🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(goal): record and replay a goal's whole trajectory (#18801)
Arvin Xud808d4ef94cd
diff --git a/.agents/skills/agent-tracing/SKILL.md b/.agents/skills/agent-tracing/SKILL.mdindex 8082d0bd012..01764d6e275 100644--- a/.agents/skills/agent-tracing/SKILL.md+++ b/.agents/skills/agent-tracing/SKILL.md@@ -75,6 +75,31 @@ Either way the snapshot is cached to `.agent-tracing/_remote/<opId>.json`, and eImplementation: `packages/agent-tracing/src/store/loadSnapshot.ts` (resolution order: local store → `_remote/` cache → injected `resolveDownloadUrl` → `TRACING_BASE_URL`) and `store/remote-store.ts` (URL built as `{base}/{agentId}/{topicId}/{opId}.json.zst`). Reading a compressed snapshot needs Node >= 22.15.+## Goal Trajectories++A goal is one complete _goal_ execution the way an operation is one complete agent execution, so it gets the same trace format one level up: `GoalTrajectory : AdvanceSnapshot` mirrors `ExecutionSnapshot : StepSnapshot`. There is no table of advances, exactly as there is no `agent_steps` table — `goal_traces` holds one rollup row per goal plus the object key, and the detail lives in the object.++The leaves join back down: an advance records the `operationId`s it put in flight (on `tick.effects[].operationId`), so `lh trace op inspect <opId>` continues from where the goal trace stops.++```bash+agent-tracing goal # list local goal trajectories+agent-tracing goal goal_xxx # the run: triggers, outcomes, graph, gates, ops+agent-tracing goal goal_xxx -a 3 # one advance in full, with the frontier it ranked+agent-tracing goal goal_xxx -j # raw JSON+```++What each tick records is the **decision input**, not just the result: the graph it read (as a delta against the previous tick), the budget it evaluated, the responsible task's state, and every eligible work node **including the ones it passed over**. Without the losers a trace cannot answer "why not that node".++**Storage** follows the operation switch, so a deployment that keeps one keeps the other:++- Completed: `goal-traces/{goalId}.json.zst`+- In progress: `goal-traces/_partial/{goalId}.json.zst` (an unfinished long-horizon goal is the normal thing to inspect)+- Dev: `.goal-tracing/{goalId}.json`++**Replay.** `replayGoalAgainstCurrentCoordinator(trajectory)` re-runs the real `decideNextMove` over the recorded inputs and reports `{advanceSeq, tickIndex, field, recorded, replayed}` wherever the current coordinator would now choose differently. This reproduces the coordinator's _decisions_ exactly; it says nothing about whether the dispatched work would have gone the same way.++Implementation: `packages/agent-tracing/src/goal/`, recorded through `apps/server/src/services/goal/advanceGoal.ts` (the single funnel every advance passes through) via the `onDecision` side channel on `GoalService.tick`.+## CLI CommandsAll commands run from the **repo root**:diff --git a/apps/cli/src/commands/goal.ts b/apps/cli/src/commands/goal.tsindex 8e5237bd988..555c7404183 100644--- a/apps/cli/src/commands/goal.ts+++ b/apps/cli/src/commands/goal.ts@@ -87,11 +87,11 @@ export function registerGoalCommand(program: Command) {const result = await client.goal.create.mutate({agentId: options.agent,config:- options.maxAttemptsPerWork || options.maxStepsPerRun || options.operationLeaseTimeoutMs+ options.maxAttemptsPerTask || options.maxStepsPerRun || options.operationLeaseTimeoutMs? {recovery: {- maxAttemptsPerWork: options.maxAttemptsPerWork- ? Number.parseInt(options.maxAttemptsPerWork, 10)+ maxAttemptsPerTask: options.maxAttemptsPerTask+ ? Number.parseInt(options.maxAttemptsPerTask, 10): undefined,maxStepsPerRun: options.maxStepsPerRun? Number.parseInt(options.maxStepsPerRun, 10)@@ -289,7 +289,7 @@ export function registerGoalCommand(program: Command) {.action(async (id: string,- kind: 'decision' | 'finding' | 'problem' | 'work',+ kind: 'decision' | 'finding' | 'problem' | 'task',title: string,options,) => {diff --git a/apps/cli/src/commands/trace/goal/index.ts b/apps/cli/src/commands/trace/goal/index.tsnew file mode 100644index 00000000000..6d0bfb82555--- /dev/null+++ b/apps/cli/src/commands/trace/goal/index.ts@@ -0,0 +1,16 @@+import type { Command } from 'commander';++import { registerGoalInspectCommand } from './inspect';+import { registerGoalListCommand } from './list';++/**+ * `lh trace goal` — traces of a whole goal run, one scale above `lh trace op`.+ * A goal's advances dispatch operations, so an advance's `op=` hands off to+ * `lh trace op inspect`.+ */+export function registerGoalCommand(parent: Command) {+ const goal = parent.command('goal').description('Traces of a whole goal run');++ registerGoalInspectCommand(goal);+ registerGoalListCommand(goal);+}diff --git a/apps/cli/src/commands/trace/goal/inspect.ts b/apps/cli/src/commands/trace/goal/inspect.tsnew file mode 100644index 00000000000..8cba531e8e8--- /dev/null+++ b/apps/cli/src/commands/trace/goal/inspect.ts@@ -0,0 +1,38 @@+import { renderGoalAdvanceDetail, renderGoalTrajectory } from '@lobechat/agent-tracing';+import type { Command } from 'commander';+import { InvalidArgumentError } from 'commander';++import { resolveTrajectoryOrExit } from './trajectory';++export function registerGoalInspectCommand(parent: Command) {+ parent+ .command('inspect')+ .alias('i')+ .description("Inspect a goal's trajectory: its advances, and the decision behind each tick")+ .argument('<target>', 'Goal id, trajectory json path, or URL')+ .option(+ '-a, --advance <n>',+ 'Show one advance in full, with the frontier it ranked',+ (value) => {+ const parsed = Number.parseInt(value, 10);+ if (!Number.isFinite(parsed))+ throw new InvalidArgumentError('--advance must be an integer');+ return parsed;+ },+ )+ .option('-j, --json', 'Output as JSON')+ .action(async (target: string, opts: { advance?: number; json?: boolean }) => {+ const trajectory = await resolveTrajectoryOrExit(target);++ if (opts.json) {+ console.log(JSON.stringify(trajectory, null, 2));+ return;+ }++ console.log(+ opts.advance === undefined+ ? renderGoalTrajectory(trajectory)+ : renderGoalAdvanceDetail(trajectory, opts.advance),+ );+ });+}diff --git a/apps/cli/src/commands/trace/goal/list.ts b/apps/cli/src/commands/trace/goal/list.tsnew file mode 100644index 00000000000..70fce506c2f--- /dev/null+++ b/apps/cli/src/commands/trace/goal/list.ts@@ -0,0 +1,113 @@+import { FileGoalTraceStore } from '@lobechat/agent-tracing';+import type { Command } from 'commander';+import { InvalidArgumentError } from 'commander';+import pc from 'picocolors';++import { getTrpcClient } from '../../../api/client';+import { printTable, timeAgo } from '../../../utils/format';+import { log } from '../../../utils/logger';++const DEFAULT_LIMIT = 20;++/**+ * Shape of one `agentTrace.listGoalTraces` row. Declared locally because the+ * CLI's standalone `tsc` run cannot resolve the `@/server/routers/lambda` path+ * alias, so TRPC results widen to `any` here (same reason `op/list.ts` does).+ */+interface GoalTraceRow {+ advancesByTrigger: Record<string, number> | null;+ advancesTotal: number | null;+ finalStatus: string | null;+ goalId: string;+ hasTrace: boolean;+ startedAt: Date | string | null;+ title: string;+}++/** `sweep=38 settle=112` — the split that says how much of a run was the safety net. */+const formatTriggers = (counts: Record<string, number> | null): string => {+ if (!counts) return '-';+ const entries = Object.entries(counts).sort((a, b) => b[1] - a[1]);+ return entries.length === 0 ? '-' : entries.map(([key, n]) => `${key}=${n}`).join(' ');+};++/**+ * Server-side listing for `--server`: goals live on the server, so this is the+ * only way to see a run recorded anywhere but this machine. Local-first+ * otherwise, matching `lh trace op list`, so a dev with no session still gets+ * the goals they just ran.+ */+const listFromServer = async (limit: number, json?: boolean) => {+ const client = await getTrpcClient();+ const { data } = await client.agentTrace.listGoalTraces.query({ limit });++ if (json) {+ console.log(JSON.stringify(data, null, 2));+ return;+ }++ if (data.length === 0) {+ log.info('No goal trajectories recorded yet.');+ return;+ }++ printTable(+ (data as GoalTraceRow[]).map((trace) => [+ trace.goalId,+ trace.finalStatus ?? pc.dim('running'),+ trace.hasTrace ? pc.green('yes') : pc.dim('—'),+ trace.advancesTotal == null ? '-' : String(trace.advancesTotal),+ formatTriggers(trace.advancesByTrigger),+ trace.startedAt ? timeAgo(trace.startedAt) : '-',+ trace.title,+ ]),+ ['GOAL', 'STATUS', 'TRACE', 'ADVANCES', 'TRIGGERS', 'AGE', 'TITLE'],+ );+};++export function registerGoalListCommand(parent: Command) {+ parent+ .command('list')+ .alias('ls')+ .description('List recorded goal trajectories (locally, or from the server)')+ .option('--server', 'List the goals recorded on the server instead of local files')+ .option('-l, --limit <n>', 'Number of goals to list', (value) => {+ const parsed = Number.parseInt(value, 10);+ if (!Number.isFinite(parsed)) throw new InvalidArgumentError('--limit must be an integer');+ return parsed;+ })+ .option('-j, --json', 'Output as JSON')+ .action(async (opts: { json?: boolean; limit?: number; server?: boolean }) => {+ const limit = opts.limit ?? DEFAULT_LIMIT;++ if (opts.server) {+ await listFromServer(limit, opts.json);+ return;+ }++ const summaries = await new FileGoalTraceStore().list({ limit });++ if (opts.json) {+ console.log(JSON.stringify(summaries, null, 2));+ return;+ }++ if (summaries.length === 0) {+ log.info(+ 'No local goal trajectories in .goal-tracing/. Pass --server to list remote runs.',+ );+ return;+ }++ printTable(+ summaries.map((summary) => [+ summary.goalId,+ summary.completionReason ?? pc.dim('running'),+ String(summary.advances),+ timeAgo(new Date(summary.createdAt)),+ summary.title,+ ]),+ ['GOAL', 'STATUS', 'ADVANCES', 'AGE', 'TITLE'],+ );+ });+}diff --git a/apps/cli/src/commands/trace/goal/trajectory.ts b/apps/cli/src/commands/trace/goal/trajectory.tsnew file mode 100644index 00000000000..a23863715f2--- /dev/null+++ b/apps/cli/src/commands/trace/goal/trajectory.ts@@ -0,0 +1,54 @@+import { type GoalTrajectory, loadGoalTrajectory } from '@lobechat/agent-tracing';+import { TRPCClientError } from '@trpc/client';++import { getTrpcClient } from '../../../api/client';+import { log } from '../../../utils/logger';++/**+ * Resolve the trajectory a `lh trace goal` subcommand was pointed at, or exit+ * with a message that says what to do about it.+ *+ * Unlike an operation snapshot there is no `TRACING_BASE_URL` fallback: a goal+ * trajectory's key lives on `goal_traces` and cannot be derived from the goal+ * id, so the server is the only way in. That is a feature — inspecting a+ * production goal needs a LobeHub login and nothing else.+ */+export const resolveTrajectoryOrExit = async (target: string): Promise<GoalTrajectory> => {+ // Why the server declined, kept so the final message can say "no trajectory+ // recorded" rather than "not found locally".+ let serverReason: string | undefined;++ const resolveDownloadUrl = async (goalId: string): Promise<string | null> => {+ const client = await getTrpcClient();++ try {+ const { data } = await client.agentTrace.getGoalTrajectoryUrl.query({ goalId });+ return data.url;+ } catch (error) {+ // NOT_FOUND means the goal is absent, outside the caller's scope, or+ // recorded nothing — all "nothing to download". Anything else (auth,+ // network, a signing failure) is real and must not be swallowed.+ if (error instanceof TRPCClientError && error.data?.code === 'NOT_FOUND') {+ serverReason = error.message;+ return null;+ }+ throw error;+ }+ };++ try {+ const trajectory = await loadGoalTrajectory(target, {+ allowDownload: true,+ resolveDownloadUrl,+ });+ if (trajectory) return trajectory;++ log.error(+ serverReason ??+ `No trajectory found for "${target}". Run \`lh trace goal list\` to see which goals have one.`,+ );+ } catch (error) {+ log.error(error instanceof Error ? error.message : String(error));+ }+ process.exit(1);+};diff --git a/apps/cli/src/commands/trace/index.ts b/apps/cli/src/commands/trace/index.tsindex 94246adb627..296236113ca 100644--- a/apps/cli/src/commands/trace/index.ts+++ b/apps/cli/src/commands/trace/index.ts@@ -1,5 +1,6 @@import type { Command } from 'commander';+import { registerGoalCommand } from './goal';import { registerOpCommand } from './op';export function registerTraceCommand(program: Command) {@@ -8,4 +9,5 @@ export function registerTraceCommand(program: Command) {.description('Inspect and replay recorded agent execution traces');registerOpCommand(trace);+ registerGoalCommand(trace);}diff --git a/apps/server/src/modules/GoalTracing/S3GoalTraceStore.ts b/apps/server/src/modules/GoalTracing/S3GoalTraceStore.tsnew file mode 100644index 00000000000..3aeb1d94a8d--- /dev/null+++ b/apps/server/src/modules/GoalTracing/S3GoalTraceStore.ts@@ -0,0 +1,105 @@+import { promisify } from 'node:util';+import { zstdCompress, zstdDecompress } from 'node:zlib';++import type { GoalTraceSummary, GoalTrajectory, IGoalTraceStore } from '@lobechat/agent-tracing';+import debug from 'debug';++import { FileS3 } from '@/server/modules/S3';++const compressZstd = promisify(zstdCompress);+const decompressZstd = promisify(zstdDecompress);++const log = debug('lobe-server:goal-tracing:s3');++const TRACE_PREFIX = 'goal-traces';+const TRAJECTORY_SUFFIX = '.json.zst';+const ZSTD_CONTENT_TYPE = 'application/zstd';++/**+ * Canonical S3 key for a goal's finalized trajectory. A goal id is stable for+ * the life of the goal, so the key is derivable from it alone — no column has+ * to carry it, the same way `parseOperationId` reconstructs an operation's key.+ */+export const buildGoalTraceKey = (goalId: string): string =>+ `${TRACE_PREFIX}/${goalId}${TRAJECTORY_SUFFIX}`;++/**+ * S3-backed goal trajectories.+ *+ * One object per goal, accumulated through a partial exactly like an operation+ * snapshot. The read-modify-write per advance is the same trade the operation+ * store already makes per step: an advance costs seconds of coordinator work+ * and minutes of agent execution, so a compressed object round trip is noise.+ *+ * S3 paths:+ * - Final: goal-traces/{goalId}.json.zst+ * - Partial: goal-traces/_partial/{goalId}.json.zst (deleted on finalization)+ */+export class S3GoalTraceStore implements IGoalTraceStore {+ private readonly s3: FileS3;++ constructor() {+ this.s3 = new FileS3();+ }++ private partialKey(goalId: string): string {+ return `${TRACE_PREFIX}/_partial/${goalId}${TRAJECTORY_SUFFIX}`;+ }++ private async encode(value: unknown): Promise<Buffer> {+ return compressZstd(Buffer.from(JSON.stringify(value)));+ }++ private async decode<T>(bytes: Uint8Array): Promise<T> {+ const buffer = await decompressZstd(Buffer.from(bytes));+ return JSON.parse(buffer.toString('utf8')) as T;+ }++ async save(trajectory: GoalTrajectory): Promise<void> {+ const key = buildGoalTraceKey(trajectory.goalId);+ log('saving goal trajectory to S3: %s', key);+ await this.s3.uploadBuffer(key, await this.encode(trajectory), ZSTD_CONTENT_TYPE);+ }++ async get(goalId: string): Promise<GoalTrajectory | null> {+ try {+ return await this.decode<GoalTrajectory>(+ await this.s3.getFileByteArray(buildGoalTraceKey(goalId)),+ );+ } catch {+ return null;+ }+ }++ // Listing means scanning a prefix; the CLI resolves goals through the+ // database instead, the same way it lists operations.+ async list(): Promise<GoalTraceSummary[]> {+ return [];+ }++ async listPartials(): Promise<string[]> {+ return [];+ }++ async loadPartial(goalId: string): Promise<Partial<GoalTrajectory> | null> {+ try {+ return await this.decode<Partial<GoalTrajectory>>(+ await this.s3.getFileByteArray(this.partialKey(goalId)),+ );+ } catch {+ return null;+ }+ }++ async savePartial(goalId: string, partial: Partial<GoalTrajectory>): Promise<void> {+ await this.s3.uploadBuffer(+ this.partialKey(goalId),+ await this.encode(partial),+ ZSTD_CONTENT_TYPE,+ );+ }++ async removePartial(goalId: string): Promise<void> {+ await this.s3.deleteFile(this.partialKey(goalId)).catch(() => {});+ }+}diff --git a/apps/server/src/modules/GoalTracing/index.ts b/apps/server/src/modules/GoalTracing/index.tsnew file mode 100644index 00000000000..f95b93fbcf5--- /dev/null+++ b/apps/server/src/modules/GoalTracing/index.ts@@ -0,0 +1 @@+export { buildGoalTraceKey, S3GoalTraceStore } from './S3GoalTraceStore';diff --git a/apps/server/src/router-hono/workflows/goal/handlers/advance.ts b/apps/server/src/router-hono/workflows/goal/handlers/advance.tsindex 594a40d6176..e9101ea119a 100644--- a/apps/server/src/router-hono/workflows/goal/handlers/advance.ts+++ b/apps/server/src/router-hono/workflows/goal/handlers/advance.ts@@ -1,3 +1,4 @@+import type { GoalAdvanceTrigger } from '@lobechat/agent-tracing';import debug from 'debug';import type { Context } from 'hono';@@ -7,6 +8,7 @@ const log = debug('lobe-server:workflows:goal:advance');export interface GoalAdvancePayload {goalId?: string;+ trigger?: GoalAdvanceTrigger;userId?: string;workspaceId?: string;}@@ -24,13 +26,13 @@ export interface GoalAdvancePayload {export async function advance(c: Context) {try {const body = (await c.req.json().catch(() => ({}))) as GoalAdvancePayload;- const { goalId, userId, workspaceId } = body ?? {};+ const { goalId, trigger, userId, workspaceId } = body ?? {};if (!goalId || !userId) {return c.json({ error: 'goalId and userId are required', success: false }, 400);}- const outcome = await advanceGoal({ goalId, userId, workspaceId });+ const outcome = await advanceGoal({ goalId, trigger, userId, workspaceId });log('goal %s advanced in %d tick(s) → %s', goalId, outcome.ticks, outcome.result.outcome);return c.json({diff --git a/apps/server/src/router-hono/workflows/goal/handlers/sweep.ts b/apps/server/src/router-hono/workflows/goal/handlers/sweep.tsindex 8af174bb2c6..bb05ac9b15d 100644--- a/apps/server/src/router-hono/workflows/goal/handlers/sweep.ts+++ b/apps/server/src/router-hono/workflows/goal/handlers/sweep.ts@@ -58,6 +58,7 @@ export async function sweep(c: Context) {const advanced = await fanout(stalled.map((goal) => ({goalId: goal.id,+ trigger: 'sweep' as const,userId: goal.userId,workspaceId: goal.workspaceId ?? undefined,})),@@ -72,6 +73,7 @@ export async function sweep(c: Context) {interface StalledGoal {goalId: string;+ trigger: 'sweep';userId: string;workspaceId?: string;}diff --git a/apps/server/src/routers/lambda/agentTrace.ts b/apps/server/src/routers/lambda/agentTrace.tsindex 7be3f17cfc7..b527510bb2c 100644--- a/apps/server/src/routers/lambda/agentTrace.ts+++ b/apps/server/src/routers/lambda/agentTrace.ts@@ -3,6 +3,7 @@ import { z } from 'zod';import { wsCompatProcedure } from '@/business/server/trpc-middlewares/workspaceAuth';import { AgentOperationModel } from '@/database/models/agentOperation';+import { GoalTraceModel } from '@/database/models/goalTrace';import { router } from '@/libs/trpc/lambda';import { serverDatabase } from '@/libs/trpc/lambda/middleware';import { FileS3 } from '@/server/modules/S3';@@ -24,6 +25,7 @@ const agentTraceProcedure = wsCompatProcedure.use(serverDatabase).use(async (optctx.userId,ctx.workspaceId ?? undefined,),+ goalTraceModel: new GoalTraceModel(ctx.serverDB, ctx.userId, ctx.workspaceId ?? undefined),},});});@@ -78,6 +80,80 @@ export const agentTraceRouter = router({}}),+ /**+ * Pre-signed GET for one goal's trajectory object.+ *+ * A goal trajectory has no derivable key — unlike an operation snapshot,+ * whose id carries its agent and topic — so this is the only way to reach+ * one. Same reasoning as `getSnapshotUrl` for not returning the blob itself:+ * it is zstd and the client decompresses it directly.+ */+ getGoalTrajectoryUrl: agentTraceProcedure+ .input(z.object({ goalId: z.string() }))+ .query(async ({ input, ctx }) => {+ try {+ const trace = await ctx.goalTraceModel.findById(input.goalId);+ if (!trace) {+ throw new TRPCError({+ code: 'NOT_FOUND',+ message:+ 'No trajectory was recorded for this goal. It may predate goal tracing, ' ++ 'or trace upload was disabled when it ran.',+ });+ }++ if (!trace.traceS3Key) {+ throw new TRPCError({+ code: 'NOT_FOUND',+ message: 'This goal has an observation row but no trajectory object to download.',+ });+ }++ return {+ data: {+ goalId: trace.goalId,+ key: trace.traceS3Key,+ url: await new FileS3().createPreSignedUrlForPreview(trace.traceS3Key),+ },+ success: true as const,+ };+ } catch (error) {+ if (error instanceof TRPCError) throw error;+ console.error('[agentTrace:getGoalTrajectoryUrl]', error);+ throw new TRPCError({+ cause: error,+ code: 'INTERNAL_SERVER_ERROR',+ message: 'Failed to sign the goal trajectory URL',+ });+ }+ }),++ /** Goals that recorded a trajectory, newest run first. */+ listGoalTraces: agentTraceProcedure+ .input(z.object({ limit: z.number().min(1).max(100).default(20) }))+ .query(async ({ input, ctx }) => {+ try {+ const traces = await ctx.goalTraceModel.list(input.limit);++ return {+ // The key is an internal storage detail; callers only need to know+ // whether there is an object to fetch.+ data: traces.map(({ traceS3Key, ...trace }) => ({+ ...trace,+ hasTrace: Boolean(traceS3Key),+ })),+ success: true as const,+ };+ } catch (error) {+ console.error('[agentTrace:listGoalTraces]', error);+ throw new TRPCError({+ cause: error,+ code: 'INTERNAL_SERVER_ERROR',+ message: 'Failed to list goal traces',+ });+ }+ }),+/** Operations recorded for a topic, newest first. */listOperations: agentTraceProcedure.input(z.object({ limit: z.number().min(1).max(100).default(20), topicId: z.string() }))diff --git a/apps/server/src/routers/lambda/goal.ts b/apps/server/src/routers/lambda/goal.tsindex d2fe721195d..627ce5b769a 100644--- a/apps/server/src/routers/lambda/goal.ts+++ b/apps/server/src/routers/lambda/goal.ts@@ -79,7 +79,7 @@ export const goalRouter = router({.input(idInput.extend({description: z.string().optional(),- kind: z.enum(['problem', 'work', 'finding', 'decision']),+ kind: z.enum(['problem', 'task', 'finding', 'decision']),priority: z.number().int().optional(),status: z.enum(['proposed', 'active', 'waiting', 'resolved', 'rejected', 'retired'])@@ -105,7 +105,7 @@ export const goalRouter = router({.object({recovery: z.object({- maxAttemptsPerWork: z.number().int().positive().optional(),+ maxAttemptsPerTask: z.number().int().positive().optional(),maxStepsPerRun: z.number().int().positive().nullable().optional(),operationLeaseTimeoutMs: z.number().int().min(60_000).optional(),})@@ -134,6 +134,7 @@ export const goalRouter = router({// coordinator takes it from here without a client holding a loop open.await scheduleGoalAdvance({goalId: data.goal.id,+ trigger: 'create',userId: ctx.userId,workspaceId: ctx.workspaceId ?? undefined,});@@ -162,6 +163,7 @@ export const goalRouter = router({// Answering the gate is what unblocks the Work; carry on from here.await scheduleGoalAdvance({goalId: input.id,+ trigger: 'decide',userId: ctx.userId,workspaceId: ctx.workspaceId ?? undefined,});@@ -182,6 +184,7 @@ export const goalRouter = router({try {const { result, ticks } = await advanceGoal({goalId: input.id,+ trigger: 'manual',userId: ctx.userId,workspaceId: ctx.workspaceId ?? undefined,});@@ -249,6 +252,7 @@ export const goalRouter = router({const data = await ctx.goalService.resume(input.id);await scheduleGoalAdvance({goalId: input.id,+ trigger: 'resume',userId: ctx.userId,workspaceId: ctx.workspaceId ?? undefined,});@@ -272,6 +276,7 @@ export const goalRouter = router({// it should start moving again without a second gesture.await scheduleGoalAdvance({goalId: id,+ trigger: 'budget',userId: ctx.userId,workspaceId: ctx.workspaceId ?? undefined,});diff --git a/apps/server/src/services/goal/advanceGoal.test.ts b/apps/server/src/services/goal/advanceGoal.test.tsindex 8aa4fe39f2d..e35fa3bf68c 100644--- a/apps/server/src/services/goal/advanceGoal.test.ts+++ b/apps/server/src/services/goal/advanceGoal.test.ts@@ -1,10 +1,29 @@import type { GoalTickOutcome, GoalTickResult } from '@lobechat/types';import { beforeEach, describe, expect, it, vi } from 'vitest';-const mocks = vi.hoisted(() => ({ tick: vi.fn() }));+const mocks = vi.hoisted(() => ({+ createStore: vi.fn(() => null as unknown),+ execute: vi.fn(),+ status: vi.fn(),+ tick: vi.fn(),+ upsert: vi.fn(),+}));-vi.mock('@/database/server', () => ({ getServerDB: vi.fn().mockResolvedValue({}) }));-vi.mock('./index', () => ({ GoalService: vi.fn(() => ({ tick: mocks.tick })) }));+// The trajectory write runs inside a transaction so it can hold a per-goal+// advisory lock, so the fake database has to model that seam.+vi.mock('@/database/server', () => ({+ getServerDB: vi.fn().mockResolvedValue({+ execute: mocks.execute,+ transaction: (run: (tx: unknown) => unknown) => run({ execute: mocks.execute }),+ }),+}));+vi.mock('./index', () => ({+ GoalService: vi.fn(() => ({ status: mocks.status, tick: mocks.tick })),+}));+vi.mock('./traceStore', () => ({ createDefaultGoalTraceStore: mocks.createStore }));+vi.mock('@/database/models/goalTrace', () => ({+ GoalTraceModel: vi.fn(() => ({ upsert: mocks.upsert })),+}));const { advanceGoal, MAX_TICKS_PER_ADVANCE } = await import('./advanceGoal');@@ -75,3 +94,177 @@ describe('advanceGoal', () => {expect(GoalService).toHaveBeenCalledWith(expect.anything(), 'owner-9', 'ws-3');});});++describe('advanceGoal trajectory recording', () => {+ const graphState = {+ decisions: [],+ edges: [],+ goal: { id: 'goal-1', status: 'running', title: 'Reproduce nanoGPT' },+ nodes: [],+ };++ const observation = (outcome: GoalTickOutcome) => ({+ at: 1000,+ branch: 'dispatch_task' as const,+ candidates: [],+ effects: [{ operationId: 'op_1', type: 'started_run' as const }],+ graphState,+ message: outcome,+ outcome,+ });++ /** Minimal store that only has to remember what was written. */+ const memoryStore = () => {+ const state: { partial?: any; saved?: any } = {};+ return {+ state,+ store: {+ get: async () => state.saved ?? null,+ list: async () => [],+ listPartials: async () => [],+ loadPartial: async () => state.partial ?? null,+ removePartial: async () => {+ state.partial = undefined;+ },+ save: async (trajectory: any) => {+ state.saved = trajectory;+ },+ savePartial: async (_id: string, partial: any) => {+ state.partial = partial;+ },+ },+ };+ };++ beforeEach(() => {+ mocks.tick.mockReset();+ mocks.status.mockReset();+ mocks.createStore.mockReset();+ mocks.upsert.mockReset();+ mocks.execute.mockReset();+ });++ it('records the ticks it observed, tagged with what triggered the advance', async () => {+ const { state, store } = memoryStore();+ mocks.createStore.mockReturnValue(store);+ mocks.status.mockResolvedValue('running');+ mocks.tick.mockImplementation(async (_goalId: string, options: any) => {+ options?.onDecision?.(observation('waiting_external'));+ return tickResult('waiting_external');+ });++ await advanceGoal({ goalId: 'goal-1', trigger: 'sweep', userId: 'user-1' });++ expect(state.partial.advances).toHaveLength(1);+ expect(state.partial.advances[0]).toMatchObject({+ childOperationIds: ['op_1'],+ seq: 0,+ trigger: 'sweep',+ });+ expect(state.partial.advances[0].ticks[0]).toMatchObject({ branch: 'dispatch_task', index: 0 });+ expect(state.saved).toBeUndefined();+ });++ it('serializes the write behind a per-goal lock so overlapping advances cannot erase one another', async () => {+ const { store } = memoryStore();+ mocks.createStore.mockReturnValue(store);+ mocks.status.mockResolvedValue('running');+ mocks.tick.mockImplementation(async (_goalId: string, options: any) => {+ options?.onDecision?.(observation('waiting_external'));+ return tickResult('waiting_external');+ });++ await advanceGoal({ goalId: 'goal-1', trigger: 'sweep', userId: 'user-1' });++ // Appending is read-modify-write on one object; without this the settle,+ // sweep and manual advances that overlap on a goal would pick the same+ // `seq` and the last writer would drop the others.+ expect(mocks.execute).toHaveBeenCalledTimes(1);+ expect(JSON.stringify(mocks.execute.mock.calls[0][0])).toContain('pg_advisory_xact_lock');+ });++ it('writes the observation row while the goal is still running, not only at the end', async () => {+ const { store } = memoryStore();+ mocks.createStore.mockReturnValue(store);+ mocks.status.mockResolvedValue('running');+ mocks.tick.mockImplementation(async (_goalId: string, options: any) => {+ options?.onDecision?.(observation('waiting_external'));+ return tickResult('waiting_external');+ });++ await advanceGoal({ goalId: 'goal-1', trigger: 'sweep', userId: 'user-1' });++ expect(mocks.upsert).toHaveBeenCalledWith(+ expect.objectContaining({+ advancesByTrigger: { sweep: 1 },+ advancesTotal: 1,+ finalStatus: null,+ goalId: 'goal-1',+ ticksTotal: 1,+ traceS3Key: 'goal-traces/goal-1.json.zst',+ // The column name, not the rollup's. Pinned so the mapping in+ // `writeObservationRow` cannot drift silently.+ workOperations: 1,+ }),+ );+ });++ it('closes the trajectory once the goal itself is terminal', async () => {+ const { state, store } = memoryStore();+ mocks.createStore.mockReturnValue(store);+ mocks.status.mockResolvedValue('achieved');+ mocks.tick.mockImplementation(async (_goalId: string, options: any) => {+ options?.onDecision?.(observation('achieved'));+ return tickResult('achieved');+ });++ await advanceGoal({ goalId: 'goal-1', trigger: 'settle', userId: 'user-1' });++ expect(state.saved).toMatchObject({ completionReason: 'achieved', totalAdvances: 1 });+ expect(state.partial).toBeUndefined();+ });++ it('leaves the trajectory open for a goal that is merely parked', async () => {+ const { state, store } = memoryStore();+ mocks.createStore.mockReturnValue(store);+ mocks.status.mockResolvedValue('paused');+ mocks.tick.mockImplementation(async (_goalId: string, options: any) => {+ options?.onDecision?.(observation('no_progress'));+ return tickResult('no_progress');+ });++ await advanceGoal({ goalId: 'goal-1', trigger: 'sweep', userId: 'user-1' });++ expect(state.saved).toBeUndefined();+ expect(state.partial.advances).toHaveLength(1);+ });++ it('keeps what a failing advance managed to do, with the failure attached', async () => {+ const { state, store } = memoryStore();+ mocks.createStore.mockReturnValue(store);+ mocks.tick+ .mockImplementationOnce(async (_goalId: string, options: any) => {+ options?.onDecision?.(observation('advanced'));+ return tickResult('advanced');+ })+ .mockRejectedValueOnce(new Error('database is gone'));++ await expect(advanceGoal({ goalId: 'goal-1', userId: 'user-1' })).rejects.toThrow(+ 'database is gone',+ );++ expect(state.partial.advances[0]).toMatchObject({+ error: { message: 'database is gone', type: 'advance' },+ });+ expect(state.partial.advances[0].ticks).toHaveLength(1);+ });++ it('does not read the goal status when tracing is off', async () => {+ mocks.createStore.mockReturnValue(null);+ mocks.tick.mockResolvedValue(tickResult('no_progress'));++ await advanceGoal({ goalId: 'goal-1', userId: 'user-1' });++ expect(mocks.status).not.toHaveBeenCalled();+ });+});diff --git a/apps/server/src/services/goal/advanceGoal.ts b/apps/server/src/services/goal/advanceGoal.tsindex 34ea5b52c2d..7c3632e4651 100644--- a/apps/server/src/services/goal/advanceGoal.ts+++ b/apps/server/src/services/goal/advanceGoal.ts@@ -1,8 +1,10 @@+import type { GoalAdvanceTrigger } from '@lobechat/agent-tracing';import type { GoalTickOutcome, GoalTickResult } from '@lobechat/types';import debug from 'debug';import { getServerDB } from '@/database/server';+import { GoalAdvanceRecorder, TERMINAL_GOAL_STATUSES } from './goalTraceRecorder';import { GoalService } from './index';const log = debug('lobe-server:goal-advance');@@ -31,6 +33,8 @@ export const MAX_TICKS_PER_ADVANCE = 20;export interface AdvanceGoalParams {goalId: string;+ /** What caused this advance. Recorded on the trajectory so a run can be sliced by source. */+ trigger?: GoalAdvanceTrigger;userId: string;workspaceId?: string;}@@ -50,19 +54,52 @@ export interface AdvanceGoalOutcome {*/export const advanceGoal = async ({goalId,+ trigger = 'unknown',userId,workspaceId,}: AdvanceGoalParams): Promise<AdvanceGoalOutcome> => {const db = await getServerDB();const service = new GoalService(db, userId, workspaceId);+ const recorder = new GoalAdvanceRecorder(db, goalId, trigger);let result: GoalTickResult | undefined;- for (let ticks = 1; ticks <= MAX_TICKS_PER_ADVANCE; ticks++) {- result = await service.tick(goalId);- log('goal %s tick %d → %s (%s)', goalId, ticks, result.outcome, result.message);- if (STOP_OUTCOMES.has(result.outcome)) return { goalId, result, ticks };+ try {+ for (let ticks = 1; ticks <= MAX_TICKS_PER_ADVANCE; ticks++) {+ result = await service.tick(goalId, { onDecision: recorder.onDecision });+ log('goal %s tick %d → %s (%s)', goalId, ticks, result.outcome, result.message);+ if (STOP_OUTCOMES.has(result.outcome)) {+ await settleTrace(recorder, service, goalId);+ return { goalId, result, ticks };+ }+ }+ } catch (error) {+ // Record what the advance managed to do before it threw. A trajectory that+ // stops mid-advance with the failure attached is the whole point of keeping+ // one — losing it is exactly the blind spot this replaces.+ await recorder.flush(error);+ throw error;}log('goal %s hit the per-advance tick limit', goalId);+ await settleTrace(recorder, service, goalId);return { goalId, result: result!, ticks: MAX_TICKS_PER_ADVANCE };};++/**+ * Write the advance, then close the trajectory if the goal itself is done.+ *+ * The status is re-read rather than inferred from the outcome: `failed` is+ * reported both by a goal that is genuinely over and by a tick that could not+ * find a responsible task, and only the first should finalize.+ */+const settleTrace = async (+ recorder: GoalAdvanceRecorder,+ service: GoalService,+ goalId: string,+): Promise<void> => {+ await recorder.flush();+ if (!recorder.enabled) return;++ const status = await service.status(goalId).catch(() => undefined);+ if (status && TERMINAL_GOAL_STATUSES.has(status)) await recorder.finalize(status);+};diff --git a/apps/server/src/services/goal/decideNextMove.test.ts b/apps/server/src/services/goal/decideNextMove.test.tsnew file mode 100644index 00000000000..000023262e0--- /dev/null+++ b/apps/server/src/services/goal/decideNextMove.test.ts@@ -0,0 +1,271 @@+import type { GoalGraphNode, GoalGraphSnapshot, TaskItem } from '@lobechat/types';+import { describe, expect, it } from 'vitest';++import {+ decideNextMove,+ GOAL_ACCEPTANCE_TASK_TITLE,+ LEASE_EXPIRED_ERROR,+ needsBudget,+ selectFrontier,+ VERIFICATION_FAILED_ERROR,+} from './decideNextMove';++const node = (id: string, overrides: Partial<GoalGraphNode> = {}): GoalGraphNode =>+ ({+ createdAt: new Date(1000),+ id,+ kind: 'task',+ priority: 0,+ status: 'proposed',+ taskId: null,+ title: id,+ ...overrides,+ }) as GoalGraphNode;++const graph = (overrides: Partial<GoalGraphSnapshot> = {}): GoalGraphSnapshot =>+ ({+ decisions: [],+ edges: [],+ events: [],+ goal: { id: 'goal_1', maxRounds: null, maxTotalCost: null, status: 'running', title: 'G' },+ nodes: [],+ workVersions: [],+ ...overrides,+ }) as GoalGraphSnapshot;++const task = (overrides: Partial<TaskItem> = {}): TaskItem =>+ ({ error: null, id: 'task_1', identifier: 'T-1', status: 'backlog', ...overrides }) as TaskItem;++const decide = (+ snapshot: GoalGraphSnapshot,+ extra: Parameters<typeof decideNextMove>[0] extends infer T+ ? Partial<Omit<T & object, 'graph' | 'frontier'>>+ : never = {},+) => decideNextMove({ frontier: selectFrontier(snapshot), graph: snapshot, ...extra });++describe('selectFrontier', () => {+ it('ranks by priority, then by creation order', () => {+ const snapshot = graph({+ nodes: [+ node('late', { createdAt: new Date(3000) }),+ node('early', { createdAt: new Date(2000) }),+ node('urgent', { priority: 5, createdAt: new Date(9000) }),+ ],+ });++ expect(selectFrontier(snapshot).candidates.map((item) => item.nodeId)).toEqual([+ 'urgent',+ 'early',+ 'late',+ ]);+ });++ it('keeps blocked nodes as candidates but never chooses them', () => {+ const snapshot = graph({+ edges: [+ { id: 'e1', kind: 'depends_on', sourceNodeId: 'b', targetNodeId: 'a' },+ ] as GoalGraphSnapshot['edges'],+ nodes: [node('a', { priority: -1 }), node('b', { priority: 5 })],+ });++ const selection = selectFrontier(snapshot);++ expect(selection.candidates[0]).toMatchObject({ blockedBy: ['a'], nodeId: 'b' });+ expect(selection.chosen?.id).toBe('a');+ });++ it('drops terminal work from the frontier', () => {+ const snapshot = graph({+ nodes: [node('done', { status: 'resolved' }), node('gone', { status: 'retired' })],+ });++ expect(selectFrontier(snapshot).candidates).toEqual([]);+ });+});++describe('decideNextMove', () => {+ it('stops on a paused or terminal goal before looking at work', () => {+ const nodes = [node('a')];+ expect(decide(graph({ goal: { ...graph().goal, status: 'paused' }, nodes })).branch).toBe(+ 'goal_paused',+ );+ expect(decide(graph({ goal: { ...graph().goal, status: 'achieved' }, nodes })).branch).toBe(+ 'goal_terminal',+ );+ expect(decide(graph({ goal: { ...graph().goal, status: 'canceled' }, nodes })).outcome).toBe(+ 'failed',+ );+ });++ it('parks on an open gate ahead of any ready work', () => {+ const move = decide(+ graph({+ decisions: [+ { id: 'd1', nodeId: 'n1', question: 'Retry or retire?', status: 'pending' },+ ] as GoalGraphSnapshot['decisions'],+ nodes: [node('a')],+ }),+ );++ expect(move).toMatchObject({+ branch: 'pending_decision',+ focusNodeId: 'n1',+ message: 'Retry or retire?',+ outcome: 'waiting_human',+ });+ });++ it('asks for a responsible task when the chosen work has none', () => {+ expect(decide(graph({ nodes: [node('a')] }))).toMatchObject({+ branch: 'create_task',+ chosenNodeId: 'a',+ outcome: 'advanced',+ });+ });++ it('reports a missing task row rather than dispatching into nothing', () => {+ const snapshot = graph({ nodes: [node('a', { taskId: 'task_1' })] });++ expect(decide(snapshot, { frontierTask: null })).toMatchObject({+ branch: 'missing_task',+ outcome: 'failed',+ });+ });++ describe('with a responsible task', () => {+ const snapshot = graph({ nodes: [node('a', { taskId: 'task_1' })] });++ it('folds a completed task into a finding', () => {+ expect(decide(snapshot, { frontierTask: task({ status: 'completed' }) }).branch).toBe(+ 'consume_completed',+ );+ });++ it('separates the two recoverable failures from the ones that need a person', () => {+ expect(+ decide(snapshot, {+ frontierTask: task({ error: LEASE_EXPIRED_ERROR, status: 'paused' }),+ }).branch,+ ).toBe('recover_lease');++ expect(+ decide(snapshot, {+ frontierTask: task({ error: VERIFICATION_FAILED_ERROR, status: 'paused' }),+ }).branch,+ ).toBe('recover_verification');++ expect(+ decide(snapshot, { frontierTask: task({ error: 'Device offline', status: 'failed' }) }),+ ).toMatchObject({ branch: 'failure_decision', message: 'Device offline' });+ });++ it('treats a plain pause as waiting on a person and a run as waiting on the world', () => {+ expect(decide(snapshot, { frontierTask: task({ status: 'paused' }) })).toMatchObject({+ branch: 'task_paused',+ outcome: 'waiting_human',+ });+ expect(decide(snapshot, { frontierTask: task({ status: 'running' }) })).toMatchObject({+ branch: 'task_running',+ outcome: 'waiting_external',+ });+ });++ it('stops on an exhausted budget instead of dispatching', () => {+ const move = decide(snapshot, {+ budget: {+ costLimitReached: false,+ maxRounds: 3,+ roundLimitReached: true,+ runs: 3,+ totalCost: 1,+ },+ frontierTask: task(),+ });++ expect(move).toMatchObject({ branch: 'budget_exhausted', outcome: 'no_progress' });+ expect(move.message).toContain('3/');+ });++ it('dispatches when the budget still has room', () => {+ expect(+ decide(snapshot, {+ budget: {+ costLimitReached: false,+ roundLimitReached: false,+ runs: 1,+ totalCost: 0.5,+ },+ frontierTask: task(),+ }).branch,+ ).toBe('dispatch_task');+ });+ });++ describe('with no ready work', () => {+ it('reports an empty graph and a fully blocked one differently', () => {+ expect(decide(graph()).message).toContain('add a work node');++ const blocked = graph({+ edges: [+ { id: 'e1', kind: 'depends_on', sourceNodeId: 'b', targetNodeId: 'missing' },+ ] as GoalGraphSnapshot['edges'],+ nodes: [node('b')],+ });+ expect(decide(blocked)).toMatchObject({+ branch: 'no_frontier',+ outcome: 'no_progress',+ });+ });++ it('moves to the terminal acceptance contract once every Work is done', () => {+ const snapshot = graph({+ goal: { ...graph().goal, requirement: 'Prove it' },+ nodes: [node('a', { status: 'resolved' })],+ });++ expect(decide(snapshot)).toMatchObject({+ branch: 'terminal_acceptance',+ outcome: 'advanced',+ });+ });++ it('holds the goal open while its acceptance Work has not passed', () => {+ const snapshot = graph({+ goal: { ...graph().goal, requirement: 'Prove it' },+ nodes: [+ node('a', { status: 'resolved' }),+ node('acc', { status: 'retired', title: GOAL_ACCEPTANCE_TASK_TITLE }),+ ],+ });++ expect(decide(snapshot)).toMatchObject({+ branch: 'terminal_acceptance',+ focusNodeId: 'acc',+ outcome: 'no_progress',+ });+ });++ it('achieves the goal when acceptance resolved, or when there is no requirement', () => {+ const withAcceptance = graph({+ goal: { ...graph().goal, requirement: 'Prove it' },+ nodes: [+ node('a', { status: 'resolved' }),+ node('acc', { status: 'resolved', title: GOAL_ACCEPTANCE_TASK_TITLE }),+ ],+ });+ expect(decide(withAcceptance).outcome).toBe('achieved');++ const withoutRequirement = graph({ nodes: [node('a', { status: 'resolved' })] });+ expect(decide(withoutRequirement).outcome).toBe('achieved');+ });+ });+});++describe('needsBudget', () => {+ it('is true only for a task the coordinator could still start', () => {+ expect(needsBudget(task({ status: 'backlog' }))).toBe(true);+ expect(needsBudget(task({ status: 'running' }))).toBe(false);+ expect(needsBudget(task({ status: 'completed' }))).toBe(false);+ expect(needsBudget(null)).toBe(false);+ });+});diff --git a/apps/server/src/services/goal/decideNextMove.ts b/apps/server/src/services/goal/decideNextMove.tsnew file mode 100644index 00000000000..f67025f0e67--- /dev/null+++ b/apps/server/src/services/goal/decideNextMove.ts@@ -0,0 +1,306 @@+import type {+ FrontierCandidate,+ GoalBudgetState,+ GoalTickBranch,+ GoalTickOutcome,+} from '@lobechat/agent-tracing';+import type { GoalGraphNode, GoalGraphSnapshot, TaskItem } from '@lobechat/types';++export const GOAL_ACCEPTANCE_TASK_TITLE = 'Complete full Goal acceptance';++/** Reason strings the recovery paths key off, written by the settle path. */+export const LEASE_EXPIRED_ERROR = 'Goal Work operation lease expired.';+export const VERIFICATION_FAILED_ERROR = 'Delivery did not pass verification.';++const TERMINAL_NODE_STATUSES = new Set(['resolved', 'rejected', 'retired']);++export interface FrontierSelection {+ /** Every eligible work node, best first. */+ candidates: FrontierCandidate[];+ chosen?: GoalGraphNode;+}++/**+ * Rank the work nodes that could run right now.+ *+ * Split out of the decision so the caller can resolve the chosen node's task+ * before deciding, and exported so a trace keeps the whole ranking rather than+ * only the winner — "why not that node" is unanswerable from the winner alone.+ */+export const selectFrontier = (graph: GoalGraphSnapshot): FrontierSelection => {+ const resolvedNodeIds = new Set(+ graph.nodes.filter((node) => node.status === 'resolved').map((node) => node.id),+ );++ const eligible = graph.nodes+ .filter((node) => node.kind === 'task' && !TERMINAL_NODE_STATUSES.has(node.status))+ .map((node) => ({+ blockedBy: graph.edges+ .filter(+ (edge) =>+ edge.kind === 'depends_on' &&+ edge.sourceNodeId === node.id &&+ !resolvedNodeIds.has(edge.targetNodeId),+ )+ .map((edge) => edge.targetNodeId),+ node,+ }))+ .sort(+ (a, b) =>+ b.node.priority - a.node.priority ||+ a.node.createdAt.getTime() - b.node.createdAt.getTime(),+ );++ return {+ candidates: eligible.map(({ blockedBy, node }) => ({+ blockedBy,+ nodeId: node.id,+ priority: node.priority,+ status: node.status,+ title: node.title,+ })),+ chosen: eligible.find(({ blockedBy }) => blockedBy.length === 0)?.node,+ };+};++/**+ * Whether the coordinator would spend money on this task, and therefore whether+ * the budget has to be read before deciding.+ *+ * Every other task status resolves to a branch that costs nothing, so a goal+ * that is merely waiting on a running Work does not pay for a budget query on+ * every sweep.+ */+export const needsBudget = (task?: TaskItem | null): boolean => {+ if (!task) return false;+ return !['completed', 'failed', 'canceled', 'paused', 'running', 'scheduled'].includes(+ task.status,+ );+};++export interface GoalMoveInput {+ /** Required only when {@link needsBudget} says the branch could dispatch. */+ budget?: GoalBudgetState;+ frontier: FrontierSelection;+ /** The chosen work node's responsible task, when it already has one. */+ frontierTask?: TaskItem | null;+ graph: GoalGraphSnapshot;+}++export interface GoalMove {+ branch: GoalTickBranch;+ candidates: FrontierCandidate[];+ chosenNodeId?: string;+ /** The node this move is about when it is not the chosen frontier. */+ focusNodeId?: string;+ message: string;+ /**+ * The outcome this branch reports when it runs to completion. Recovery+ * branches can still end up elsewhere depending on how much budget is left,+ * which is why the trace records the actual outcome separately.+ */+ outcome: GoalTickOutcome;+}++/**+ * The coordinator's decision, with no IO in it.+ *+ * `tick` used to interleave choosing and doing, so what it decided existed only+ * for as long as the call. Pulling the choice out means a trajectory can record+ * the decision surface and hand it back later: run this function over recorded+ * inputs and any change in coordinator policy shows up as a diff rather than as+ * a surprise on the next live goal.+ */+export const decideNextMove = ({+ budget,+ frontier,+ frontierTask,+ graph,+}: GoalMoveInput): GoalMove => {+ const { candidates, chosen } = frontier;+ const base = { candidates, chosenNodeId: chosen?.id };++ if (graph.goal.status === 'paused') {+ return { ...base, branch: 'goal_paused', message: 'Goal is paused', outcome: 'no_progress' };+ }+ if (graph.goal.status === 'achieved') {+ return {+ ...base,+ branch: 'goal_terminal',+ message: 'Goal is already achieved',+ outcome: 'achieved',+ };+ }+ if (graph.goal.status === 'failed' || graph.goal.status === 'canceled') {+ return {+ ...base,+ branch: 'goal_terminal',+ message: `Goal is ${graph.goal.status}`,+ outcome: 'failed',+ };+ }++ const pendingDecision = graph.decisions.find((decision) => decision.status === 'pending');+ if (pendingDecision) {+ return {+ ...base,+ branch: 'pending_decision',+ focusNodeId: pendingDecision.nodeId,+ message: pendingDecision.question,+ outcome: 'waiting_human',+ };+ }++ if (!chosen) return decideWithoutFrontier(graph, candidates);++ if (!chosen.taskId) {+ return {+ ...base,+ branch: 'create_task',+ message: `Work "${chosen.title}" has no responsible task yet`,+ outcome: 'advanced',+ };+ }++ if (!frontierTask) {+ return {+ ...base,+ branch: 'missing_task',+ message: 'Responsible task is missing',+ outcome: 'failed',+ };+ }++ return decideForTask(base, frontierTask, budget, graph);+};++const decideWithoutFrontier = (+ graph: GoalGraphSnapshot,+ candidates: FrontierCandidate[],+): GoalMove => {+ const base = { candidates };+ const taskNodes = graph.nodes.filter((node) => node.kind === 'task');+ const allWorkTerminal =+ taskNodes.length > 0 && taskNodes.every((node) => TERMINAL_NODE_STATUSES.has(node.status));++ if (!allWorkTerminal) {+ // Nothing here moves without a person: either there is no Work at all, or+ // every remaining Work is blocked and nothing is running to unblock it.+ return {+ ...base,+ branch: 'no_frontier',+ message:+ taskNodes.length === 0+ ? 'No work frontier exists; add a work node'+ : 'No work node is ready; resolve its dependencies first',+ outcome: 'no_progress',+ };+ }++ const acceptanceWork = taskNodes.find((node) => node.title === GOAL_ACCEPTANCE_TASK_TITLE);++ if (graph.goal.requirement && !acceptanceWork) {+ return {+ ...base,+ branch: 'terminal_acceptance',+ message: 'Every Work finished; the Goal-level acceptance contract is next',+ outcome: 'advanced',+ };+ }+ if (graph.goal.requirement && acceptanceWork?.status !== 'resolved') {+ return {+ ...base,+ branch: 'terminal_acceptance',+ focusNodeId: acceptanceWork?.id,+ message: 'Goal-level acceptance did not pass',+ outcome: 'no_progress',+ };+ }+ return {+ ...base,+ branch: 'terminal_acceptance',+ message: 'Goal-level acceptance passed',+ outcome: 'achieved',+ };+};++const decideForTask = (+ base: { candidates: FrontierCandidate[]; chosenNodeId?: string },+ task: TaskItem,+ budget: GoalBudgetState | undefined,+ graph: GoalGraphSnapshot,+): GoalMove => {+ if (task.status === 'completed') {+ return {+ ...base,+ branch: 'consume_completed',+ message: `Task ${task.identifier} completed`,+ outcome: 'advanced',+ };+ }++ if (+ task.status === 'failed' ||+ task.status === 'canceled' ||+ (task.status === 'paused' && task.error)+ ) {+ if (task.status === 'paused' && task.error === LEASE_EXPIRED_ERROR) {+ return {+ ...base,+ branch: 'recover_lease',+ message: `Task ${task.identifier} outlived its operation lease`,+ outcome: 'waiting_external',+ };+ }+ if (task.status === 'paused' && task.error === VERIFICATION_FAILED_ERROR) {+ return {+ ...base,+ branch: 'recover_verification',+ message: `Task ${task.identifier} did not pass verification`,+ outcome: 'waiting_external',+ };+ }+ return {+ ...base,+ branch: 'failure_decision',+ message: task.error ?? `Task ${task.status}`,+ outcome: 'waiting_human',+ };+ }++ if (task.status === 'paused') {+ return {+ ...base,+ branch: 'task_paused',+ message: `Task ${task.identifier} is paused`,+ outcome: 'waiting_human',+ };+ }++ if (task.status === 'running' || task.status === 'scheduled') {+ return {+ ...base,+ branch: 'task_running',+ message: `Task ${task.identifier} is ${task.status}`,+ outcome: 'waiting_external',+ };+ }++ if (budget?.roundLimitReached || budget?.costLimitReached) {+ return {+ ...base,+ branch: 'budget_exhausted',+ message: budget.roundLimitReached+ ? `Round budget reached (${budget.runs}/${graph.goal.maxRounds})`+ : `Cost budget reached ($${budget.totalCost.toFixed(4)}/$${graph.goal.maxTotalCost})`,+ outcome: 'no_progress',+ };+ }++ return {+ ...base,+ branch: 'dispatch_task',+ message: `Task ${task.identifier} is ready to run`,+ outcome: 'waiting_external',+ };+};diff --git a/apps/server/src/services/goal/goalTraceRecorder.ts b/apps/server/src/services/goal/goalTraceRecorder.tsnew file mode 100644index 00000000000..720173b5a43--- /dev/null+++ b/apps/server/src/services/goal/goalTraceRecorder.ts@@ -0,0 +1,168 @@+import {+ appendAdvanceToPartial,+ buildGoalTraceRollup,+ finalizeGoalTrace,+ type GoalAdvanceTrigger,+ type GoalTrajectory,+ type IGoalTraceStore,+ type RecordTickInput,+} from '@lobechat/agent-tracing';+import debug from 'debug';+import { sql } from 'drizzle-orm';++import { GoalTraceModel } from '@/database/models/goalTrace';+import type { LobeChatDatabase } from '@/database/type';+import { buildGoalTraceKey } from '@/server/modules/GoalTracing';++import type { GoalTickObservation } from './traceObservation';+import { createDefaultGoalTraceStore } from './traceStore';++const log = debug('lobe-server:goal-trace');++/**+ * Advisory-lock namespace, so a goal's trace lock cannot collide with another+ * feature's. `0x676f_616c` is ASCII `goal`, and fits int4.+ */+const GOAL_TRACE_LOCK_NAMESPACE = 0x67_6f_61_6c;++/**+ * Collects one advance's ticks and writes them into the goal's trajectory.+ *+ * Recording is best-effort by construction: a goal that cannot be traced must+ * still advance. Every write is caught here so a storage outage degrades+ * observability instead of stalling long-horizon goals — the same posture the+ * operation snapshot recorder takes.+ */+export class GoalAdvanceRecorder {+ private readonly startedAt = Date.now();+ private readonly ticks: RecordTickInput[] = [];+ private readonly operationIds = new Set<string>();++ constructor(+ private readonly db: LobeChatDatabase,+ private readonly goalId: string,+ private readonly trigger: GoalAdvanceTrigger,+ private readonly store: IGoalTraceStore | null = createDefaultGoalTraceStore(),+ ) {}++ get enabled(): boolean {+ return this.store !== null;+ }++ /** Pass to `GoalService.tick`; undefined when tracing is off, so tick skips the work. */+ get onDecision(): ((observation: GoalTickObservation) => void) | undefined {+ if (!this.store) return undefined;+ return (observation) => {+ const { effects, graphState, ...rest } = observation;+ for (const effect of effects) {+ if (effect.operationId) this.operationIds.add(effect.operationId);+ }+ this.ticks.push({ ...rest, effects, graphState });+ };+ }++ async flush(error?: unknown): Promise<void> {+ if (!this.store || this.ticks.length === 0) return;++ try {+ await this.serializedPerGoal(async (tx) => {+ const trajectory = await appendAdvanceToPartial(this.store!, this.goalId, {+ childOperationIds: [...this.operationIds],+ error: error+ ? { message: error instanceof Error ? error.message : String(error), type: 'advance' }+ : undefined,+ startedAt: this.startedAt,+ ticks: this.ticks,+ trigger: this.trigger,+ });+ if (trajectory) await this.writeObservationRow(trajectory, tx);+ });+ } catch (writeError) {+ log('failed to record advance for %s: %O', this.goalId, writeError);+ }+ }++ /**+ * Run the trajectory write under a per-goal advisory lock.+ *+ * Appending is read-modify-write on one object, and advances for the same+ * goal genuinely overlap — an event hook, a manual nudge and the sweep can+ * all be in flight at once, which the coordinator handles everywhere else by+ * claiming rows. Without serialization two advances read the same partial,+ * pick the same `seq`, and the second write silently erases the first; the+ * stale rollup then overwrites the row and `advancesTotal` goes backwards.+ *+ * The lock is transaction-scoped, so it releases on commit or on any failure,+ * and it is held across the object write — which is the point: reading the+ * partial and writing it back have to be one critical section. That keeps a+ * transaction open for one storage round trip, which is the cost of the+ * trajectory being complete.+ */+ private async serializedPerGoal<T>(run: (tx: LobeChatDatabase) => Promise<T>): Promise<T> {+ return this.db.transaction(async (tx) => {+ await tx.execute(+ sql`SELECT pg_advisory_xact_lock(${GOAL_TRACE_LOCK_NAMESPACE}, hashtext(${this.goalId}))`,+ );+ return run(tx as unknown as LobeChatDatabase);+ });+ }++ /**+ * Re-derive the observation row from the whole trajectory on every advance.+ *+ * Rewriting rather than incrementing is what makes it exact however often it+ * runs — an advance can be retried by the queue, and an additive counter+ * would drift. It also keeps the row queryable while the goal is still+ * running, which is when a stalling goal is worth finding.+ */+ private async writeObservationRow(+ trajectory: GoalTrajectory,+ tx: LobeChatDatabase = this.db,+ ): Promise<void> {+ const rollup = buildGoalTraceRollup(trajectory);++ await new GoalTraceModel(tx).upsert({+ advancesByOutcome: rollup.advancesByOutcome,+ advancesByTrigger: rollup.advancesByTrigger,+ advancesTotal: rollup.advancesTotal,+ completedAt: rollup.completedAt ? new Date(rollup.completedAt) : null,+ finalStatus: rollup.completionReason ?? null,+ findingsTotal: rollup.findingsTotal,+ gatesOpened: rollup.gatesOpened,+ gatesResolved: rollup.gatesResolved,+ goalId: this.goalId,+ humanWaitingMs: rollup.humanWaitingMs,+ nodesTotal: rollup.nodesTotal,+ startedAt: new Date(rollup.startedAt),+ ticksByBranch: rollup.ticksByBranch,+ ticksTotal: rollup.ticksTotal,+ traceS3Key: buildGoalTraceKey(this.goalId),+ workOperations: rollup.operationsTotal,+ // Columns kept as shipped. The node kind is now `task`, but renaming+ // three columns on a live table buys nothing the reporting names above+ // do not already give — so the mapping lives here, in one place.+ workResolved: rollup.tasksCompleted,+ workRetired: rollup.tasksRetired,+ });+ }++ /**+ * Close the trajectory once the goal itself is terminal. A goal that is only+ * parked keeps its partial, which readers still serve — an unfinished+ * long-horizon goal is the normal thing to inspect.+ */+ async finalize(completionReason: string): Promise<void> {+ if (!this.store) return;+ try {+ await this.serializedPerGoal(async (tx) => {+ const trajectory = await finalizeGoalTrace(this.store!, this.goalId, { completionReason });+ if (trajectory) await this.writeObservationRow(trajectory, tx);+ });+ } catch (error) {+ log('failed to finalize trajectory for %s: %O', this.goalId, error);+ }+ }+}++/** Goal statuses that end a trajectory. `paused` is a stop, not an end. */+export const TERMINAL_GOAL_STATUSES = new Set(['achieved', 'failed', 'canceled']);diff --git a/apps/server/src/services/goal/index.test.ts b/apps/server/src/services/goal/index.test.tsindex 0c0de8e6ac4..60a4b92e1ae 100644--- a/apps/server/src/services/goal/index.test.ts+++ b/apps/server/src/services/goal/index.test.ts@@ -29,6 +29,7 @@ import { AgentRuntimeCoordinator } from '@/server/modules/AgentRuntime/AgentRuntimport { TaskService } from '../task';import { TaskRunnerService } from '../taskRunner';import { GoalService } from './index';+import type { GoalTickObservation } from './traceObservation';const serverDB: LobeChatDatabase = await getTestDB();const userId = 'goal-service-test-user';@@ -66,7 +67,7 @@ describe('GoalService', () => {expect(results.filter((result) => result.outcome === 'advanced')).toHaveLength(1);expect(taskRows).toHaveLength(1);- expect(current.nodes.find((node) => node.kind === 'work')?.taskId).toBe(taskRows[0].id);+ expect(current.nodes.find((node) => node.kind === 'task')?.taskId).toBe(taskRows[0].id);expect(current.workVersions).toHaveLength(1);});@@ -97,7 +98,7 @@ describe('GoalService', () => {const service = new GoalService(serverDB, userId);const taskModel = new TaskModel(serverDB, userId);const graph = await service.create({- config: { recovery: { maxAttemptsPerWork: 3 } },+ config: { recovery: { maxAttemptsPerTask: 3 } },title: 'Raced recovery',work: ['Retry me once'],});@@ -277,7 +278,7 @@ describe('GoalService', () => {await service.tick(graph.goal.id);const { events, nodes } = await service.graph(graph.goal.id);- const work = nodes.find((node) => node.kind === 'work')!;+ const work = nodes.find((node) => node.kind === 'task')!;const actorsFor = (eventType: string, entityId: string) =>events.filter((event) => event.eventType === eventType && event.entityId === entityId)@@ -360,7 +361,7 @@ describe('GoalService', () => {expect(created.taskId).toBeDefined();const waitingGraph = await service.graph(graph.goal.id);- expect(waitingGraph.nodes.find((node) => node.kind === 'work')).toMatchObject({+ expect(waitingGraph.nodes.find((node) => node.kind === 'task')).toMatchObject({status: 'active',taskId: created.taskId,});@@ -435,7 +436,7 @@ describe('GoalService', () => {expect(current.goal.status).not.toBe('achieved');expect(current.nodes).toContainEqual(expect.objectContaining({- kind: 'work',+ kind: 'task',status: 'proposed',title: 'Complete full Goal acceptance',}),@@ -488,6 +489,42 @@ describe('GoalService', () => {expect(achieved.outcome).toBe('achieved');});+ it('reports the effects a tick actually produced, not just its outcome', async () => {+ // The rollup counts gates and findings from these effects, so a branch that+ // forgets to report one reads as "no human was ever involved" — silently,+ // and only in the trace. Driving the real path is the only thing that+ // catches it; a synthetic observation always agrees with itself.+ const service = new GoalService(serverDB, userId);+ const taskModel = new TaskModel(serverDB, userId);+ const graph = await service.create({ title: 'Effect reporting', work: ['Risky task'] });++ const created = await service.tick(graph.goal.id);+ await taskModel.updateStatus(created.taskId!, 'paused', { error: 'Verifier rejected output' });++ const observed: GoalTickObservation[] = [];+ const gated = await service.tick(graph.goal.id, {+ onDecision: (observation) => observed.push(observation),+ });++ expect(gated.outcome).toBe('waiting_human');+ expect(observed.at(-1)!.effects).toContainEqual(+ expect.objectContaining({ detail: 'Verifier rejected output', type: 'opened_decision' }),+ );++ // And the other half: a completed task folds into a finding, which is what+ // `findingsTotal` counts.+ const decision = (await service.graph(graph.goal.id)).decisions[0];+ await service.decide(graph.goal.id, decision.id, 'retry');+ await taskModel.updateStatus(created.taskId!, 'completed');++ const consumed: GoalTickObservation[] = [];+ await service.tick(graph.goal.id, { onDecision: (o) => consumed.push(o) });++ expect(consumed.at(-1)!.effects).toContainEqual(+ expect.objectContaining({ detail: 'finding', type: 'created_node' }),+ );+ });+it('automatically retries failed Work verification within policy budget', async () => {const runSpy = vi.spyOn(TaskRunnerService.prototype, 'runTask').mockResolvedValue({agentId: 'agent-recovery',@@ -507,7 +544,7 @@ describe('GoalService', () => {const service = new GoalService(serverDB, userId);const taskModel = new TaskModel(serverDB, userId);const graph = await service.create({- config: { recovery: { maxAttemptsPerWork: 3, maxStepsPerRun: 500 } },+ config: { recovery: { maxAttemptsPerTask: 3, maxStepsPerRun: 500 } },title: 'Recover BW 150 research',work: ['Verify Micron BW 150 suppliers'],});@@ -558,7 +595,7 @@ describe('GoalService', () => {const taskModel = new TaskModel(serverDB, userId);const graph = await service.create({config: {- recovery: { maxAttemptsPerWork: 3, operationLeaseTimeoutMs: 60_000 },+ recovery: { maxAttemptsPerTask: 3, operationLeaseTimeoutMs: 60_000 },},title: 'Recover interrupted work',work: ['Run a durable experiment'],@@ -600,7 +637,7 @@ describe('GoalService', () => {const service = new GoalService(serverDB, userId);const taskModel = new TaskModel(serverDB, userId);const graph = await service.create({- config: { recovery: { maxAttemptsPerWork: 3, operationLeaseTimeoutMs: 60_000 } },+ config: { recovery: { maxAttemptsPerTask: 3, operationLeaseTimeoutMs: 60_000 } },maxTotalCost: 0.5,title: 'Respect abandoned Work cost',work: ['Run an expensive experiment'],@@ -704,7 +741,7 @@ describe('GoalService', () => {const service = new GoalService(serverDB, userId);const taskModel = new TaskModel(serverDB, userId);const graph = await service.create({- config: { recovery: { maxAttemptsPerWork: 3 } },+ config: { recovery: { maxAttemptsPerTask: 3 } },title: 'Resume abandoned recovery',work: ['Run a durable experiment'],});@@ -727,7 +764,7 @@ describe('GoalService', () => {const service = new GoalService(serverDB, userId);const taskModel = new TaskModel(serverDB, userId);const graph = await service.create({- config: { recovery: { maxAttemptsPerWork: 1 } },+ config: { recovery: { maxAttemptsPerTask: 1 } },title: 'Bounded recovery',work: ['Verify Micron BW 150 suppliers'],});@@ -747,7 +784,7 @@ describe('GoalService', () => {const service = new GoalService(serverDB, userId);const taskModel = new TaskModel(serverDB, userId);const graph = await service.create({- config: { recovery: { maxAttemptsPerWork: 1 } },+ config: { recovery: { maxAttemptsPerTask: 1 } },requirement: 'Return three verified supplier quotes.',title: 'Bounded terminal acceptance',work: ['Complete full Goal acceptance'],@@ -787,12 +824,12 @@ describe('GoalService', () => {const service = new GoalService(serverDB, userId);const graph = await service.create({ title: 'Dependency-aware goal' });const prerequisite = await service.addNode(graph.goal.id, {- kind: 'work',+ kind: 'task',priority: 0,title: 'Collect evidence',});const dependent = await service.addNode(graph.goal.id, {- kind: 'work',+ kind: 'task',priority: 10,title: 'Train from evidence',});diff --git a/apps/server/src/services/goal/index.ts b/apps/server/src/services/goal/index.tsindex 578fde69b9d..852c727c675 100644--- a/apps/server/src/services/goal/index.ts+++ b/apps/server/src/services/goal/index.ts@@ -1,11 +1,14 @@+import type { GoalAdvanceEffect } from '@lobechat/agent-tracing';import { GOAL_COORDINATOR_ACTOR_ID } from '@lobechat/const/goal';import type {GoalConfig,GoalEdgeKind,+ GoalGraphNode,GoalGraphSnapshot,GoalItem,GoalNodeKind,GoalNodeStatus,+ GoalStatus,GoalTickResult,TaskItem,TaskTopicHandoff,@@ -26,12 +29,24 @@ import { AgentRuntimeCoordinator } from '@/server/modules/AgentRuntime/AgentRuntimport { TaskService } from '../task';import { TaskRunnerService } from '../taskRunner';import { AcceptanceService } from '../verify/acceptanceService';-import { resolveOperationLeaseTimeout, resolveWorkMaxSteps } from './recoveryPolicy';-import { WorkRecoveryCoordinator } from './workRecoveryCoordinator';+import {+ decideNextMove,+ GOAL_ACCEPTANCE_TASK_TITLE,+ type GoalMove,+ needsBudget,+ selectFrontier,+} from './decideNextMove';+import { resolveOperationLeaseTimeout, resolveTaskMaxSteps } from './recoveryPolicy';+import { TaskRecoveryCoordinator } from './taskRecoveryCoordinator';+import {+ type GoalTickOptions,+ toBudgetState,+ toFrontierTaskState,+ toTraceGraphState,+} from './traceObservation';-const WORK_NODE_CLAIM_TTL_MS = 5 * 60 * 1000;+const TASK_NODE_CLAIM_TTL_MS = 5 * 60 * 1000;const TASK_DESCRIPTION_MAX_LENGTH = 255;-const GOAL_ACCEPTANCE_WORK_TITLE = 'Complete full Goal acceptance';export interface CreateGoalWorkInput {description?: string;@@ -157,7 +172,7 @@ export class GoalService {const work = await authorGraph.createNode(goal.id, {createdByAgentId: input.createdByAgentId,description,- kind: 'work',+ kind: 'task',title,});if (!work) throw new Error('Failed to seed goal work');@@ -172,6 +187,10 @@ export class GoalService {graph = async (goalId: string) => this.requireGraph(goalId);+ /** Current lifecycle status, without paying for the whole graph. */+ status = async (goalId: string): Promise<GoalStatus | undefined> =>+ (await this.goalModel.findById(goalId))?.status;+addNode = async (goalId: string, input: CreateGoalNodeInput) => {const node = await this.graphModel.createNode(goalId, input);if (!node) throw new TRPCError({ code: 'NOT_FOUND', message: 'Goal not found' });@@ -308,334 +327,412 @@ export class GoalService {(edge) => edge.targetNodeId === decision.nodeId && edge.kind === 'leads_to',);const source = incoming && graph.nodes.find((node) => node.id === incoming.sourceNodeId);- if (source?.kind === 'work') {+ if (source?.kind === 'task') {if (optionId === 'retry' && source.taskId) {await this.taskModel.updateStatus(source.taskId, 'backlog', { error: null });await this.graphModel.updateNodeStatus(goalId, source.id, 'active', resolution);} else if (optionId === 'retire' ||- (optionId === 'fail' && source.title === GOAL_ACCEPTANCE_WORK_TITLE)+ (optionId === 'fail' && source.title === GOAL_ACCEPTANCE_TASK_TITLE)) {await this.graphModel.updateNodeStatus(goalId, source.id, 'retired', resolution);}}const terminalAcceptanceFailed =- source?.title === GOAL_ACCEPTANCE_WORK_TITLE &&+ source?.title === GOAL_ACCEPTANCE_TASK_TITLE &&(optionId === 'retire' || optionId === 'fail');await this.goalModel.updateStatus(goalId, terminalAcceptanceFailed ? 'failed' : 'running');return resolved;};- tick = async (goalId: string): Promise<GoalTickResult> => {+ /**+ * Advance the goal by one coordinator step.+ *+ * Choosing and doing are separate: `decideNextMove` is a pure function of the+ * graph, the responsible task and the budget, and everything under the switch+ * only carries that choice out. `onDecision` then receives both what the+ * coordinator read and what it did — the decision surface a goal trajectory+ * records. It travels on that side channel rather than on `GoalTickResult`+ * because the result crosses tRPC to the client and the graph payload is+ * large, the same reason the context engine snapshot stays off the agent+ * runtime's event array.+ */+ tick = async (goalId: string, options?: GoalTickOptions): Promise<GoalTickResult> => {+ const at = Date.now();const graph = await this.requireGraph(goalId);- if (graph.goal.status === 'paused') {- return { goalId, message: 'Goal is paused', outcome: 'no_progress' };- }- if (graph.goal.status === 'achieved') {- return { goalId, message: 'Goal is already achieved', outcome: 'achieved' };- }- if (graph.goal.status === 'failed' || graph.goal.status === 'canceled') {- return { goalId, message: `Goal is ${graph.goal.status}`, outcome: 'failed' };- }+ const frontier = selectFrontier(graph);+ const chosen = frontier.chosen;- const pendingDecision = graph.decisions.find((decision) => decision.status === 'pending');- if (pendingDecision) {- await this.goalModel.updateStatus(goalId, 'review');- return {- goalId,- message: pendingDecision.question,- nodeId: pendingDecision.nodeId,- outcome: 'waiting_human',- };- }+ const frontierTask = chosen?.taskId+ ? ((await this.taskModel.findById(chosen.taskId)) ?? null)+ : undefined;+ // Only the branch that could start a run reads the budget, so a goal that is+ // merely waiting on running Work does not pay for the query on every sweep.+ const budget = needsBudget(frontierTask)+ ? toBudgetState(graph.goal, await this.evaluateBudget(graph.goal, graph))+ : undefined;- const resolvedNodeIds = new Set(- graph.nodes.filter((node) => node.status === 'resolved').map((node) => node.id),- );- const frontier = graph.nodes- .filter((node) => {- if (node.kind !== 'work' || ['resolved', 'rejected', 'retired'].includes(node.status)) {- return false;- }+ const move = decideNextMove({ budget, frontier, frontierTask, graph });+ const effects: GoalAdvanceEffect[] = [];- const dependencies = graph.edges.filter(- (edge) => edge.kind === 'depends_on' && edge.sourceNodeId === node.id,- );- return dependencies.every((edge) => resolvedNodeIds.has(edge.targetNodeId));- })- .sort((a, b) => b.priority - a.priority || a.createdAt.getTime() - b.createdAt.getTime())[0];-- if (!frontier) {- const workNodes = graph.nodes.filter((node) => node.kind === 'work');- const allWorkTerminal =- workNodes.length > 0 &&- workNodes.every((node) => ['resolved', 'rejected', 'retired'].includes(node.status));- if (allWorkTerminal) {- const goalAcceptanceWork = workNodes.find(- (node) => node.title === GOAL_ACCEPTANCE_WORK_TITLE,+ const observe = (result: GoalTickResult): GoalTickResult => {+ options?.onDecision?.({+ at,+ branch: move.branch,+ budget,+ candidates: move.candidates,+ chosenNodeId: move.chosenNodeId,+ effects,+ frontierTask: frontierTask ? toFrontierTaskState(frontierTask) : undefined,+ graphState: toTraceGraphState(graph),+ message: result.message,+ outcome: result.outcome,+ taskId: result.taskId,+ });+ return result;+ };++ switch (move.branch) {+ case 'goal_paused':+ case 'goal_terminal': {+ return observe({ goalId, message: move.message, outcome: move.outcome });+ }++ case 'pending_decision': {+ await this.goalModel.updateStatus(goalId, 'review');+ effects.push({ type: 'goal_status', detail: 'review' });+ return observe({+ goalId,+ message: move.message,+ nodeId: move.focusNodeId,+ outcome: move.outcome,+ });+ }++ case 'terminal_acceptance': {+ return observe(await this.settleTerminalAcceptance(graph, move, effects));+ }++ case 'no_frontier': {+ // Say so on the row instead of leaving a goal that reads as `running`+ // while it cannot run — and, just as importantly, take it out of the+ // sweep's window. A `running` goal that always reports `no_progress` is+ // picked by every scan forever, and enough of them starve every other+ // stalled goal out of the newest-first limit.+ await this.goalModel.updateStatus(goalId, 'paused');+ effects.push({ type: 'goal_status', detail: 'paused' });+ return observe({ goalId, message: move.message, outcome: move.outcome });+ }++ case 'create_task': {+ return observe(await this.createResponsibleTask(graph, chosen!, effects));+ }++ case 'missing_task': {+ await this.coordinatorGraph.updateNodeStatus(+ goalId,+ chosen!.id,+ 'waiting',+ 'Responsible task is missing',);- if (graph.goal.requirement && !goalAcceptanceWork) {- const result = await this.coordinatorGraph.createNodeOnce(goalId, {- description: [- `Complete and prove the overall Goal acceptance requirement: ${graph.goal.requirement}`,- 'Inspect and reuse existing Goal findings, artifacts, metrics, and command results as the primary evidence. Do not repeat expensive or destructive work when the existing evidence is sufficient and still auditable.',- 'Explicitly close every remaining acceptance gap instead of treating completed upstream Work as proof that the whole Goal is achieved. Run only the missing or stale checks needed to close those gaps.',- 'Return one auditable final delivery with evidence for every requirement. If a requirement cannot be satisfied, state the exact gap and the minimum next action; do not claim the Goal is complete.',- ].join('\n\n'),- kind: 'work',- priority: -1,- title: GOAL_ACCEPTANCE_WORK_TITLE,- });- if (!result) {- return {+ effects.push({ nodeId: chosen!.id, type: 'node_status', detail: 'waiting' });+ return observe({+ goalId,+ message: move.message,+ nodeId: chosen!.id,+ outcome: move.outcome,+ });+ }++ default: {+ // Everything from here on has a live responsible task.+ const task = frontierTask!;+ await this.ensureTaskWorkVersion(graph.goal.id, chosen!.id, task.id);++ switch (move.branch) {+ case 'consume_completed': {+ return observe(await this.consumeCompletedTask(graph, chosen!.id, task.id, effects));+ }++ case 'recover_lease': {+ return observe(+ await this.resumeAbandonedTaskRecovery(graph, chosen!.id, task, effects),+ );+ }++ case 'recover_verification': {+ return observe(await this.recoverAfterVerification(graph, chosen!.id, task, effects));+ }++ case 'failure_decision': {+ return observe(+ await this.openFailureDecision(graph, chosen!.id, task.id, move.message, effects),+ );+ }++ case 'task_paused': {+ return observe({goalId,- message: 'Could not create the Goal-level acceptance Work',- outcome: 'no_progress',- };+ message: move.message,+ nodeId: chosen!.id,+ outcome: move.outcome,+ taskId: task.id,+ });}- if (result.created) {- const problem = graph.nodes.find((node) => node.kind === 'problem');- if (problem) {- await this.coordinatorGraph.createEdge(- goalId,- problem.id,- result.node.id,- 'decomposes',- );++ case 'task_running': {+ if (task.status === 'running') {+ const recovered = await this.recoverAbandonedTask(graph, chosen!.id, task, effects);+ if (recovered) return observe(recovered);}+ return observe({+ goalId,+ message: move.message,+ nodeId: chosen!.id,+ outcome: move.outcome,+ taskId: task.id,+ });+ }++ case 'budget_exhausted': {+ await this.goalModel.updateStatus(goalId, 'paused');+ effects.push({ type: 'goal_status', detail: 'paused' });+ return observe({+ goalId,+ message: move.message,+ nodeId: chosen!.id,+ outcome: move.outcome,+ taskId: task.id,+ });+ }++ default: {+ return observe(await this.dispatchWork(graph, chosen!.id, task, effects));}- return {- goalId,- message: result.created- ? 'Created Goal-level acceptance Work for the remaining contract'- : 'Goal-level acceptance Work was created by another coordinator',- nodeId: result.node.id,- outcome: 'advanced',- };- }- if (graph.goal.requirement && goalAcceptanceWork?.status !== 'resolved') {- return {- goalId,- message: 'Goal-level acceptance did not pass',- nodeId: goalAcceptanceWork?.id,- outcome: 'no_progress',- };}- await this.goalModel.updateStatus(goalId, 'achieved');- return { goalId, message: 'Goal-level acceptance passed', outcome: 'achieved' };}- // Nothing here moves without a person: either there is no Work at all, or- // every remaining Work is blocked and nothing is running to unblock it.- // Say so on the row instead of leaving a goal that reads as `running`- // while it cannot run — and, just as importantly, take it out of the- // sweep's window. A `running` goal that always reports `no_progress` is- // picked by every scan forever, and enough of them starve every other- // stalled goal out of the newest-first limit.- await this.goalModel.updateStatus(goalId, 'paused');+ }+ };++ /**+ * Create the Goal-level acceptance Work, or read the verdict it already+ * reached. Only runs once every other Work is terminal.+ */+ private settleTerminalAcceptance = async (+ graph: GoalGraphSnapshot,+ move: GoalMove,+ effects: GoalAdvanceEffect[],+ ): Promise<GoalTickResult> => {+ const goalId = graph.goal.id;++ if (move.outcome === 'achieved') {+ await this.goalModel.updateStatus(goalId, 'achieved');+ effects.push({ type: 'goal_status', detail: 'achieved' });+ return { goalId, message: move.message, outcome: 'achieved' };+ }++ if (move.outcome === 'no_progress') {+ return { goalId, message: move.message, nodeId: move.focusNodeId, outcome: 'no_progress' };+ }++ const result = await this.coordinatorGraph.createNodeOnce(goalId, {+ description: [+ `Complete and prove the overall Goal acceptance requirement: ${graph.goal.requirement}`,+ 'Inspect and reuse existing Goal findings, artifacts, metrics, and command results as the primary evidence. Do not repeat expensive or destructive work when the existing evidence is sufficient and still auditable.',+ 'Explicitly close every remaining acceptance gap instead of treating completed upstream Work as proof that the whole Goal is achieved. Run only the missing or stale checks needed to close those gaps.',+ 'Return one auditable final delivery with evidence for every requirement. If a requirement cannot be satisfied, state the exact gap and the minimum next action; do not claim the Goal is complete.',+ ].join('\n\n'),+ kind: 'task',+ priority: -1,+ title: GOAL_ACCEPTANCE_TASK_TITLE,+ });+ if (!result) {return {goalId,- message:- workNodes.length === 0- ? 'No work frontier exists; add a work node'- : 'No work node is ready; resolve its dependencies first',+ message: 'Could not create the Goal-level acceptance Work',outcome: 'no_progress',};}+ if (result.created) {+ effects.push({ nodeId: result.node.id, type: 'created_node', detail: 'terminal acceptance' });+ const problem = graph.nodes.find((node) => node.kind === 'problem');+ if (problem) {+ await this.coordinatorGraph.createEdge(goalId, problem.id, result.node.id, 'decomposes');+ }+ }+ return {+ goalId,+ message: result.created+ ? 'Created Goal-level acceptance Work for the remaining contract'+ : 'Goal-level acceptance Work was created by another coordinator',+ nodeId: result.node.id,+ outcome: 'advanced',+ };+ };- if (!frontier.taskId) {- const claim = await this.coordinatorGraph.claimWorkNode(- goalId,- frontier.id,- new Date(Date.now() - WORK_NODE_CLAIM_TTL_MS),+ /** Claim the chosen Work and give it a responsible task plus its acceptance contract. */+ private createResponsibleTask = async (+ graph: GoalGraphSnapshot,+ frontier: GoalGraphNode,+ effects: GoalAdvanceEffect[],+ ): Promise<GoalTickResult> => {+ const goalId = graph.goal.id;+ const claim = await this.coordinatorGraph.claimTaskNode(+ goalId,+ frontier.id,+ new Date(Date.now() - TASK_NODE_CLAIM_TTL_MS),+ );+ if (!claim) {+ const current = (await this.requireGraph(goalId)).nodes.find(+ (node) => node.id === frontier.id,);- if (!claim) {- const current = (await this.requireGraph(goalId)).nodes.find(- (node) => node.id === frontier.id,- );+ return {+ goalId,+ message: current?.taskId+ ? 'Responsible task was created by another coordinator'+ : 'Work node is being claimed by another coordinator',+ nodeId: frontier.id,+ outcome: 'waiting_external',+ taskId: current?.taskId ?? undefined,+ };+ }++ let acceptanceId: string | undefined;+ let task: TaskItem | undefined;+ try {+ const description = frontier.description ?? frontier.title;+ task = await this.taskService.createTask({+ assigneeAgentId: graph.goal.agentId ?? undefined,+ config: { checkpoint: { topic: { after: false } } },+ description: description?.slice(0, TASK_DESCRIPTION_MAX_LENGTH),+ instruction: this.buildTaskInstruction(graph, frontier.title, frontier.description),+ name: frontier.title,+ projectId: graph.goal.projectId ?? undefined,+ });+ const acceptance = await this.acceptanceService.ensureForSubject('task', task.id, {+ config: { enabled: true },+ requirement: this.buildTaskAcceptanceRequirement(+ graph,+ frontier.title,+ frontier.description,+ ),+ });+ acceptanceId = acceptance.id;+ const bound = await this.coordinatorGraph.bindTask(goalId, frontier.id, task.id);+ if (!bound) {+ await this.acceptanceService.acceptanceModel.delete(acceptance.id);+ await this.taskModel.delete(task.id);return {goalId,- message: current?.taskId- ? 'Responsible task was created by another coordinator'- : 'Work node is being claimed by another coordinator',+ message: 'Responsible task was created by another coordinator',nodeId: frontier.id,outcome: 'waiting_external',- taskId: current?.taskId ?? undefined,};}-- let acceptanceId: string | undefined;- let task: TaskItem | undefined;- try {- const description = frontier.description ?? frontier.title;- task = await this.taskService.createTask({- assigneeAgentId: graph.goal.agentId ?? undefined,- config: { checkpoint: { topic: { after: false } } },- description: description?.slice(0, TASK_DESCRIPTION_MAX_LENGTH),- instruction: this.buildWorkInstruction(graph, frontier.title, frontier.description),- name: frontier.title,- projectId: graph.goal.projectId ?? undefined,- });- const acceptance = await this.acceptanceService.ensureForSubject('task', task.id, {- config: { enabled: true },- requirement: this.buildWorkAcceptanceRequirement(- graph,- frontier.title,- frontier.description,- ),- });- acceptanceId = acceptance.id;- const bound = await this.coordinatorGraph.bindTask(goalId, frontier.id, task.id);- if (!bound) {- await this.acceptanceService.acceptanceModel.delete(acceptance.id);- await this.taskModel.delete(task.id);- return {- goalId,- message: 'Responsible task was created by another coordinator',- nodeId: frontier.id,- outcome: 'waiting_external',- };- }- } catch (error) {- if (acceptanceId) {- await this.acceptanceService.acceptanceModel.delete(acceptanceId).catch(() => {});- }- if (task) {- await this.taskModel.delete(task.id).catch((cleanupError) => {- console.error('[GoalService.tick] failed to delete unbound task:', cleanupError);- });- }- await this.coordinatorGraph.updateNodeStatus(goalId, frontier.id, 'proposed');- throw error;+ } catch (error) {+ if (acceptanceId) {+ await this.acceptanceService.acceptanceModel.delete(acceptanceId).catch(() => {});}- const work = await this.workModel.registerTask({- changeType: 'created',- taskId: task.id,- toolIdentifier: 'goal-coordinator',- toolName: 'createResponsibleTask',- });- if (work?.currentVersionId) {- await this.coordinatorGraph.attachWorkVersion(- goalId,- frontier.id,- work.currentVersionId,- 'produced',- );+ if (task) {+ await this.taskModel.delete(task.id).catch((cleanupError) => {+ console.error('[GoalService.tick] failed to delete unbound task:', cleanupError);+ });}- await this.goalModel.updateStatus(goalId, 'running');- return {- goalId,- message: `Created responsible task ${task.identifier}`,- nodeId: frontier.id,- outcome: 'advanced',- taskId: task.id,- };+ await this.coordinatorGraph.updateNodeStatus(goalId, frontier.id, 'proposed');+ throw error;}- const task = await this.taskModel.findById(frontier.taskId);- if (!task) {- await this.coordinatorGraph.updateNodeStatus(- goalId,- frontier.id,- 'waiting',- 'Responsible task is missing',- );- return {+ effects.push({ nodeId: frontier.id, targetId: task.id, type: 'created_task' });+ const work = await this.workModel.registerTask({+ changeType: 'created',+ taskId: task.id,+ toolIdentifier: 'goal-coordinator',+ toolName: 'createResponsibleTask',+ });+ if (work?.currentVersionId) {+ await this.coordinatorGraph.attachWorkVersion(goalId,- message: 'Responsible task is missing',- nodeId: frontier.id,- outcome: 'failed',- };- }- await this.ensureTaskWorkVersion(graph.goal.id, frontier.id, task.id);-- if (task.status === 'completed') return this.consumeCompletedWork(graph, frontier.id, task.id);- if (- task.status === 'failed' ||- task.status === 'canceled' ||- (task.status === 'paused' && task.error)- ) {- if (task.status === 'paused' && task.error === 'Goal Work operation lease expired.') {- return this.resumeAbandonedWorkRecovery(graph, frontier.id, task);- }- if (task.status === 'paused' && task.error === 'Delivery did not pass verification.') {- const taskIds = graph.nodes.flatMap((node) => (node.taskId ? [node.taskId] : []));- const runs = await this.taskTopicModel.findWithHandoffByTaskIds(taskIds, 10_000);- const totalCost = runs.reduce((sum, run) => sum + Number(run.totalCost ?? 0), 0);- const recovery = await new WorkRecoveryCoordinator(- this.db,- this.userId,- this.workspaceId,- ).recover({ goal: graph.goal, spentCost: totalCost, task });- if (recovery === 'continued') {- await this.coordinatorGraph.updateNodeStatus(- goalId,- frontier.id,- 'active',- 'Automatically started the next Work attempt after verification feedback',- );- await this.goalModel.updateStatus(goalId, 'running');- return {- goalId,- message: `Automatically retried task ${task.identifier}`,- nodeId: frontier.id,- outcome: 'waiting_external',- taskId: task.id,- };- }- const exhaustedReason =- recovery === 'exhausted-cost'- ? 'Goal cost budget was exhausted'- : recovery === 'exhausted-rounds'- ? 'Work attempt budget was exhausted'- : 'Automatic recovery could not start the next attempt';- return this.openFailureDecision(graph, frontier.id, task.id, exhaustedReason);- }- return this.openFailureDecision(- graph,frontier.id,- task.id,- task.error ?? `Task ${task.status}`,+ work.currentVersionId,+ 'produced',);}- if (task.status === 'paused') {- return {+ await this.goalModel.updateStatus(goalId, 'running');+ return {+ goalId,+ message: `Created responsible task ${task.identifier}`,+ nodeId: frontier.id,+ outcome: 'advanced',+ taskId: task.id,+ };+ };++ /**+ * Automatic recovery after a Work delivery failed verification. Spends the+ * Work's remaining attempt budget before it escalates to a person.+ */+ private recoverAfterVerification = async (+ graph: GoalGraphSnapshot,+ nodeId: string,+ task: TaskItem,+ effects: GoalAdvanceEffect[],+ ): Promise<GoalTickResult> => {+ const goalId = graph.goal.id;+ const taskIds = graph.nodes.flatMap((node) => (node.taskId ? [node.taskId] : []));+ const runs = await this.taskTopicModel.findWithHandoffByTaskIds(taskIds, 10_000);+ const totalCost = runs.reduce((sum, run) => sum + Number(run.totalCost ?? 0), 0);+ const recovery = await new TaskRecoveryCoordinator(+ this.db,+ this.userId,+ this.workspaceId,+ ).recover({ goal: graph.goal, spentCost: totalCost, task });++ if (recovery.outcome === 'started' || recovery.outcome === 'already-running') {+ await this.coordinatorGraph.updateNodeStatus(goalId,- message: `Task ${task.identifier} is paused`,- nodeId: frontier.id,- outcome: 'waiting_human',- taskId: task.id,- };- }- if (task.status === 'running' || task.status === 'scheduled') {- if (task.status === 'running') {- const recovered = await this.recoverAbandonedWork(graph, frontier.id, task);- if (recovered) return recovered;+ nodeId,+ 'active',+ 'Automatically started the next Work attempt after verification feedback',+ );+ await this.goalModel.updateStatus(goalId, 'running');+ // Only when this advance is the one that spawned the run. Reporting it+ // for a retry another advance owns would put a run in this trajectory+ // that it did not start, and attribute its cost here.+ if (recovery.outcome === 'started') {+ effects.push({+ detail: 'verification retry',+ nodeId,+ operationId: recovery.operationId,+ targetId: task.id,+ type: 'started_run',+ });}return {goalId,- message: `Task ${task.identifier} is ${task.status}`,- nodeId: frontier.id,+ message: `Automatically retried task ${task.identifier}`,+ nodeId,outcome: 'waiting_external',taskId: task.id,};}- const { costLimitReached, roundLimitReached, runs, totalCost } = await this.evaluateBudget(- graph.goal,- graph,- );- if (roundLimitReached || costLimitReached) {- await this.goalModel.updateStatus(goalId, 'paused');- return {- goalId,- message: roundLimitReached- ? `Round budget reached (${runs.length}/${graph.goal.maxRounds})`- : `Cost budget reached ($${totalCost.toFixed(4)}/$${graph.goal.maxTotalCost})`,- nodeId: frontier.id,- outcome: 'no_progress',- taskId: task.id,- };- }+ const exhaustedReason =+ recovery.outcome === 'exhausted-cost'+ ? 'Goal cost budget was exhausted'+ : recovery.outcome === 'exhausted-rounds'+ ? 'Work attempt budget was exhausted'+ : 'Automatic recovery could not start the next attempt';+ return this.openFailureDecision(graph, nodeId, task.id, exhaustedReason, effects);+ };++ /** Claim the task for dispatch and start its run. */+ private dispatchWork = async (+ graph: GoalGraphSnapshot,+ nodeId: string,+ task: TaskItem,+ effects: GoalAdvanceEffect[],+ ): Promise<GoalTickResult> => {+ const goalId = graph.goal.id;// Advances arrive from independent sources — an event hook, a manual nudge,// the sweep — and can overlap. `runTask` decides whether a run is already@@ -651,7 +748,7 @@ export class GoalService {return {goalId,message: `Task ${task.identifier} is already being started`,- nodeId: frontier.id,+ nodeId,outcome: 'waiting_external',taskId: task.id,};@@ -659,14 +756,20 @@ export class GoalService {try {const run = await new TaskRunnerService(this.db, this.userId, this.workspaceId).runTask({- maxSteps: resolveWorkMaxSteps(graph.goal),+ maxSteps: resolveTaskMaxSteps(graph.goal),taskId: task.id,trigger: 'goal',});+ effects.push({+ nodeId,+ operationId: run.operationId,+ targetId: task.id,+ type: 'started_run',+ });return {goalId,message: `Started task ${task.identifier}`,- nodeId: frontier.id,+ nodeId,outcome: 'waiting_external',taskId: run.taskId,};@@ -707,10 +810,11 @@ export class GoalService {}};- private recoverAbandonedWork = async (+ private recoverAbandonedTask = async (graph: GoalGraphSnapshot,nodeId: string,task: TaskItem,+ effects: GoalAdvanceEffect[] = [],): Promise<GoalTickResult | undefined> => {const [runningTopic] = await this.taskTopicModel.findRunningByTaskIds([task.id]);const operationId = runningTopic?.operationId;@@ -756,20 +860,21 @@ export class GoalService {});if (!reclaimed) return undefined;- return this.resumeAbandonedWorkRecovery(graph, nodeId, task);+ return this.resumeAbandonedTaskRecovery(graph, nodeId, task, effects);};- private resumeAbandonedWorkRecovery = async (+ private resumeAbandonedTaskRecovery = async (graph: GoalGraphSnapshot,nodeId: string,task: TaskItem,+ effects: GoalAdvanceEffect[] = [],): Promise<GoalTickResult> => {- const recovery = await new WorkRecoveryCoordinator(+ const recovery = await new TaskRecoveryCoordinator(this.db,this.userId,this.workspaceId,).recover({ goal: graph.goal, task });- if (recovery === 'continued') {+ if (recovery.outcome === 'started' || recovery.outcome === 'already-running') {await this.coordinatorGraph.updateNodeStatus(graph.goal.id,nodeId,@@ -777,6 +882,15 @@ export class GoalService {'Recovered an abandoned Work operation and started the next attempt',);await this.goalModel.updateStatus(graph.goal.id, 'running');+ if (recovery.outcome === 'started') {+ effects.push({+ detail: 'abandoned operation retry',+ nodeId,+ operationId: recovery.operationId,+ targetId: task.id,+ type: 'started_run',+ });+ }return {goalId: graph.goal.id,message: `Recovered abandoned task ${task.identifier}`,@@ -787,15 +901,15 @@ export class GoalService {}const reason =- recovery === 'exhausted-cost'+ recovery.outcome === 'exhausted-cost'? 'Goal cost budget was exhausted after an operation was abandoned'- : recovery === 'exhausted-rounds'+ : recovery.outcome === 'exhausted-rounds'? 'Work attempt budget was exhausted after an operation was abandoned': 'Automatic recovery could not restart an abandoned operation';- return this.openFailureDecision(graph, nodeId, task.id, reason);+ return this.openFailureDecision(graph, nodeId, task.id, reason, effects);};- private buildWorkInstruction = (+ private buildTaskInstruction = (graph: GoalGraphSnapshot,title: string,description: string | null,@@ -816,12 +930,12 @@ export class GoalService {.filter(Boolean).join('\n\n');- private buildWorkAcceptanceRequirement = (+ private buildTaskAcceptanceRequirement = (graph: GoalGraphSnapshot,title: string,description: string | null,) => {- if (title === GOAL_ACCEPTANCE_WORK_TITLE) {+ if (title === GOAL_ACCEPTANCE_TASK_TITLE) {return [`Terminal Goal acceptance requirement (authoritative): ${graph.goal.requirement ?? graph.goal.title}`,description ? `Required delivery: ${description}` : undefined,@@ -845,10 +959,11 @@ export class GoalService {.join('\n\n');};- private consumeCompletedWork = async (+ private consumeCompletedTask = async (graph: GoalGraphSnapshot,nodeId: string,taskId: string,+ effects: GoalAdvanceEffect[] = [],): Promise<GoalTickResult> => {const existingFinding = graph.edges.some((edge) => edge.sourceNodeId === nodeId && edge.kind === 'produces',@@ -862,6 +977,13 @@ export class GoalService {toolName: 'synthesizeTaskOutcome',topicId: latest?.topicId,});+ effects.push({+ nodeId,+ operationId: latest?.operationId ?? undefined,+ targetId: taskId,+ type: 'node_status',+ detail: 'resolved',+ });if (completedWork?.currentVersionId) {await this.coordinatorGraph.attachWorkVersion(graph.goal.id,@@ -882,8 +1004,10 @@ export class GoalService {handoff?.summary ??`Completed: ${graph.nodes.find((node) => node.id === nodeId)?.title}`,});- if (finding)+ if (finding) {+ effects.push({ detail: 'finding', nodeId, targetId: finding.id, type: 'created_node' });await this.coordinatorGraph.createEdge(graph.goal.id, nodeId, finding.id, 'produces');+ }}await this.coordinatorGraph.updateNodeStatus(graph.goal.id,@@ -905,6 +1029,7 @@ export class GoalService {nodeId: string,taskId: string,reason: string,+ effects: GoalAdvanceEffect[] = [],): Promise<GoalTickResult> => {const existingDecisionNode = graph.edges.filter((edge) => edge.sourceNodeId === nodeId && edge.kind === 'leads_to')@@ -915,13 +1040,14 @@ export class GoalService {description: reason,kind: 'decision',status: 'waiting',- title: 'Choose how to recover failed work',+ title: 'Choose how to recover failed task',});if (node) {+ effects.push({ detail: reason, nodeId, targetId: node.id, type: 'opened_decision' });await this.coordinatorGraph.createEdge(graph.goal.id, nodeId, node.id, 'leads_to');const terminalAcceptance =graph.nodes.find((candidate) => candidate.id === nodeId)?.title ===- GOAL_ACCEPTANCE_WORK_TITLE;+ GOAL_ACCEPTANCE_TASK_TITLE;await this.coordinatorGraph.createDecision(graph.goal.id, node.id, {authority: 'user',options: terminalAcceptance@@ -930,12 +1056,12 @@ export class GoalService {{ id: 'fail', label: 'Fail goal' },]: [- { id: 'retry', label: 'Retry work' },- { id: 'retire', label: 'Retire work' },+ { id: 'retry', label: 'Retry task' },+ { id: 'retire', label: 'Retire task' },],question: terminalAcceptance? `${reason}. Retry Goal acceptance or fail this Goal?`- : `${reason}. Retry or retire this work node?`,+ : `${reason}. Retry or retire this task node?`,recommendedOptionId: 'retry',requestedUserId: this.userId,});diff --git a/apps/server/src/services/goal/recoveryPolicy.ts b/apps/server/src/services/goal/recoveryPolicy.tsindex 1a0b663e965..b7b197555be 100644--- a/apps/server/src/services/goal/recoveryPolicy.ts+++ b/apps/server/src/services/goal/recoveryPolicy.ts@@ -8,13 +8,13 @@ const DEFAULT_OPERATION_LEASE_TIMEOUT_MS = 5 * 60 * 1000;export const MIN_OPERATION_LEASE_TIMEOUT_MS = 3 * 60 * 1000;/** How many attempts one Work gets before the coordinator opens a decision gate. */-export const resolveWorkAttemptBudget = (goal: GoalItem): number => {- const configured = goal.config?.recovery?.maxAttemptsPerWork;+export const resolveTaskAttemptBudget = (goal: GoalItem): number => {+ const configured = goal.config?.recovery?.maxAttemptsPerTask;if (typeof configured === 'number') return Math.max(1, configured);return DEFAULT_MAX_ATTEMPTS_PER_WORK;};-export const resolveWorkMaxSteps = (goal: GoalItem): number | undefined => {+export const resolveTaskMaxSteps = (goal: GoalItem): number | undefined => {const configured = goal.config?.recovery?.maxStepsPerRun;return typeof configured === 'number' && configured > 0 ? configured : undefined;};diff --git a/apps/server/src/services/goal/replayCoordinator.test.ts b/apps/server/src/services/goal/replayCoordinator.test.tsnew file mode 100644index 00000000000..23c04d51fa6--- /dev/null+++ b/apps/server/src/services/goal/replayCoordinator.test.ts@@ -0,0 +1,171 @@+import type { GoalGraphState, GoalTickSnapshot, GoalTrajectory } from '@lobechat/agent-tracing';+import { describe, expect, it } from 'vitest';++import { replayGoalAgainstCurrentCoordinator } from './replayCoordinator';++const work = (id: string, overrides: Partial<GoalGraphState['nodes'][number]> = {}) => ({+ createdAt: 1000,+ id,+ kind: 'task',+ priority: 0,+ status: 'proposed',+ taskId: null,+ title: id,+ ...overrides,+});++const graphState = (overrides: Partial<GoalGraphState> = {}): GoalGraphState => ({+ decisions: [],+ edges: [],+ goal: {+ id: 'goal_1',+ maxRounds: null,+ maxTotalCost: null,+ requirement: 'Prove it',+ status: 'running',+ title: 'Reproduce nanoGPT',+ },+ nodes: [],+ ...overrides,+});++const tick = (index: number, overrides: Partial<GoalTickSnapshot>): GoalTickSnapshot => ({+ at: 1000,+ branch: 'create_task',+ candidates: [],+ effects: [],+ graphShape: {+ edgesTotal: 0,+ findings: 0,+ gatesPending: 0,+ nodesTotal: 0,+ tasksBlocked: 0,+ tasksOpen: 0,+ tasksReady: 0,+ tasksCompleted: 0,+ },+ index,+ message: '',+ outcome: 'advanced',+ ...overrides,+});++/**+ * Two advances of a two-Work goal: the second Work depends on the first, so the+ * coordinator picks `a`, then picks `b` only once `a` resolves.+ */+const trajectory: GoalTrajectory = {+ advances: [+ {+ completedAt: 10,+ durationMs: 10,+ seq: 0,+ startedAt: 0,+ ticks: [+ tick(0, {+ candidates: [+ { blockedBy: [], nodeId: 'a', priority: 0, status: 'proposed', title: 'a' },+ { blockedBy: ['a'], nodeId: 'b', priority: 0, status: 'proposed', title: 'b' },+ ],+ chosenNodeId: 'a',+ }),+ ],+ trigger: 'create',+ },+ {+ completedAt: 30,+ durationMs: 10,+ seq: 1,+ startedAt: 20,+ ticks: [+ tick(0, {+ candidates: [{ blockedBy: [], nodeId: 'b', priority: 0, status: 'proposed', title: 'b' }],+ chosenNodeId: 'b',+ graphDelta: { nodesUpserted: [work('a', { status: 'resolved' })] },+ }),+ ],+ trigger: 'settle',+ },+ ],+ goalId: 'goal_1',+ graphBaseline: graphState({+ edges: [{ id: 'e1', kind: 'depends_on', sourceNodeId: 'b', targetNodeId: 'a' }],+ nodes: [work('a'), work('b')],+ }),+ startedAt: 0,+ title: 'Reproduce nanoGPT',+ totalAdvances: 2,+ totalTicks: 2,+ traceId: 'goal_1',+};++describe('replayGoalAgainstCurrentCoordinator', () => {+ it('reproduces a recorded run against the live coordinator', () => {+ expect(replayGoalAgainstCurrentCoordinator(trajectory)).toMatchObject({+ divergences: [],+ matched: 2,+ ticks: 2,+ });+ });++ it('reports the advance and tick where the coordinator would now choose differently', () => {+ const altered: GoalTrajectory = {+ ...trajectory,+ advances: [+ trajectory.advances[0],+ {+ ...trajectory.advances[1],+ ticks: [{ ...trajectory.advances[1].ticks[0], chosenNodeId: 'a' }],+ },+ ],+ };++ expect(replayGoalAgainstCurrentCoordinator(altered).divergences).toEqual([+ { advanceSeq: 1, field: 'chosenNodeId', recorded: 'a', replayed: 'b', tickIndex: 0 },+ ]);+ });++ it('replays the dependency gate from the state at each tick, not the final one', () => {+ // Without folding the delta, `b` would look blocked at advance 1 and the+ // recorded choice would read as a divergence.+ const result = replayGoalAgainstCurrentCoordinator(trajectory);++ expect(result.matched).toBe(result.ticks);+ });++ it('carries the recorded budget into the decision', () => {+ const exhausted: GoalTrajectory = {+ ...trajectory,+ advances: [+ {+ ...trajectory.advances[0],+ ticks: [+ tick(0, {+ branch: 'budget_exhausted',+ budget: {+ costLimitReached: true,+ maxTotalCost: 1,+ roundLimitReached: false,+ runs: 4,+ totalCost: 2,+ },+ candidates: [+ { blockedBy: [], nodeId: 'a', priority: 0, status: 'proposed', title: 'a' },+ { blockedBy: ['a'], nodeId: 'b', priority: 0, status: 'proposed', title: 'b' },+ ],+ chosenNodeId: 'a',+ frontierTask: { id: 'task_1', status: 'backlog', updatedAt: 0 },+ outcome: 'no_progress',+ }),+ ],+ },+ ],+ graphBaseline: graphState({+ edges: [{ id: 'e1', kind: 'depends_on', sourceNodeId: 'b', targetNodeId: 'a' }],+ nodes: [work('a', { taskId: 'task_1' }), work('b')],+ }),+ };++ expect(replayGoalAgainstCurrentCoordinator(exhausted).divergences).toEqual([]);+ });+});diff --git a/apps/server/src/services/goal/replayCoordinator.ts b/apps/server/src/services/goal/replayCoordinator.tsnew file mode 100644index 00000000000..8453bfaee56--- /dev/null+++ b/apps/server/src/services/goal/replayCoordinator.ts@@ -0,0 +1,72 @@+import type {+ GoalDecider,+ GoalDecision,+ GoalDecisionInput,+ GoalGraphState,+ GoalReplayResult,+ GoalTrajectory,+} from '@lobechat/agent-tracing';+import { replayGoalTrajectory } from '@lobechat/agent-tracing';+import type { GoalGraphSnapshot, TaskItem } from '@lobechat/types';++import { decideNextMove, selectFrontier } from './decideNextMove';++/**+ * Lift a recorded graph back into the shape the coordinator reads.+ *+ * The trace stores only what the decision depends on, so this fills the rest+ * with empty values rather than inventing content: `decideNextMove` never looks+ * at descriptions, events or work versions, and a replay that fabricated them+ * would be testing something the original run never saw.+ */+export const fromTraceGraphState = (state: GoalGraphState): GoalGraphSnapshot =>+ ({+ decisions: state.decisions.map((decision) => ({+ ...decision,+ options: null,+ recommendedOptionId: null,+ })),+ edges: state.edges,+ events: [],+ goal: { ...state.goal, config: null, projectId: null },+ nodes: state.nodes.map((node) => ({+ ...node,+ createdAt: new Date(node.createdAt),+ description: null,+ })),+ workVersions: [],+ }) as unknown as GoalGraphSnapshot;++const toTask = (input: GoalDecisionInput): TaskItem | undefined | null => {+ if (input.frontierTask === undefined) return undefined;+ return { ...input.frontierTask, updatedAt: new Date(input.frontierTask.updatedAt) } as TaskItem;+};++/**+ * The live coordinator, as a decider a recorded trajectory can be replayed+ * against.+ *+ * This is the whole payoff of splitting the decision out of `tick`: the+ * function under test here is the one production runs, not a model of it.+ */+export const coordinatorDecider: GoalDecider = (input): GoalDecision => {+ const graph = fromTraceGraphState(input.graph);+ const frontier = selectFrontier(graph);+ const move = decideNextMove({+ budget: input.budget,+ frontier,+ frontierTask: toTask(input),+ graph,+ });++ return { branch: move.branch, candidates: move.candidates, chosenNodeId: move.chosenNodeId };+};++/**+ * Replay a recorded goal against the current coordinator.+ *+ * An empty `divergences` means a rule change was inert on this run; every entry+ * is a real behavioural difference, with the advance and tick that produced it.+ */+export const replayGoalAgainstCurrentCoordinator = (trajectory: GoalTrajectory): GoalReplayResult =>+ replayGoalTrajectory(trajectory, coordinatorDecider);diff --git a/apps/server/src/services/goal/scheduler/impls/local.ts b/apps/server/src/services/goal/scheduler/impls/local.tsindex 8e53685832c..76684a918fe 100644--- a/apps/server/src/services/goal/scheduler/impls/local.ts+++ b/apps/server/src/services/goal/scheduler/impls/local.ts@@ -14,14 +14,14 @@ export class LocalGoalScheduler implements GoalSchedulerImpl {private pending = new Map<string, NodeJS.Timeout>();async scheduleAdvance(params: ScheduleGoalAdvanceParams): Promise<string> {- const { delay = 0, goalId, userId, workspaceId } = params;+ const { delay = 0, goalId, trigger, userId, workspaceId } = params;const scheduleId = `local-goal-${goalId}-${Date.now()}`;log('scheduling advance for goal %s (delay: %ds)', goalId, delay);const timer = setTimeout(async () => {this.pending.delete(scheduleId);try {- await advanceGoal({ goalId, userId, workspaceId });+ await advanceGoal({ goalId, trigger, userId, workspaceId });} catch (error) {// Never surface: an advance is best-effort, and the sweep retries.log('advance failed for goal %s: %O', goalId, error);diff --git a/apps/server/src/services/goal/scheduler/impls/qstash.ts b/apps/server/src/services/goal/scheduler/impls/qstash.tsindex e847832be9d..1a4523c861d 100644--- a/apps/server/src/services/goal/scheduler/impls/qstash.ts+++ b/apps/server/src/services/goal/scheduler/impls/qstash.ts@@ -31,12 +31,12 @@ export class QStashGoalScheduler implements GoalSchedulerImpl {}async scheduleAdvance(params: ScheduleGoalAdvanceParams): Promise<string> {- const { delay = 0, goalId, userId, workspaceId } = params;+ const { delay = 0, goalId, trigger, userId, workspaceId } = params;const url = `${this.baseUrl}${GOAL_ADVANCE_PATH}`;log('publishing advance: goal=%s delay=%ds url=%s', goalId, delay, url);const response = await this.qstashClient.publishJSON({- body: { goalId, userId, workspaceId },+ body: { goalId, trigger, userId, workspaceId },delay,url,});diff --git a/apps/server/src/services/goal/scheduler/impls/type.ts b/apps/server/src/services/goal/scheduler/impls/type.tsindex bced80dfc46..77567d7f399 100644--- a/apps/server/src/services/goal/scheduler/impls/type.ts+++ b/apps/server/src/services/goal/scheduler/impls/type.ts@@ -1,7 +1,11 @@+import type { GoalAdvanceTrigger } from '@lobechat/agent-tracing';+export interface ScheduleGoalAdvanceParams {/** Seconds to wait before advancing. Defaults to 0 (as soon as possible). */delay?: number;goalId: string;+ /** What made this goal advanceable. Survives the queue hop onto the trajectory. */+ trigger?: GoalAdvanceTrigger;userId: string;workspaceId?: string;}diff --git a/apps/server/src/services/goal/workRecoveryCoordinator.ts b/apps/server/src/services/goal/taskRecoveryCoordinator.tssimilarity index 65%rename from apps/server/src/services/goal/workRecoveryCoordinator.tsrename to apps/server/src/services/goal/taskRecoveryCoordinator.tsindex 081526dffbc..ff57199f89b 100644--- a/apps/server/src/services/goal/workRecoveryCoordinator.ts+++ b/apps/server/src/services/goal/taskRecoveryCoordinator.ts@@ -6,15 +6,33 @@ import { TaskModel } from '@/database/models/task';import type { LobeChatDatabase } from '@/database/type';import { TaskRunnerService } from '@/server/services/taskRunner';-import { resolveWorkAttemptBudget, resolveWorkMaxSteps } from './recoveryPolicy';+import { resolveTaskAttemptBudget, resolveTaskMaxSteps } from './recoveryPolicy';const log = debug('lobe-server:goal-work-recovery');-export type WorkRecoveryOutcome =- 'continued' | 'exhausted-cost' | 'exhausted-rounds' | 'spawn-failed';+export type TaskRecoveryOutcome =+ /** This call spawned the retry, and `operationId` is its run. */+ | 'started'+ /** Another overlapping advance owns the retry; this one started nothing. */+ | 'already-running'+ | 'exhausted-cost'+ | 'exhausted-rounds'+ | 'spawn-failed';++/**+ * `started` and `already-running` both mean "the Work is moving, keep waiting",+ * but only the first is something *this* advance did. They used to share the+ * name `continued`, which made the trajectory claim a run it had not started+ * and drop the operation id of the one it had.+ */+export interface TaskRecoveryResult {+ /** Present only on `started`. The drill-down link into `agent_operations`. */+ operationId?: string;+ outcome: TaskRecoveryOutcome;+}/** Retry budget and spawn boundary for a Goal Graph Work Task. */-export class WorkRecoveryCoordinator {+export class TaskRecoveryCoordinator {constructor(private readonly db: LobeChatDatabase,private readonly userId: string,@@ -25,11 +43,11 @@ export class WorkRecoveryCoordinator {goal: GoalItem;spentCost?: number;task: TaskItem;- }): Promise<WorkRecoveryOutcome> => {+ }): Promise<TaskRecoveryResult> => {const { goal, task } = params;const attempts = task.totalTopics || 0;- const attemptBudget = resolveWorkAttemptBudget(goal);- if (attempts >= attemptBudget) return 'exhausted-rounds';+ const attemptBudget = resolveTaskAttemptBudget(goal);+ if (attempts >= attemptBudget) return { outcome: 'exhausted-rounds' };if (typeof goal.maxTotalCost === 'number') {const spent =@@ -37,7 +55,7 @@ export class WorkRecoveryCoordinator {(await new AgentOperationModel(this.db, this.userId, this.workspaceId).sumCostByTask(task.id,));- if (spent >= goal.maxTotalCost) return 'exhausted-cost';+ if (spent >= goal.maxTotalCost) return { outcome: 'exhausted-cost' };}// Both recovery paths — a failed verification and an abandoned operation —@@ -53,7 +71,7 @@ export class WorkRecoveryCoordinator {const current = await taskModel.findById(task.id);if (!current || current.status === 'running') {log('task %s recovery was already claimed by another advance', task.identifier);- return 'continued';+ return { outcome: 'already-running' };}const claimed = await taskModel.updateStatusIfCurrent(task.id, current.status, 'running', {error: null,@@ -61,17 +79,17 @@ export class WorkRecoveryCoordinator {});if (!claimed) {log('task %s recovery lost the claim race', task.identifier);- return 'continued';+ return { outcome: 'already-running' };}try {- await new TaskRunnerService(this.db, this.userId, this.workspaceId).runTask({- maxSteps: resolveWorkMaxSteps(goal),+ const run = await new TaskRunnerService(this.db, this.userId, this.workspaceId).runTask({+ maxSteps: resolveTaskMaxSteps(goal),taskId: task.id,trigger: 'goal',});log('task %s → recovery attempt %d spawned', task.identifier, attempts + 1);- return 'continued';+ return { operationId: run.operationId, outcome: 'started' };} catch (error) {log('task %s recovery spawn failed (non-fatal): %O', task.identifier, error);// We own the claim, so nothing else will put the task back.@@ -80,7 +98,7 @@ export class WorkRecoveryCoordinator {.catch((releaseError) => {log('task %s failed to release the recovery claim: %O', task.identifier, releaseError);});- return 'spawn-failed';+ return { outcome: 'spawn-failed' };}};}diff --git a/apps/server/src/services/goal/traceObservation.ts b/apps/server/src/services/goal/traceObservation.tsnew file mode 100644index 00000000000..eea5f0f9f63--- /dev/null+++ b/apps/server/src/services/goal/traceObservation.ts@@ -0,0 +1,100 @@+import type {+ FrontierCandidate,+ GoalAdvanceEffect,+ GoalBudgetState,+ GoalFrontierTaskState,+ GoalGraphState,+ GoalTickBranch,+ GoalTickOutcome,+} from '@lobechat/agent-tracing';+import type { GoalGraphSnapshot, GoalItem, TaskItem } from '@lobechat/types';++/**+ * What one tick read and what it did, handed to the trajectory recorder.+ *+ * Travels through a side channel rather than on `GoalTickResult` because the+ * graph payload is large and that result crosses tRPC to the client — the same+ * reason the context engine snapshot stays off the agent runtime's event array.+ */+export interface GoalTickObservation {+ at: number;+ branch: GoalTickBranch;+ budget?: GoalBudgetState;+ candidates: FrontierCandidate[];+ chosenNodeId?: string;+ effects: GoalAdvanceEffect[];+ frontierTask?: GoalFrontierTaskState;+ graphState: GoalGraphState;+ message: string;+ outcome: GoalTickOutcome;+ taskId?: string;+}++export interface GoalTickOptions {+ onDecision?: (observation: GoalTickObservation) => void;+}++/**+ * Project the server graph onto the trace format.+ *+ * Only what the coordinator actually reads is carried over: descriptions,+ * confidences and event history are not decision inputs, and a trajectory that+ * copied them would grow with the conversation rather than with the reasoning.+ */+export const toTraceGraphState = (graph: GoalGraphSnapshot): GoalGraphState => ({+ decisions: graph.decisions.map((decision) => ({+ id: decision.id,+ nodeId: decision.nodeId,+ question: decision.question,+ resolvedOptionId: decision.resolvedOptionId,+ status: decision.status,+ })),+ edges: graph.edges.map((edge) => ({+ id: edge.id,+ kind: edge.kind,+ sourceNodeId: edge.sourceNodeId,+ targetNodeId: edge.targetNodeId,+ })),+ goal: {+ agentId: graph.goal.agentId,+ id: graph.goal.id,+ maxRounds: graph.goal.maxRounds,+ maxTotalCost: graph.goal.maxTotalCost,+ requirement: graph.goal.requirement,+ status: graph.goal.status,+ title: graph.goal.title,+ },+ nodes: graph.nodes.map((node) => ({+ createdAt: node.createdAt.getTime(),+ id: node.id,+ kind: node.kind,+ priority: node.priority,+ status: node.status,+ taskId: node.taskId,+ title: node.title,+ })),+});++export const toFrontierTaskState = (task: TaskItem): GoalFrontierTaskState => ({+ error: task.error,+ id: task.id,+ identifier: task.identifier,+ status: task.status,+ updatedAt: new Date(task.updatedAt).getTime(),+});++export interface BudgetEvaluation {+ costLimitReached: boolean;+ roundLimitReached: boolean;+ runs: { length: number };+ totalCost: number;+}++export const toBudgetState = (goal: GoalItem, budget: BudgetEvaluation): GoalBudgetState => ({+ costLimitReached: budget.costLimitReached,+ maxRounds: goal.maxRounds,+ maxTotalCost: goal.maxTotalCost === null ? null : Number(goal.maxTotalCost),+ roundLimitReached: budget.roundLimitReached,+ runs: budget.runs.length,+ totalCost: budget.totalCost,+});diff --git a/apps/server/src/services/goal/traceStore.ts b/apps/server/src/services/goal/traceStore.tsnew file mode 100644index 00000000000..a9ac2529ab1--- /dev/null+++ b/apps/server/src/services/goal/traceStore.ts@@ -0,0 +1,41 @@+import { FileGoalTraceStore, type IGoalTraceStore } from '@lobechat/agent-tracing';++import { S3GoalTraceStore } from '@/server/modules/GoalTracing';++import { shouldUseAgentS3Tracing } from '../agentRuntime/snapshotStore';++/**+ * Constructor injection for tests. Defaults are statically imported — never+ * load them through a dynamic `require(moduleName)`, which defeats the+ * bundler's `@/` alias resolution and silently yields a null store.+ */+export interface GoalTraceStoreFactories {+ createFile?: () => IGoalTraceStore;+ createS3?: () => IGoalTraceStore;+}++/**+ * Goal trajectories follow the same switch as operation snapshots, so a+ * deployment that records one records the other and a goal trace never points+ * at operation traces that were not kept.+ */+export const createDefaultGoalTraceStore = (+ factories: GoalTraceStoreFactories = {},+): IGoalTraceStore | null => {+ if (shouldUseAgentS3Tracing()) {+ try {+ return (factories.createS3 ?? (() => new S3GoalTraceStore()))();+ } catch (error) {+ // Best-effort, but loud: a swallowed failure here would leave production+ // goals with no trajectory and no sign of why.+ console.error('[goalTraceStore] failed to create S3GoalTraceStore, tracing disabled:', error);+ return null;+ }+ }++ if (process.env.NODE_ENV === 'development') {+ return (factories.createFile ?? (() => new FileGoalTraceStore()))();+ }++ return null;+};diff --git a/apps/server/src/services/taskRunner/buildTaskPrompt.test.ts b/apps/server/src/services/taskRunner/buildTaskPrompt.test.tsindex ff56dfd5556..d74374cae89 100644--- a/apps/server/src/services/taskRunner/buildTaskPrompt.test.ts+++ b/apps/server/src/services/taskRunner/buildTaskPrompt.test.ts@@ -35,17 +35,17 @@ describe('buildTaskPrompt Goal loop context', () => {});await taskModel.update(task.id, { totalTopics: 1 });const goal = await new GoalModel(db, userId).create({- config: { recovery: { maxAttemptsPerWork: 2 } },+ config: { recovery: { maxAttemptsPerTask: 2 } },maxRounds: 20,subjectType: 'standalone',title: 'Graph-managed work budget',});const graphModel = new GoalGraphModel(db, userId);- const workNode = await graphModel.createNode(goal.id, {- kind: 'work',+ const taskNode = await graphModel.createNode(goal.id, {+ kind: 'task',title: 'Close acceptance gap',});- await graphModel.bindTask(goal.id, workNode!.id, task.id);+ await graphModel.bindTask(goal.id, taskNode!.id, task.id);const currentTask = await taskModel.findById(task.id);const result = await buildTaskPrompt(currentTask!, {diff --git a/apps/server/src/services/taskRunner/buildTaskPrompt.ts b/apps/server/src/services/taskRunner/buildTaskPrompt.tsindex ab310e01b6f..169dc90e217 100644--- a/apps/server/src/services/taskRunner/buildTaskPrompt.ts+++ b/apps/server/src/services/taskRunner/buildTaskPrompt.ts@@ -13,7 +13,7 @@ import { VerifyRunModel } from '@/database/models/verifyRun';import type { LobeChatDatabase } from '@/database/type';import { extractFileIdsFromEditorData } from '@/server/services/file/extractFileIdsFromEditorData';import { resolveAttachmentMetadata } from '@/server/services/file/resolveAttachments';-import { resolveWorkAttemptBudget } from '@/server/services/goal/recoveryPolicy';+import { resolveTaskAttemptBudget } from '@/server/services/goal/recoveryPolicy';import { resolveTaskAcceptance } from '@/server/services/verify/taskAcceptance';/** Cap on unresolved checks carried into the next round's prompt. */@@ -34,7 +34,7 @@ const resolveGoalLoopContext = async (const goal = await new GoalModel(db, userId, workspaceId).findByWorkTask(task.id);if (!goal || !task.totalTopics) return undefined;- const budget = resolveWorkAttemptBudget(goal);+ const budget = resolveTaskAttemptBudget(goal);const context: TaskRunPromptGoalLoop = {maxRounds: Number.isFinite(budget) ? budget : null,round: (task.totalTopics || 0) + 1,diff --git a/apps/server/src/services/toolExecution/serverRuntimes/__tests__/goal.test.ts b/apps/server/src/services/toolExecution/serverRuntimes/__tests__/goal.test.tsindex 3858825435b..1381db6a26b 100644--- a/apps/server/src/services/toolExecution/serverRuntimes/__tests__/goal.test.ts+++ b/apps/server/src/services/toolExecution/serverRuntimes/__tests__/goal.test.ts@@ -47,6 +47,9 @@ describe('goalRuntime.createGoal', () => {expect(mocks.scheduleGoalAdvance).toHaveBeenCalledWith({goalId: 'goal_1',+ // The label survives the queue hop onto the trajectory, so a run can be+ // sliced by what drove it — asserted here rather than left loose.+ trigger: 'create',userId: 'user-1',workspaceId: 'ws-1',});diff --git a/apps/server/src/services/toolExecution/serverRuntimes/goal.ts b/apps/server/src/services/toolExecution/serverRuntimes/goal.tsindex 8b071e12a02..0ab45014639 100644--- a/apps/server/src/services/toolExecution/serverRuntimes/goal.ts+++ b/apps/server/src/services/toolExecution/serverRuntimes/goal.ts@@ -45,7 +45,7 @@ export const goalRuntime: ServerRuntimeRegistration = {agentId,createdByAgentId: agentId,config: {- recovery: { maxAttemptsPerWork: resolveGoalAttemptBudget(args.maxIterations) },+ recovery: { maxAttemptsPerTask: resolveGoalAttemptBudget(args.maxIterations) },},// `maxIterations` caps attempts on one Work; it is deliberately not// passed as `maxRounds`, which counts runs across every Work in the@@ -62,6 +62,7 @@ export const goalRuntime: ServerRuntimeRegistration = {// while the agent has been told not to create it again.await scheduleGoalAdvance({goalId: graph.goal.id,+ trigger: 'create',userId,workspaceId: workspaceId ?? undefined,});@@ -80,6 +81,7 @@ export const goalRuntime: ServerRuntimeRegistration = {// the goal keeps itself moving through the queued advances.const { result } = await advanceGoal({goalId: graph.goal.id,+ trigger: 'create',userId,workspaceId: workspaceId ?? undefined,});diff --git a/apps/server/src/services/verify/settle.ts b/apps/server/src/services/verify/settle.tsindex e4ab0151d17..41363308b36 100644--- a/apps/server/src/services/verify/settle.ts+++ b/apps/server/src/services/verify/settle.ts@@ -177,7 +177,7 @@ export const driveTaskFromVerify = async (taskOperation.taskId,);if (goal) {- await scheduleGoalAdvance({ goalId: goal.id, userId, workspaceId });+ await scheduleGoalAdvance({ goalId: goal.id, trigger: 'settle', userId, workspaceId });log('verify-settle → queued goal advance for %s', goal.id);}} catch (error) {diff --git a/docs/development/database-schema.dbml b/docs/development/database-schema.dbmlindex 25427d5b54d..b5c77e0eb31 100644--- a/docs/development/database-schema.dbml+++ b/docs/development/database-schema.dbml@@ -309,7 +309,7 @@ table agent_eval_runs {updated_at "timestamp with time zone" [not null, default: `now()`]indexes {-+dataset_id [name: 'agent_eval_runs_dataset_id_idx']experiment_id [name: 'agent_eval_runs_experiment_id_idx']parent_run_id [name: 'agent_eval_runs_parent_run_id_idx']@@ -450,11 +450,11 @@ table agent_intervention_resolutions {resolution_request_id [name: 'agent_intervention_resolutions_request_unique', unique](user_id, workspace_id, batch_id) [name: 'agent_intervention_resolutions_owner_batch_idx'](status, created_at) [name: 'agent_intervention_resolutions_status_created_idx']-----+++++}}@@ -504,11 +504,11 @@ table agent_interventions {(user_id, workspace_id, batch_id, item_index) [name: 'agent_interventions_owner_batch_idx'](user_id, activity_key) [name: 'agent_interventions_activity_key_idx'](status, deadline) [name: 'agent_interventions_status_deadline_idx']-----+++++}}@@ -1261,7 +1261,7 @@ table expertise_bindings {updated_at "timestamp with time zone" [not null, default: `now()`]indexes {-+(agent_id, domain_id) [name: 'expertise_bindings_agent_domain_unique', unique](project_id, domain_id) [name: 'expertise_bindings_project_domain_unique', unique](bound_workspace_id, domain_id) [name: 'expertise_bindings_workspace_domain_unique', unique]@@ -1297,7 +1297,7 @@ table expertise_domain_snapshots {captured_at "timestamp with time zone" [not null, default: `now()`]indexes {-+(domain_id, run_index) [name: 'expertise_domain_snapshots_domain_run_index_unique', unique](domain_id, captured_at) [name: 'expertise_domain_snapshots_domain_captured_idx']domain_id [name: 'expertise_domain_snapshots_pending_fit_idx']@@ -1358,8 +1358,8 @@ table expertise_hits {created_at "timestamp with time zone" [not null, default: `now()`]indexes {--++(lesson_id, created_at) [name: 'expertise_hits_lesson_created_idx']run_id [name: 'expertise_hits_run_idx'](domain_id, outcome) [name: 'expertise_hits_domain_outcome_idx']@@ -1623,6 +1623,28 @@ table knowledge_bases {}}+table fts_search_sync_outbox {+ attempts integer [not null, default: 0]+ available_at "timestamp with time zone" [not null, default: `now()`]+ created_at "timestamp with time zone" [not null, default: `now()`]+ dead_at "timestamp with time zone"+ document_id text [not null]+ entity text [not null]+ id uuid [pk, not null, default: `gen_random_uuid()`]+ last_error text+ locked_until "timestamp with time zone"+ priority smallint [not null, default: 10]+ revision bigint [not null, default: `nextval('fts_search_sync_revision_seq')`]+ updated_at "timestamp with time zone" [not null, default: `now()`]++ indexes {+ (entity, document_id) [name: 'fts_search_sync_outbox_entity_document_id_unique', unique]+ (priority, available_at, revision) [name: 'fts_search_sync_outbox_claim_idx']+ dead_at [name: 'fts_search_sync_outbox_dead_idx']+ locked_until [name: 'fts_search_sync_outbox_lease_idx']+ }+}+table generation_batches {id text [pk, not null]user_id text [not null]@@ -1735,9 +1757,9 @@ table goal_edges {(source_node_id, target_node_id, kind) [name: 'goal_edges_source_target_kind_unique', unique]goal_id [name: 'goal_edges_goal_id_idx']target_node_id [name: 'goal_edges_target_node_id_idx']---+++}}@@ -1824,8 +1846,7 @@ table goal_nodes {(goal_id, kind) [name: 'goal_nodes_goal_id_kind_idx'](goal_id, id) [name: 'goal_nodes_goal_id_id_unique', unique]task_id [name: 'goal_nodes_task_id_unique', unique]--+}}@@ -2479,7 +2500,7 @@ table project_completion_reviews {(project_id, created_at) [name: 'project_completion_reviews_project_id_created_at_idx']reviewer_user_id [name: 'project_completion_reviews_reviewer_user_id_idx']workspace_id [name: 'project_completion_reviews_workspace_id_idx']-+}}@@ -2554,7 +2575,7 @@ table projects {(workspace_id, visibility, user_id) [name: 'projects_workspace_visibility_idx'](status, updated_at) [name: 'projects_status_updated_at_idx']coordinator_agent_id [name: 'projects_coordinator_agent_id_unique', unique]-+}}@@ -2575,7 +2596,7 @@ table push_live_activities {(user_id, activity_key) [name: 'idx_push_live_activities_user_activity'](user_id, operation_id) [name: 'idx_push_live_activities_user_operation']last_seen_at [name: 'idx_push_live_activities_last_seen']-+}}@@ -2596,7 +2617,7 @@ table push_tokens {(user_id, device_id) [name: 'idx_push_tokens_user_device', unique]user_id [name: 'idx_push_tokens_user']last_seen_at [name: 'idx_push_tokens_last_seen']-+}}@@ -2914,28 +2935,6 @@ table resource_transfer_requests {}}-table fts_search_sync_outbox {- attempts integer [not null, default: 0]- available_at "timestamp with time zone" [not null, default: `now()`]- created_at "timestamp with time zone" [not null, default: `now()`]- dead_at "timestamp with time zone"- document_id text [not null]- entity text [not null]- id uuid [pk, not null, default: `gen_random_uuid()`]- last_error text- locked_until "timestamp with time zone"- priority smallint [not null, default: 10]- revision bigint [not null, default: `nextval('fts_search_sync_revision_seq')`]- updated_at "timestamp with time zone" [not null, default: `now()`]-- indexes {- (entity, document_id) [name: 'fts_search_sync_outbox_entity_document_id_unique', unique]- (priority, available_at, revision) [name: 'fts_search_sync_outbox_claim_idx']- dead_at [name: 'fts_search_sync_outbox_dead_idx']- locked_until [name: 'fts_search_sync_outbox_lease_idx']- }-}-table session_groups {id text [pk, not null]name text [not null]@@ -3180,7 +3179,7 @@ table tasks {updated_at "timestamp with time zone" [not null, default: `now()`]indexes {-+(identifier, created_by_user_id) [name: 'tasks_identifier_idx', unique]created_by_user_id [name: 'tasks_created_by_user_id_idx']created_by_agent_id [name: 'tasks_created_by_agent_id_idx']@@ -3354,10 +3353,10 @@ table topic_comments {indexes {(topic_id, author_user_id, client_id) [name: 'topic_comments_topic_id_author_user_id_client_id_unique', unique]----++++(parent_comment_id, created_at, id) [name: 'topic_comments_parent_comment_id_created_at_id_idx'](topic_id, created_at, id) [name: 'topic_comments_topic_id_created_at_id_idx'](topic_id, message_id) [name: 'topic_comments_topic_id_message_id_idx']@@ -3844,7 +3843,7 @@ table verify_review_predictions {workspace_id [name: 'verify_review_predictions_workspace_id_idx'](provider, model) [name: 'verify_review_predictions_model_idx'](check_result_id, provider, model, prompt_version) [name: 'verify_review_predictions_result_model_prompt_unique', unique]-+}}@@ -3909,7 +3908,7 @@ table verify_runs {workspace_id [name: 'verify_runs_workspace_id_idx']acceptance_id [name: 'verify_runs_acceptance_id_idx'](acceptance_id, round_index) [name: 'verify_runs_acceptance_round_unique', unique]-+operation_id [name: 'verify_runs_operation_id_unique', unique]source [name: 'verify_runs_source_idx']user_decision [name: 'verify_runs_user_decision_idx']@@ -4214,4 +4213,4 @@ ref: topic_documents.document_id > documents.idref: topic_documents.topic_id > topics.id-ref: topics.session_id - sessions.id+ref: topics.session_id - sessions.id\ No newline at end of filediff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex 4e65b4cd0f8..c587f734220 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -519,7 +519,7 @@"goalProcess.kind.decision": "Decision","goalProcess.kind.finding": "Finding","goalProcess.kind.problem": "Question",- "goalProcess.kind.work": "Task",+ "goalProcess.kind.task": "Task","goalProcess.metrics.findings": "Findings","goalProcess.metrics.status": "Status","goalProcess.metrics.tasks": "Tasks",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex 6358687f908..a8edf5546ea 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -519,7 +519,7 @@"goalProcess.kind.decision": "决策","goalProcess.kind.finding": "结论","goalProcess.kind.problem": "问题",- "goalProcess.kind.work": "任务",+ "goalProcess.kind.task": "任务","goalProcess.metrics.findings": "结论","goalProcess.metrics.status": "状态","goalProcess.metrics.tasks": "任务",diff --git a/packages/agent-tracing/src/goal/__tests__/delta.test.ts b/packages/agent-tracing/src/goal/__tests__/delta.test.tsnew file mode 100644index 00000000000..8ee622ac95d--- /dev/null+++ b/packages/agent-tracing/src/goal/__tests__/delta.test.ts@@ -0,0 +1,148 @@+import { describe, expect, it } from 'vitest';++import { applyGraphDelta, buildGraphShape, computeGraphDelta, reconstructGraphAt } from '../delta';+import type { GoalTickSnapshot, GoalTrajectory } from '../types';+import { edge, graph, node } from './fixtures';++describe('computeGraphDelta', () => {+ it('returns undefined when nothing moved', () => {+ const state = graph({ nodes: [node('a')] });+ expect(computeGraphDelta(state, { ...state, nodes: [node('a')] })).toBeUndefined();+ });++ it('emits only the entities that changed', () => {+ const before = graph({ nodes: [node('a'), node('b')] });+ const after = graph({+ nodes: [node('a'), node('b', { status: 'resolved' })],+ });++ expect(computeGraphDelta(before, after)).toEqual({+ nodesUpserted: [node('b', { status: 'resolved' })],+ });+ });++ it('records removals and goal-level changes', () => {+ const before = graph({ edges: [edge('e1', 'a', 'b')], nodes: [node('a')] });+ const after = graph({ goal: { ...before.goal, status: 'achieved' }, nodes: [] });++ expect(computeGraphDelta(before, after)).toEqual({+ edgesRemoved: ['e1'],+ goal: { status: 'achieved' },+ nodesRemoved: ['a'],+ });+ });+});++describe('applyGraphDelta', () => {+ it('round-trips a diff', () => {+ const before = graph({ nodes: [node('a')] });+ const after = graph({+ edges: [edge('e1', 'a', 'b')],+ nodes: [node('a', { status: 'active' }), node('b')],+ });++ expect(applyGraphDelta(before, computeGraphDelta(before, after))).toEqual(after);+ });++ it('leaves the input untouched', () => {+ const before = graph({ nodes: [node('a')] });+ applyGraphDelta(before, { nodesUpserted: [node('b')] });+ expect(before.nodes).toHaveLength(1);+ });+});++const tick = (index: number, overrides: Partial<GoalTickSnapshot> = {}): GoalTickSnapshot => ({+ at: 0,+ branch: 'dispatch_task',+ budget: { costLimitReached: false, roundLimitReached: false, runs: 0, totalCost: 0 },+ candidates: [],+ effects: [],+ graphShape: {+ edgesTotal: 0,+ findings: 0,+ gatesPending: 0,+ nodesTotal: 0,+ tasksBlocked: 0,+ tasksOpen: 0,+ tasksReady: 0,+ tasksCompleted: 0,+ },+ index,+ message: '',+ outcome: 'advanced',+ ...overrides,+});++describe('reconstructGraphAt', () => {+ it('replays the state the coordinator read entering a tick', () => {+ const trajectory = {+ advances: [+ {+ completedAt: 2,+ durationMs: 2,+ seq: 0,+ startedAt: 0,+ ticks: [+ tick(0),+ tick(1, { graphDelta: { nodesUpserted: [node('a', { status: 'active' })] } }),+ ],+ trigger: 'create' as const,+ },+ {+ completedAt: 4,+ durationMs: 1,+ seq: 1,+ startedAt: 3,+ ticks: [tick(0, { graphDelta: { nodesUpserted: [node('a', { status: 'resolved' })] } })],+ trigger: 'settle' as const,+ },+ ],+ goalId: 'goal_1',+ graphBaseline: graph({ nodes: [node('a')] }),+ startedAt: 0,+ title: 'Reproduce nanoGPT',+ totalAdvances: 2,+ totalTicks: 3,+ traceId: 'goal_1',+ } satisfies GoalTrajectory;++ expect(reconstructGraphAt(trajectory, 0, 0).nodes[0].status).toBe('proposed');+ expect(reconstructGraphAt(trajectory, 0, 1).nodes[0].status).toBe('active');+ expect(reconstructGraphAt(trajectory, 1, 0).nodes[0].status).toBe('resolved');+ });+});++describe('buildGraphShape', () => {+ it('splits open work into ready and blocked by unresolved dependencies', () => {+ const state = graph({+ edges: [edge('e1', 'b', 'a')],+ nodes: [+ node('a', { status: 'active' }),+ node('b'),+ node('c', { kind: 'finding', status: 'resolved' }),+ ],+ });++ expect(buildGraphShape(state)).toMatchObject({+ findings: 1,+ nodesTotal: 3,+ tasksBlocked: 1,+ tasksOpen: 2,+ tasksReady: 1,+ tasksCompleted: 0,+ });+ });++ it('counts work ready once its dependency resolves', () => {+ const state = graph({+ edges: [edge('e1', 'b', 'a')],+ nodes: [node('a', { status: 'resolved' }), node('b')],+ });++ expect(buildGraphShape(state)).toMatchObject({+ tasksBlocked: 0,+ tasksReady: 1,+ tasksCompleted: 1,+ });+ });+});diff --git a/packages/agent-tracing/src/goal/__tests__/fileStore.test.ts b/packages/agent-tracing/src/goal/__tests__/fileStore.test.tsnew file mode 100644index 00000000000..a63763b953c--- /dev/null+++ b/packages/agent-tracing/src/goal/__tests__/fileStore.test.ts@@ -0,0 +1,68 @@+import fs from 'node:fs/promises';+import os from 'node:os';+import path from 'node:path';++import { afterEach, beforeEach, describe, expect, it } from 'vitest';++import { FileGoalTraceStore } from '../store/file-store';+import type { GoalTrajectory } from '../types';+import { graph, node } from './fixtures';++const trajectory = (goalId: string, title: string): GoalTrajectory => ({+ advances: [],+ goalId,+ graphBaseline: graph({ nodes: [node('a')] }),+ startedAt: 0,+ title,+ totalAdvances: 0,+ totalTicks: 0,+ traceId: goalId,+});++describe('FileGoalTraceStore.list', () => {+ let rootDir: string;+ let store: FileGoalTraceStore;++ beforeEach(async () => {+ rootDir = await fs.mkdtemp(path.join(os.tmpdir(), 'goal-store-'));+ store = new FileGoalTraceStore(rootDir);+ });++ afterEach(async () => {+ await fs.rm(rootDir, { force: true, recursive: true });+ });++ it('lists goals that are still running, not only finished ones', async () => {+ // A long-horizon goal is a partial for nearly all of its life, so a listing+ // that showed only finalized objects would report an empty directory on a+ // machine that is actively running goals.+ await store.savePartial('goal_running', {+ advances: [],+ goalId: 'goal_running',+ startedAt: 5,+ title: 'Still going',+ });++ expect(await store.list()).toMatchObject([+ { completionReason: undefined, goalId: 'goal_running', title: 'Still going' },+ ]);+ });++ it('shows a goal once when a stale partial outlived its finalized object', async () => {+ await store.savePartial('goal_1', { advances: [], goalId: 'goal_1', title: 'Partial copy' });+ await store.save({ ...trajectory('goal_1', 'Finalized copy'), completionReason: 'achieved' });++ const listed = await store.list();++ expect(listed).toHaveLength(1);+ expect(listed[0]).toMatchObject({ completionReason: 'achieved', title: 'Finalized copy' });+ });++ it('applies the limit across both kinds', async () => {+ await store.save(trajectory('goal_done', 'Done'));+ await store.savePartial('goal_open', { advances: [], goalId: 'goal_open', title: 'Open' });++ expect(await store.list({ limit: 1 })).toHaveLength(1);+ expect(await store.list()).toHaveLength(2);+ });+});diff --git a/packages/agent-tracing/src/goal/__tests__/fixtures.ts b/packages/agent-tracing/src/goal/__tests__/fixtures.tsnew file mode 100644index 00000000000..2bf957a5fd6--- /dev/null+++ b/packages/agent-tracing/src/goal/__tests__/fixtures.ts@@ -0,0 +1,32 @@+import type { GoalGraphState, GoalTraceEdge, GoalTraceNode } from '../types';++export const node = (id: string, overrides: Partial<GoalTraceNode> = {}): GoalTraceNode => ({+ createdAt: 1000,+ id,+ kind: 'work',+ priority: 0,+ status: 'proposed',+ title: id,+ ...overrides,+});++export const edge = (+ id: string,+ sourceNodeId: string,+ targetNodeId: string,+ kind = 'depends_on',+): GoalTraceEdge => ({ id, kind, sourceNodeId, targetNodeId });++export const graph = (overrides: Partial<GoalGraphState> = {}): GoalGraphState => ({+ decisions: [],+ edges: [],+ goal: {+ id: 'goal_1',+ maxRounds: null,+ maxTotalCost: null,+ status: 'running',+ title: 'Reproduce nanoGPT',+ },+ nodes: [],+ ...overrides,+});diff --git a/packages/agent-tracing/src/goal/__tests__/loadTrajectory.test.ts b/packages/agent-tracing/src/goal/__tests__/loadTrajectory.test.tsnew file mode 100644index 00000000000..531b698235a--- /dev/null+++ b/packages/agent-tracing/src/goal/__tests__/loadTrajectory.test.ts@@ -0,0 +1,89 @@+import fs from 'node:fs/promises';+import os from 'node:os';+import path from 'node:path';++import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import { FileGoalTraceStore } from '../store/file-store';+import { loadGoalTrajectory } from '../store/loadTrajectory';+import type { GoalTrajectory } from '../types';+import { graph, node } from './fixtures';++const trajectory = (goalId: string): GoalTrajectory => ({+ advances: [],+ goalId,+ graphBaseline: graph({ nodes: [node('a')] }),+ startedAt: 0,+ title: 'Reproduce nanoGPT',+ totalAdvances: 0,+ totalTicks: 0,+ traceId: goalId,+});++describe('loadGoalTrajectory', () => {+ let rootDir: string;++ beforeEach(async () => {+ rootDir = await fs.mkdtemp(path.join(os.tmpdir(), 'goal-trace-'));+ });++ afterEach(async () => {+ await fs.rm(rootDir, { force: true, recursive: true });+ });++ it('reads a local trajectory without asking the server', async () => {+ await new FileGoalTraceStore(rootDir).save(trajectory('goal_1'));+ const resolveDownloadUrl = vi.fn();++ const loaded = await loadGoalTrajectory('goal_1', {+ allowDownload: true,+ resolveDownloadUrl,+ rootDir,+ });++ expect(loaded?.goalId).toBe('goal_1');+ expect(resolveDownloadUrl).not.toHaveBeenCalled();+ });++ it('serves an in-flight goal from its partial', async () => {+ await new FileGoalTraceStore(rootDir).savePartial('goal_2', {+ advances: [],+ goalId: 'goal_2',+ startedAt: 5,+ title: 'Still running',+ });++ const loaded = await loadGoalTrajectory('goal_2', { rootDir });++ expect(loaded).toMatchObject({ goalId: 'goal_2', title: 'Still running' });+ });++ it('does not reach the network unless downloading is allowed', async () => {+ const resolveDownloadUrl = vi.fn();++ expect(+ await loadGoalTrajectory('goal_missing', { resolveDownloadUrl, rootDir }),+ ).toBeUndefined();+ expect(resolveDownloadUrl).not.toHaveBeenCalled();+ });++ it('gives up quietly when the server has nothing to sign', async () => {+ const resolveDownloadUrl = vi.fn().mockResolvedValue(null);++ const loaded = await loadGoalTrajectory('goal_missing', {+ allowDownload: true,+ resolveDownloadUrl,+ rootDir,+ });++ expect(loaded).toBeUndefined();+ expect(resolveDownloadUrl).toHaveBeenCalledWith('goal_missing');+ });++ it('reads a trajectory straight off a json path', async () => {+ const filePath = path.join(rootDir, 'exported.json');+ await fs.writeFile(filePath, JSON.stringify(trajectory('goal_3')), 'utf8');++ expect((await loadGoalTrajectory(filePath))?.goalId).toBe('goal_3');+ });+});diff --git a/packages/agent-tracing/src/goal/__tests__/recorder.test.ts b/packages/agent-tracing/src/goal/__tests__/recorder.test.tsnew file mode 100644index 00000000000..b1df17a1389--- /dev/null+++ b/packages/agent-tracing/src/goal/__tests__/recorder.test.ts@@ -0,0 +1,170 @@+import { beforeEach, describe, expect, it } from 'vitest';++import { appendAdvanceToPartial, finalizeGoalTrace, type RecordTickInput } from '../recorder';+import type { IGoalTraceStore } from '../store/types';+import type { GoalGraphState, GoalTraceSummary, GoalTrajectory } from '../types';+import { graph, node } from './fixtures';++class MemoryStore implements IGoalTraceStore {+ partials = new Map<string, Partial<GoalTrajectory>>();+ saved = new Map<string, GoalTrajectory>();++ async get(goalId: string) {+ return this.saved.get(goalId) ?? null;+ }+ async list(): Promise<GoalTraceSummary[]> {+ return [];+ }+ async listPartials() {+ return [...this.partials.keys()];+ }+ async loadPartial(goalId: string) {+ return this.partials.get(goalId) ?? null;+ }+ async removePartial(goalId: string) {+ this.partials.delete(goalId);+ }+ async save(trajectory: GoalTrajectory) {+ this.saved.set(trajectory.goalId, trajectory);+ }+ async savePartial(goalId: string, partial: Partial<GoalTrajectory>) {+ this.partials.set(goalId, partial);+ }+}++const tick = (graphState: GoalGraphState, at = 0): RecordTickInput => ({+ at,+ branch: 'dispatch_task',+ budget: { costLimitReached: false, roundLimitReached: false, runs: 0, totalCost: 0 },+ candidates: [],+ effects: [],+ graphState,+ message: 'ok',+ outcome: 'advanced',+});++describe('appendAdvanceToPartial', () => {+ let store: MemoryStore;++ beforeEach(() => {+ store = new MemoryStore();+ });++ it('seeds the baseline from the first tick and leaves its delta empty', async () => {+ const state = graph({ nodes: [node('a')] });++ const trajectory = await appendAdvanceToPartial(store, 'goal_1', {+ startedAt: 0,+ ticks: [tick(state)],+ trigger: 'create',+ });+ const advance = trajectory?.advances.at(-1);++ expect(advance?.seq).toBe(0);+ expect(advance?.ticks[0].graphDelta).toBeUndefined();+ expect(store.partials.get('goal_1')?.graphBaseline).toEqual(state);+ });++ it('diffs each tick against the previous recorded state, across advances', async () => {+ const first = graph({ nodes: [node('a')] });+ const second = graph({ nodes: [node('a', { status: 'active' })] });+ const third = graph({ nodes: [node('a', { status: 'resolved' })] });++ await appendAdvanceToPartial(store, 'goal_1', {+ startedAt: 0,+ ticks: [tick(first), tick(second)],+ trigger: 'create',+ });+ const next = (+ await appendAdvanceToPartial(store, 'goal_1', {+ startedAt: 5,+ ticks: [tick(third)],+ trigger: 'settle',+ })+ )?.advances.at(-1);++ expect(next?.seq).toBe(1);+ expect(next?.ticks[0].graphDelta).toEqual({+ nodesUpserted: [node('a', { status: 'resolved' })],+ });+ });++ it('captures a graph edit made between two advances', async () => {+ await appendAdvanceToPartial(store, 'goal_1', {+ startedAt: 0,+ ticks: [tick(graph({ nodes: [node('a')] }))],+ trigger: 'create',+ });++ // A work node added from the UI, with no advance in between.+ const withExtra = graph({ nodes: [node('a'), node('b')] });+ const next = (+ await appendAdvanceToPartial(store, 'goal_1', {+ startedAt: 5,+ ticks: [tick(withExtra)],+ trigger: 'manual',+ })+ )?.advances.at(-1);++ expect(next?.ticks[0].graphDelta).toEqual({ nodesUpserted: [node('b')] });+ });++ it('records nothing for an advance that ran no ticks', async () => {+ expect(+ await appendAdvanceToPartial(store, 'goal_1', {+ startedAt: 0,+ ticks: [],+ trigger: 'sweep',+ }),+ ).toBeNull();+ expect(store.partials.size).toBe(0);+ });++ it('computes shape per tick', async () => {+ const advance = (+ await appendAdvanceToPartial(store, 'goal_1', {+ startedAt: 0,+ ticks: [tick(graph({ nodes: [node('a'), node('b', { kind: 'finding' })] }))],+ trigger: 'create',+ })+ )?.advances.at(-1);++ expect(advance?.ticks[0].graphShape).toMatchObject({+ findings: 1,+ nodesTotal: 2,+ tasksOpen: 1,+ });+ });+});++describe('finalizeGoalTrace', () => {+ it('moves the partial into a finalized trajectory', async () => {+ const store = new MemoryStore();+ await appendAdvanceToPartial(store, 'goal_1', {+ startedAt: 0,+ ticks: [tick(graph({ nodes: [node('a')] }))],+ trigger: 'create',+ });++ const trajectory = await finalizeGoalTrace(store, 'goal_1', {+ completedAt: 99,+ completionReason: 'achieved',+ });++ expect(trajectory).toMatchObject({+ completedAt: 99,+ completionReason: 'achieved',+ goalId: 'goal_1',+ totalAdvances: 1,+ totalTicks: 1,+ });+ expect(store.partials.size).toBe(0);+ expect(await store.get('goal_1')).not.toBeNull();+ });++ it('is a no-op when the goal never recorded anything', async () => {+ expect(+ await finalizeGoalTrace(new MemoryStore(), 'goal_x', { completionReason: 'failed' }),+ ).toBeNull();+ });+});diff --git a/packages/agent-tracing/src/goal/__tests__/replay.test.ts b/packages/agent-tracing/src/goal/__tests__/replay.test.tsnew file mode 100644index 00000000000..f9eb487ead8--- /dev/null+++ b/packages/agent-tracing/src/goal/__tests__/replay.test.ts@@ -0,0 +1,147 @@+import { describe, expect, it } from 'vitest';++import { type GoalDecider, replayGoalTrajectory } from '../replay';+import type { GoalTickSnapshot, GoalTrajectory } from '../types';+import { graph, node } from './fixtures';++const tick = (overrides: Partial<GoalTickSnapshot> = {}): GoalTickSnapshot => ({+ at: 1000,+ branch: 'dispatch_task',+ budget: { costLimitReached: false, roundLimitReached: false, runs: 0, totalCost: 0 },+ candidates: [+ { blockedBy: [], nodeId: 'a', priority: 1, status: 'proposed', title: 'a' },+ { blockedBy: [], nodeId: 'b', priority: 0, status: 'proposed', title: 'b' },+ ],+ chosenNodeId: 'a',+ effects: [],+ graphShape: {+ edgesTotal: 0,+ findings: 0,+ gatesPending: 0,+ nodesTotal: 2,+ tasksBlocked: 0,+ tasksOpen: 2,+ tasksReady: 2,+ tasksCompleted: 0,+ },+ index: 0,+ message: '',+ outcome: 'advanced',+ ...overrides,+});++const trajectory: GoalTrajectory = {+ advances: [+ {+ completedAt: 5,+ durationMs: 5,+ seq: 0,+ startedAt: 0,+ ticks: [tick()],+ trigger: 'create',+ },+ ],+ goalId: 'goal_1',+ graphBaseline: graph({ nodes: [node('a', { priority: 1 }), node('b')] }),+ startedAt: 0,+ title: 'Reproduce nanoGPT',+ totalAdvances: 1,+ totalTicks: 1,+ traceId: 'goal_1',+};++/** Ranks the same way the recorded run did: priority desc, then creation order. */+const faithful: GoalDecider = ({ graph: state }) => {+ const candidates = state.nodes+ .filter((item) => item.kind === 'work')+ .sort((a, b) => b.priority - a.priority || a.createdAt - b.createdAt)+ .map((item) => ({+ blockedBy: [],+ nodeId: item.id,+ priority: item.priority,+ status: item.status,+ title: item.title,+ }));++ return { branch: 'dispatch_task', candidates, chosenNodeId: candidates[0]?.nodeId };+};++describe('replayGoalTrajectory', () => {+ it('reports no divergence when the decider still decides the same way', () => {+ expect(replayGoalTrajectory(trajectory, faithful)).toMatchObject({+ divergences: [],+ matched: 1,+ ticks: 1,+ });+ });++ it('flags a reordered frontier as a candidates divergence', () => {+ const reversed: GoalDecider = (input) => {+ const decision = faithful(input);+ return { ...decision, candidates: [...decision.candidates].reverse() };+ };++ const result = replayGoalTrajectory(trajectory, reversed);++ expect(result.matched).toBe(0);+ expect(result.divergences).toEqual([+ { advanceSeq: 0, field: 'candidates', recorded: 'a,b', replayed: 'b,a', tickIndex: 0 },+ ]);+ });++ it('ignores the outcome, which the branch produces rather than decides', () => {+ const result = replayGoalTrajectory(+ {+ ...trajectory,+ advances: [+ {+ ...trajectory.advances[0],+ ticks: [tick({ outcome: 'waiting_human' })],+ },+ ],+ },+ faithful,+ );++ expect(result.divergences).toEqual([]);+ });++ it('flags a changed branch and a changed choice separately', () => {+ const different: GoalDecider = (input) => ({+ ...faithful(input),+ branch: 'budget_exhausted',+ chosenNodeId: 'b',+ });++ expect(+ replayGoalTrajectory(trajectory, different).divergences.map((item) => item.field),+ ).toEqual(['branch', 'chosenNodeId']);+ });++ it('feeds the decider the graph as it was entering the tick, not the final one', () => {+ const seen: string[] = [];+ replayGoalTrajectory(+ {+ ...trajectory,+ advances: [+ {+ ...trajectory.advances[0],+ ticks: [+ tick(),+ tick({+ graphDelta: { nodesUpserted: [node('c')] },+ index: 1,+ }),+ ],+ },+ ],+ },+ (input) => {+ seen.push(input.graph.nodes.map((item) => item.id).join(','));+ return faithful(input);+ },+ );++ expect(seen).toEqual(['a,b', 'a,b,c']);+ });+});diff --git a/packages/agent-tracing/src/goal/__tests__/rollup.test.ts b/packages/agent-tracing/src/goal/__tests__/rollup.test.tsnew file mode 100644index 00000000000..cddc1cc867a--- /dev/null+++ b/packages/agent-tracing/src/goal/__tests__/rollup.test.ts@@ -0,0 +1,155 @@+import { describe, expect, it } from 'vitest';++import { buildGoalTraceRollup } from '../rollup';+import type {+ GoalAdvanceSnapshot,+ GoalAdvanceTrigger,+ GoalTickSnapshot,+ GoalTrajectory,+} from '../types';+import { graph, node } from './fixtures';++const tick = (overrides: Partial<GoalTickSnapshot> = {}): GoalTickSnapshot => ({+ at: 0,+ branch: 'dispatch_task',+ budget: { costLimitReached: false, roundLimitReached: false, runs: 0, totalCost: 0 },+ candidates: [],+ effects: [],+ graphShape: {+ edgesTotal: 0,+ findings: 0,+ gatesPending: 0,+ nodesTotal: 0,+ tasksBlocked: 0,+ tasksOpen: 0,+ tasksReady: 0,+ tasksCompleted: 0,+ },+ index: 0,+ message: '',+ outcome: 'advanced',+ ...overrides,+});++const advance = (+ seq: number,+ trigger: GoalAdvanceTrigger,+ overrides: Partial<GoalAdvanceSnapshot> = {},+): GoalAdvanceSnapshot => ({+ completedAt: seq * 10 + 5,+ durationMs: 5,+ seq,+ startedAt: seq * 10,+ ticks: [tick()],+ trigger,+ ...overrides,+});++const trajectory = (advances: GoalAdvanceSnapshot[]): GoalTrajectory => ({+ advances,+ goalId: 'goal_1',+ graphBaseline: graph({ nodes: [node('a')] }),+ startedAt: 0,+ title: 'Reproduce nanoGPT',+ totalAdvances: advances.length,+ totalTicks: advances.reduce((sum, item) => sum + item.ticks.length, 0),+ traceId: 'goal_1',+});++describe('buildGoalTraceRollup', () => {+ it('buckets advances by trigger and by the outcome each stopped on', () => {+ const rollup = buildGoalTraceRollup(+ trajectory([+ advance(0, 'create'),+ advance(1, 'sweep', { ticks: [tick(), tick({ index: 1, outcome: 'no_progress' })] }),+ advance(2, 'sweep', { ticks: [tick({ outcome: 'no_progress' })] }),+ ]),+ );++ expect(rollup.advancesByTrigger).toEqual({ create: 1, sweep: 2 });+ expect(rollup.advancesByOutcome).toEqual({ advanced: 1, no_progress: 2 });+ expect(rollup.ticksTotal).toBe(4);+ });++ it('dedupes child operations across advances', () => {+ // The same operation can be reported by the advance that started it and by+ // the one that consumed its result.+ const rollup = buildGoalTraceRollup(+ trajectory([+ advance(0, 'create', { childOperationIds: ['op_1', 'op_2'] }),+ advance(1, 'settle', { childOperationIds: ['op_2'] }),+ ]),+ );++ expect(rollup.operationsTotal).toBe(2);+ });++ it('counts a gate that a person answered between two advances', () => {+ // The resolving half is never an effect: `goal.decide` runs outside any+ // advance, so no tick is executing to report it. Both transitions are only+ // visible in the recorded graph.+ const gate = (status: string) => ({+ decisionsUpserted: [{ id: 'd1', nodeId: 'n1', question: 'Retry or retire?', status }],+ });++ const rollup = buildGoalTraceRollup(+ trajectory([+ advance(0, 'settle', {+ ticks: [tick({ at: 1000, graphDelta: gate('pending'), outcome: 'waiting_human' })],+ }),+ advance(1, 'decide', {+ ticks: [tick({ at: 4000, graphDelta: gate('resolved') })],+ }),+ ]),+ );++ expect(rollup).toMatchObject({ gatesOpened: 1, gatesResolved: 1, humanWaitingMs: 3000 });+ });++ it('leaves a still-open gate counted as opened and unresolved', () => {+ const rollup = buildGoalTraceRollup(+ trajectory([+ advance(0, 'settle', {+ ticks: [+ tick({+ at: 1000,+ graphDelta: {+ decisionsUpserted: [+ { id: 'd1', nodeId: 'n1', question: 'Retry?', status: 'pending' },+ ],+ },+ outcome: 'waiting_human',+ }),+ ],+ }),+ ]),+ );++ expect(rollup).toMatchObject({ gatesOpened: 1, gatesResolved: 0, humanWaitingMs: 0 });+ });++ it('does not count a gate from effects alone, which only cover half its life', () => {+ const rollup = buildGoalTraceRollup(+ trajectory([+ advance(0, 'sweep', { ticks: [tick({ effects: [{ type: 'opened_decision' }] })] }),+ ]),+ );++ expect(rollup).toMatchObject({ gatesOpened: 0, gatesResolved: 0 });+ });++ it('reads the final graph shape through the delta chain', () => {+ const rollup = buildGoalTraceRollup(+ trajectory([+ advance(0, 'create', {+ ticks: [+ tick({ graphDelta: { nodesUpserted: [node('a', { status: 'resolved' })] } }),+ tick({ index: 1, graphDelta: { nodesUpserted: [node('b', { kind: 'finding' })] } }),+ ],+ }),+ ]),+ );++ expect(rollup).toMatchObject({ findingsTotal: 1, nodesTotal: 2, tasksCompleted: 1 });+ });+});diff --git a/packages/agent-tracing/src/goal/__tests__/viewer.test.ts b/packages/agent-tracing/src/goal/__tests__/viewer.test.tsnew file mode 100644index 00000000000..4345716d5e1--- /dev/null+++ b/packages/agent-tracing/src/goal/__tests__/viewer.test.ts@@ -0,0 +1,118 @@+import { describe, expect, it } from 'vitest';++import type { GoalTickSnapshot, GoalTrajectory } from '../types';+import { renderGoalAdvanceDetail, renderGoalTrajectory } from '../viewer';+import { graph, node } from './fixtures';++const tick = (overrides: Partial<GoalTickSnapshot> = {}): GoalTickSnapshot => ({+ at: 0,+ branch: 'dispatch_task',+ candidates: [+ { blockedBy: [], nodeId: 'aaaaaaaa-1111', priority: 1, status: 'proposed', title: 'Clone' },+ {+ blockedBy: ['aaaaaaaa-1111'],+ nodeId: 'bbbbbbbb-2222',+ priority: 0,+ status: 'proposed',+ title: 'Train',+ },+ ],+ chosenNodeId: 'aaaaaaaa-1111',+ effects: [],+ graphShape: {+ edgesTotal: 1,+ findings: 0,+ gatesPending: 0,+ nodesTotal: 2,+ tasksBlocked: 1,+ tasksOpen: 2,+ tasksReady: 1,+ tasksCompleted: 0,+ },+ index: 0,+ message: 'Task T-31 is ready to run',+ outcome: 'waiting_external',+ ...overrides,+});++const trajectory: GoalTrajectory = {+ advances: [+ {+ childOperationIds: ['op_1'],+ completedAt: 2000,+ durationMs: 2000,+ seq: 0,+ startedAt: 0,+ ticks: [+ tick({+ budget: {+ costLimitReached: false,+ maxRounds: null,+ maxTotalCost: 5,+ roundLimitReached: false,+ runs: 0,+ totalCost: 0,+ },+ effects: [{ operationId: 'op_1', targetId: 'task_A', type: 'started_run' }],+ frontierTask: {+ error: null,+ id: 'task_A',+ identifier: 'T-31',+ status: 'backlog',+ updatedAt: 0,+ },+ }),+ ],+ trigger: 'create',+ },+ ],+ completedAt: 5000,+ completionReason: 'achieved',+ goalId: 'goal_1',+ graphBaseline: graph({ nodes: [node('aaaaaaaa-1111'), node('bbbbbbbb-2222')] }),+ startedAt: 0,+ title: 'Reproduce nanoGPT',+ totalAdvances: 1,+ totalTicks: 1,+ traceId: 'goal_1',+};++describe('renderGoalTrajectory', () => {+ it('leads with how the run ended and what drove it', () => {+ const output = renderGoalTrajectory(trajectory);++ expect(output).toContain('goal_1 Reproduce nanoGPT');+ expect(output).toContain('achieved');+ expect(output).toContain('by trigger: create=1');+ expect(output).toContain('1 operation(s)');+ });++ it('shows each advance with its ticks nested under it', () => {+ const output = renderGoalTrajectory(trajectory);++ expect(output).toContain('#0');+ expect(output).toContain('dispatch_task');+ expect(output).toContain('(+1 eligible)');+ });+});++describe('renderGoalAdvanceDetail', () => {+ it('shows the candidates that lost, not only the one that won', () => {+ const output = renderGoalAdvanceDetail(trajectory, 0);++ expect(output).toContain('▸ aaaaaaaa p1 proposed Clone');+ expect(output).toContain('bbbbbbbb p0 proposed Train blocked by aaaaaaaa');+ });++ it('shows the budget and task the decision was made against', () => {+ const output = renderGoalAdvanceDetail(trajectory, 0);++ expect(output).toContain('budget: rounds ∞ cost $0.0000/$5');+ expect(output).toContain('task: T-31 backlog');+ expect(output).toContain('effect: started_run task_A op=op_1');+ });++ it('says so rather than rendering an empty frame for an advance that is not there', () => {+ expect(renderGoalAdvanceDetail(trajectory, 9)).toBe('No advance #9 in goal_1');+ });+});diff --git a/packages/agent-tracing/src/goal/delta.ts b/packages/agent-tracing/src/goal/delta.tsnew file mode 100644index 00000000000..966032fdb58--- /dev/null+++ b/packages/agent-tracing/src/goal/delta.ts@@ -0,0 +1,176 @@+import type {+ GoalGraphDelta,+ GoalGraphShape,+ GoalGraphState,+ GoalTraceDecision,+ GoalTraceEdge,+ GoalTraceNode,+ GoalTrajectory,+} from './types';++const byId = <T extends { id: string }>(items: T[]): Map<string, T> =>+ new Map(items.map((item) => [item.id, item]));++const sameNode = (a: GoalTraceNode, b: GoalTraceNode): boolean =>+ a.kind === b.kind &&+ a.status === b.status &&+ a.title === b.title &&+ a.priority === b.priority &&+ (a.taskId ?? null) === (b.taskId ?? null) &&+ a.createdAt === b.createdAt;++const sameDecision = (a: GoalTraceDecision, b: GoalTraceDecision): boolean =>+ a.status === b.status &&+ a.question === b.question &&+ a.nodeId === b.nodeId &&+ (a.resolvedOptionId ?? null) === (b.resolvedOptionId ?? null);++const goalDelta = (+ previous: GoalGraphState['goal'],+ next: GoalGraphState['goal'],+): Partial<GoalGraphState['goal']> | undefined => {+ const changed: Partial<GoalGraphState['goal']> = {};+ for (const key of Object.keys(next) as (keyof GoalGraphState['goal'])[]) {+ if ((previous[key] ?? null) !== (next[key] ?? null)) {+ changed[key] = next[key] as never;+ }+ }+ return Object.keys(changed).length > 0 ? changed : undefined;+};++/**+ * Diff two graph states into the delta persisted on an advance.+ *+ * Only entities that actually moved are emitted. A goal that sits through a+ * sweep tick without changing produces an empty delta, which is what makes a+ * long-horizon trajectory cheap to keep in one object.+ */+export const computeGraphDelta = (+ previous: GoalGraphState,+ next: GoalGraphState,+): GoalGraphDelta | undefined => {+ const delta: GoalGraphDelta = {};++ const previousNodes = byId(previous.nodes);+ const nodesUpserted = next.nodes.filter((node) => {+ const before = previousNodes.get(node.id);+ return !before || !sameNode(before, node);+ });+ if (nodesUpserted.length > 0) delta.nodesUpserted = nodesUpserted;++ const nextNodeIds = new Set(next.nodes.map((node) => node.id));+ const nodesRemoved = previous.nodes+ .filter((node) => !nextNodeIds.has(node.id))+ .map((node) => node.id);+ if (nodesRemoved.length > 0) delta.nodesRemoved = nodesRemoved;++ const previousEdgeIds = new Set(previous.edges.map((edge) => edge.id));+ const edgesAdded = next.edges.filter((edge) => !previousEdgeIds.has(edge.id));+ if (edgesAdded.length > 0) delta.edgesAdded = edgesAdded;++ const nextEdgeIds = new Set(next.edges.map((edge) => edge.id));+ const edgesRemoved = previous.edges+ .filter((edge) => !nextEdgeIds.has(edge.id))+ .map((edge) => edge.id);+ if (edgesRemoved.length > 0) delta.edgesRemoved = edgesRemoved;++ const previousDecisions = byId(previous.decisions);+ const decisionsUpserted = next.decisions.filter((decision) => {+ const before = previousDecisions.get(decision.id);+ return !before || !sameDecision(before, decision);+ });+ if (decisionsUpserted.length > 0) delta.decisionsUpserted = decisionsUpserted;++ const goal = goalDelta(previous.goal, next.goal);+ if (goal) delta.goal = goal;++ return Object.keys(delta).length > 0 ? delta : undefined;+};++const upsert = <T extends { id: string }>(items: T[], incoming: T[] | undefined): T[] => {+ if (!incoming?.length) return items;+ const merged = byId(items);+ for (const item of incoming) merged.set(item.id, item);+ return [...merged.values()];+};++const remove = <T extends { id: string }>(items: T[], removed: string[] | undefined): T[] => {+ if (!removed?.length) return items;+ const gone = new Set(removed);+ return items.filter((item) => !gone.has(item.id));+};++/** Fold one delta onto a state. Pure — never mutates the input. */+export const applyGraphDelta = (state: GoalGraphState, delta?: GoalGraphDelta): GoalGraphState => {+ if (!delta) return state;++ const nodes = remove(upsert(state.nodes, delta.nodesUpserted), delta.nodesRemoved);+ const edges = remove(upsert<GoalTraceEdge>(state.edges, delta.edgesAdded), delta.edgesRemoved);++ return {+ decisions: upsert(state.decisions, delta.decisionsUpserted),+ edges,+ goal: delta.goal ? { ...state.goal, ...delta.goal } : state.goal,+ nodes,+ };+};++/**+ * The graph the coordinator read entering a given tick.+ *+ * Deltas are stored per tick as "what changed since the previous recorded+ * state", so folding the baseline through every tick up to and including the+ * target reproduces its decision input exactly — the same walk+ * `reconstructMessages` does over `messagesDelta`.+ */+export const reconstructGraphAt = (+ trajectory: GoalTrajectory,+ advanceSeq: number,+ tickIndex = 0,+): GoalGraphState => {+ let state = trajectory.graphBaseline;+ for (const advance of trajectory.advances) {+ if (advance.seq > advanceSeq) break;+ for (const tick of advance.ticks) {+ if (advance.seq === advanceSeq && tick.index > tickIndex) return state;+ state = applyGraphDelta(state, tick.graphDelta);+ }+ }+ return state;+};++/** Final graph state after every recorded tick. */+export const reconstructFinalGraph = (trajectory: GoalTrajectory): GoalGraphState =>+ trajectory.advances.reduce(+ (state, advance) =>+ advance.ticks.reduce((inner, tick) => applyGraphDelta(inner, tick.graphDelta), state),+ trajectory.graphBaseline,+ );++const TERMINAL_NODE_STATUSES = new Set(['resolved', 'rejected', 'retired']);++/** Cheap shape metrics for one graph state. */+export const buildGraphShape = (state: GoalGraphState): GoalGraphShape => {+ const resolvedNodeIds = new Set(+ state.nodes.filter((node) => node.status === 'resolved').map((node) => node.id),+ );+ const work = state.nodes.filter((node) => node.kind === 'work');+ const open = work.filter((node) => !TERMINAL_NODE_STATUSES.has(node.status));++ const ready = open.filter((node) =>+ state.edges+ .filter((edge) => edge.kind === 'depends_on' && edge.sourceNodeId === node.id)+ .every((edge) => resolvedNodeIds.has(edge.targetNodeId)),+ );++ return {+ edgesTotal: state.edges.length,+ findings: state.nodes.filter((node) => node.kind === 'finding').length,+ gatesPending: state.decisions.filter((decision) => decision.status === 'pending').length,+ nodesTotal: state.nodes.length,+ tasksBlocked: open.length - ready.length,+ tasksOpen: open.length,+ tasksReady: ready.length,+ tasksCompleted: work.filter((node) => node.status === 'resolved').length,+ };+};diff --git a/packages/agent-tracing/src/goal/index.ts b/packages/agent-tracing/src/goal/index.tsnew file mode 100644index 00000000000..e6f6b191555--- /dev/null+++ b/packages/agent-tracing/src/goal/index.ts@@ -0,0 +1,49 @@+export {+ applyGraphDelta,+ buildGraphShape,+ computeGraphDelta,+ reconstructFinalGraph,+ reconstructGraphAt,+} from './delta';+export {+ appendAdvanceToPartial,+ finalizeGoalTrace,+ type FinalizeGoalTraceInput,+ type RecordAdvanceInput,+ type RecordTickInput,+} from './recorder';+export {+ type GoalDecider,+ type GoalDecision,+ type GoalDecisionInput,+ type GoalReplayDivergence,+ type GoalReplayResult,+ replayGoalTrajectory,+} from './replay';+export { buildGoalTraceRollup, type GoalTraceRollup } from './rollup';+export { FileGoalTraceStore } from './store/file-store';+export { loadGoalTrajectory, type LoadGoalTrajectoryOptions } from './store/loadTrajectory';+export { RemoteGoalTraceStore } from './store/remote-store';+export type { IGoalTraceStore } from './store/types';+export type {+ FrontierCandidate,+ GoalAdvanceEffect,+ GoalAdvanceSnapshot,+ GoalAdvanceTrigger,+ GoalBudgetState,+ GoalEffectType,+ GoalFrontierTaskState,+ GoalGraphDelta,+ GoalGraphShape,+ GoalGraphState,+ GoalTickBranch,+ GoalTickOutcome,+ GoalTickSnapshot,+ GoalTraceDecision,+ GoalTraceEdge,+ GoalTraceGoal,+ GoalTraceNode,+ GoalTraceSummary,+ GoalTrajectory,+} from './types';+export { renderGoalAdvanceDetail, renderGoalTrajectory } from './viewer';diff --git a/packages/agent-tracing/src/goal/recorder.ts b/packages/agent-tracing/src/goal/recorder.tsnew file mode 100644index 00000000000..c84416ae4e7--- /dev/null+++ b/packages/agent-tracing/src/goal/recorder.ts@@ -0,0 +1,128 @@+import { buildGraphShape, computeGraphDelta, reconstructFinalGraph } from './delta';+import { partialToTrajectory } from './store/file-store';+import type { IGoalTraceStore } from './store/types';+import type {+ GoalAdvanceSnapshot,+ GoalAdvanceTrigger,+ GoalGraphState,+ GoalTickSnapshot,+ GoalTrajectory,+} from './types';++/**+ * One tick as the coordinator reports it. `graphState` is the full graph it+ * read on entry; the recorder turns consecutive states into the stored deltas,+ * so callers never have to remember what the previous tick saw.+ */+export interface RecordTickInput extends Omit<+ GoalTickSnapshot,+ 'graphDelta' | 'graphShape' | 'index'+> {+ graphState: GoalGraphState;+}++export interface RecordAdvanceInput {+ childOperationIds?: string[];+ completedAt?: number;+ error?: { message: string; type: string };+ startedAt: number;+ ticks: RecordTickInput[];+ trigger: GoalAdvanceTrigger;+}++/**+ * Append one advance to a goal's in-progress trajectory.+ *+ * Deltas are computed here rather than by the caller because advances run in+ * separate processes — a QStash worker holds no memory of the previous one. The+ * partial is the only place the prior state exists, so folding it forward is+ * also what keeps a graph edit made outside an advance (a work node added from+ * the UI between two advances) inside the trace instead of vanishing between+ * two states.+ */+export const appendAdvanceToPartial = async (+ store: IGoalTraceStore,+ goalId: string,+ input: RecordAdvanceInput,+): Promise<GoalTrajectory | null> => {+ if (input.ticks.length === 0) return null;++ const partial = (await store.loadPartial(goalId)) ?? {};+ const advances = partial.advances ?? [];+ const baseline = partial.graphBaseline ?? input.ticks[0].graphState;++ let previousState: GoalGraphState = partial.graphBaseline+ ? reconstructFinalGraph(partialToTrajectory(goalId, partial))+ : baseline;++ const ticks: GoalTickSnapshot[] = input.ticks.map((tick, index) => {+ const { graphState, ...rest } = tick;+ const snapshot: GoalTickSnapshot = {+ ...rest,+ graphDelta: computeGraphDelta(previousState, graphState),+ graphShape: buildGraphShape(graphState),+ index,+ };+ previousState = graphState;+ return snapshot;+ });++ const completedAt = input.completedAt ?? Date.now();+ const advance: GoalAdvanceSnapshot = {+ childOperationIds: input.childOperationIds?.length ? input.childOperationIds : undefined,+ completedAt,+ durationMs: completedAt - input.startedAt,+ error: input.error,+ seq: advances.length,+ startedAt: input.startedAt,+ ticks,+ trigger: input.trigger,+ };++ const updated: Partial<GoalTrajectory> = {+ ...partial,+ advances: [...advances, advance],+ goalId,+ graphBaseline: baseline,+ startedAt: partial.startedAt ?? input.startedAt,+ title: partial.title ?? previousState.goal.title,+ traceId: partial.traceId ?? goalId,+ };+ await store.savePartial(goalId, updated);++ // Returned whole rather than as the appended advance alone: the caller needs+ // the accumulated run to derive the observation row, and re-reading the+ // object it just wrote would cost another round trip to storage.+ return partialToTrajectory(goalId, updated);+};++export interface FinalizeGoalTraceInput {+ completedAt?: number;+ completionReason: string;+}++/**+ * Promote the partial into the finalized trajectory.+ *+ * Called when the goal reaches a terminal status. A goal that never terminates+ * keeps its partial, which `get()` still serves — an unfinished long-horizon+ * goal is the normal thing to inspect, not an error.+ */+export const finalizeGoalTrace = async (+ store: IGoalTraceStore,+ goalId: string,+ input: FinalizeGoalTraceInput,+): Promise<GoalTrajectory | null> => {+ const partial = await store.loadPartial(goalId);+ if (!partial) return null;++ const trajectory: GoalTrajectory = {+ ...partialToTrajectory(goalId, partial),+ completedAt: input.completedAt ?? Date.now(),+ completionReason: input.completionReason,+ };++ await store.save(trajectory);+ await store.removePartial(goalId);+ return trajectory;+};diff --git a/packages/agent-tracing/src/goal/replay.ts b/packages/agent-tracing/src/goal/replay.tsnew file mode 100644index 00000000000..4e80252032e--- /dev/null+++ b/packages/agent-tracing/src/goal/replay.ts@@ -0,0 +1,112 @@+import { reconstructGraphAt } from './delta';+import type {+ FrontierCandidate,+ GoalBudgetState,+ GoalFrontierTaskState,+ GoalGraphState,+ GoalTickBranch,+ GoalTrajectory,+} from './types';++/**+ * Everything the coordinator's decision depends on. Anything not in here must+ * not change what it picks, or the trace is not a replayable record.+ */+export interface GoalDecisionInput {+ budget?: GoalBudgetState;+ /** State of the chosen work node's responsible task, when it already has one. */+ frontierTask?: GoalFrontierTaskState;+ graph: GoalGraphState;+ now: number;+}++/**+ * What the coordinator *chose*. Deliberately excludes the outcome: a branch+ * like `recover_lease` reports `waiting_external` or `waiting_human` depending+ * on whether recovery still had budget, and that is the result of running the+ * branch rather than part of the decision. Comparing it would flag work the+ * decider was never asked to do.+ */+export interface GoalDecision {+ branch: GoalTickBranch;+ /** Every eligible work node, in the order the coordinator ranked them. */+ candidates: FrontierCandidate[];+ chosenNodeId?: string;+}++export type GoalDecider = (input: GoalDecisionInput) => GoalDecision;++export interface GoalReplayDivergence {+ advanceSeq: number;+ field: 'branch' | 'chosenNodeId' | 'candidates';+ recorded: string;+ replayed: string;+ tickIndex: number;+}++export interface GoalReplayResult {+ divergences: GoalReplayDivergence[];+ goalId: string;+ matched: number;+ ticks: number;+}++const candidateOrder = (candidates: FrontierCandidate[]): string =>+ candidates.map((candidate) => candidate.nodeId).join(',');++/**+ * Re-run a decider over a recorded trajectory and report where it now decides+ * differently.+ *+ * Feeding the current implementation its own history is how a coordinator rule+ * change gets a regression signal: an empty `divergences` means the change was+ * inert on this run, and every entry is a real behavioural difference with the+ * exact input that produced it. No database and no environment — the trajectory+ * carries the whole decision surface.+ */+export const replayGoalTrajectory = (+ trajectory: GoalTrajectory,+ decide: GoalDecider,+): GoalReplayResult => {+ const divergences: GoalReplayDivergence[] = [];+ let ticks = 0;+ let matched = 0;++ for (const advance of trajectory.advances) {+ for (const tick of advance.ticks) {+ ticks += 1;+ const graph: GoalGraphState = reconstructGraphAt(trajectory, advance.seq, tick.index);+ const replayed = decide({+ budget: tick.budget,+ frontierTask: tick.frontierTask,+ graph,+ now: tick.at,+ });++ const before = divergences.length;+ const record = (+ field: GoalReplayDivergence['field'],+ recordedValue: string,+ replayedValue: string,+ ) => {+ if (recordedValue !== replayedValue) {+ divergences.push({+ advanceSeq: advance.seq,+ field,+ recorded: recordedValue,+ replayed: replayedValue,+ tickIndex: tick.index,+ });+ }+ };++ record('branch', tick.branch, replayed.branch);+ record('chosenNodeId', tick.chosenNodeId ?? '', replayed.chosenNodeId ?? '');+ record('candidates', candidateOrder(tick.candidates), candidateOrder(replayed.candidates));++ if (divergences.length === before) matched += 1;+ }+ }++ return { divergences, goalId: trajectory.goalId, matched, ticks };+};diff --git a/packages/agent-tracing/src/goal/rollup.ts b/packages/agent-tracing/src/goal/rollup.tsnew file mode 100644index 00000000000..77325264a22--- /dev/null+++ b/packages/agent-tracing/src/goal/rollup.ts@@ -0,0 +1,139 @@+import { applyGraphDelta, buildGraphShape, reconstructFinalGraph } from './delta';+import type { GoalGraphShape, GoalTrajectory } from './types';++/**+ * The `goal_traces` row for a trajectory.+ *+ * Everything here is a scalar or a small bucket count — the analytics surface.+ * Per-advance detail (the graph at each tick, the budget it read, the frontier+ * candidates it passed over) stays in the trajectory object, the same way an+ * operation's messages stay in its `ExecutionSnapshot` rather than on+ * `agent_operations`.+ */+export interface GoalTraceRollup {+ advancesByOutcome: Record<string, number>;+ advancesByTrigger: Record<string, number>;+ advancesTotal: number;+ completedAt?: number;+ completionReason?: string;+ findingsTotal: number;+ gatesOpened: number;+ gatesResolved: number;+ /** Wall time a goal spent parked on a human, summed across gates. */+ humanWaitingMs: number;+ nodesTotal: number;+ /** Operations this goal put in flight — the join key count into `agent_operations`. */+ operationsTotal: number;+ startedAt: number;+ tasksCompleted: number;+ tasksRetired: number;+ ticksByBranch: Record<string, number>;+ ticksTotal: number;+}++const increment = (counter: Record<string, number>, key: string): void => {+ counter[key] = (counter[key] ?? 0) + 1;+};++interface GateMetrics {+ gatesOpened: number;+ gatesResolved: number;+ humanWaitingMs: number;+}++/**+ * Gate metrics, read from the recorded graph rather than from effects.+ *+ * Effects only exist where someone remembered to emit one, and the resolving+ * half never can: a person answers a gate through `goal.decide`, outside any+ * advance, so no tick is running to report it. The decision rows are in every+ * recorded graph state either way, so folding them forward sees both+ * transitions without the coordinator having to cooperate.+ *+ * Waiting time is measured between the tick that first saw the gate open and+ * the tick that first saw it answered. That is the wall time the goal actually+ * stood still — it starts when the coordinator stopped, not when the row was+ * written, and it ends when the coordinator noticed, not when the person+ * clicked. Both boundaries are what the goal experienced.+ */+const gateMetrics = (trajectory: GoalTrajectory): GateMetrics => {+ let state = trajectory.graphBaseline;+ const openedAt = new Map<string, number>();+ let gatesOpened = 0;+ let gatesResolved = 0;+ let humanWaitingMs = 0;++ const observe = (at: number) => {+ for (const decision of state.decisions) {+ if (decision.status === 'pending') {+ if (!openedAt.has(decision.id)) {+ openedAt.set(decision.id, at);+ gatesOpened += 1;+ }+ continue;+ }+ // Anything that is no longer pending has been answered — by a person, or+ // by the coordinator canceling it.+ const opened = openedAt.get(decision.id);+ if (opened === undefined) continue;+ openedAt.delete(decision.id);+ gatesResolved += 1;+ humanWaitingMs += Math.max(0, at - opened);+ }+ };++ for (const advance of trajectory.advances) {+ for (const tick of advance.ticks) {+ state = applyGraphDelta(state, tick.graphDelta);+ observe(tick.at);+ }+ }++ return { gatesOpened, gatesResolved, humanWaitingMs };+};++export const buildGoalTraceRollup = (trajectory: GoalTrajectory): GoalTraceRollup => {+ const advancesByTrigger: Record<string, number> = {};+ const advancesByOutcome: Record<string, number> = {};+ const ticksByBranch: Record<string, number> = {};++ let ticksTotal = 0;+ const operationIds = new Set<string>();++ for (const advance of trajectory.advances) {+ increment(advancesByTrigger, advance.trigger);++ // An advance's outcome is its last tick's — the one it stopped on.+ const last = advance.ticks.at(-1);+ if (last) increment(advancesByOutcome, last.outcome);++ ticksTotal += advance.ticks.length;+ for (const tick of advance.ticks) increment(ticksByBranch, tick.branch);+ for (const operationId of advance.childOperationIds ?? []) operationIds.add(operationId);+ }++ const finalGraph = reconstructFinalGraph(trajectory);+ const shape: GoalGraphShape = buildGraphShape(finalGraph);+ const gates = gateMetrics(trajectory);++ return {+ advancesByOutcome,+ advancesByTrigger,+ advancesTotal: trajectory.advances.length,+ completedAt: trajectory.completedAt,+ completionReason: trajectory.completionReason,+ findingsTotal: shape.findings,+ gatesOpened: gates.gatesOpened,+ gatesResolved: gates.gatesResolved,+ humanWaitingMs: gates.humanWaitingMs,+ nodesTotal: shape.nodesTotal,+ startedAt: trajectory.startedAt,+ ticksByBranch,+ ticksTotal,+ operationsTotal: operationIds.size,+ tasksCompleted: shape.tasksCompleted,+ tasksRetired: finalGraph.nodes.filter(+ (node) => node.kind === 'work' && node.status === 'retired',+ ).length,+ };+};diff --git a/packages/agent-tracing/src/goal/store/file-store.ts b/packages/agent-tracing/src/goal/store/file-store.tsnew file mode 100644index 00000000000..57024036a84--- /dev/null+++ b/packages/agent-tracing/src/goal/store/file-store.ts@@ -0,0 +1,185 @@+import fs from 'node:fs/promises';+import path from 'node:path';++import type { GoalTraceSummary, GoalTrajectory } from '../types';+import type { IGoalTraceStore } from './types';++const DEFAULT_DIR = '.goal-tracing';+const PARTIAL_DIR = '_partial';++/**+ * Local-disk goal trajectories, the dev counterpart of `FileSnapshotStore`.+ *+ * Files are keyed by goal id rather than by timestamp: a goal id is stable for+ * the whole run, so there is exactly one object per goal and no name to+ * reconcile when it is finalized.+ */+export class FileGoalTraceStore implements IGoalTraceStore {+ private dir: string;++ constructor(rootDir?: string) {+ this.dir = path.resolve(rootDir ?? process.cwd(), DEFAULT_DIR);+ }++ private filePath(goalId: string): string {+ return path.join(this.dir, `${safeName(goalId)}.json`);+ }++ private partialDir(): string {+ return path.join(this.dir, PARTIAL_DIR);+ }++ private partialPath(goalId: string): string {+ return path.join(this.partialDir(), `${safeName(goalId)}.json`);+ }++ async save(trajectory: GoalTrajectory): Promise<void> {+ await fs.mkdir(this.dir, { recursive: true });+ await fs.writeFile(+ this.filePath(trajectory.goalId),+ JSON.stringify(trajectory, null, 2),+ 'utf8',+ );+ }++ async get(goalId: string): Promise<GoalTrajectory | null> {+ const finalized = await readJson<GoalTrajectory>(this.filePath(goalId));+ if (finalized) return finalized;++ // An in-flight goal is the common case for a tool used while debugging, so+ // fall through to the partial instead of reporting "no trace".+ const partial = await this.loadPartial(goalId);+ return partial ? partialToTrajectory(goalId, partial) : null;+ }++ /**+ * Finalized and in-progress trajectories together, newest first.+ *+ * A long-horizon goal spends nearly all of its life as a partial, so a+ * listing that showed only finalized objects would report "nothing here" on+ * a machine that is actively running goals — while inspecting any one of+ * them by id worked fine.+ */+ async list(options?: { limit?: number }): Promise<GoalTraceSummary[]> {+ const limit = options?.limit ?? 10;++ const finalized = await Promise.all(+ (await this.listFiles()).map(async (file) => ({+ mtime: await mtimeOf(path.join(this.dir, file)),+ trajectory: await readJson<GoalTrajectory>(path.join(this.dir, file)),+ })),+ );+ const partials = await Promise.all(+ (await this.listPartials()).map(async (file) => {+ const filePath = path.join(this.partialDir(), file);+ const partial = await readJson<Partial<GoalTrajectory>>(filePath);+ return {+ mtime: await mtimeOf(filePath),+ trajectory: partial+ ? partialToTrajectory(partial.goalId ?? file.replace(/\.json$/, ''), partial)+ : null,+ };+ }),+ );++ // A goal that finalized while a stale partial lingered would otherwise show+ // twice; the finalized object wins because it is the complete one.+ const seen = new Set<string>();+ return [...finalized, ...partials]+ .flatMap((entry) => (entry.trajectory ? [{ ...entry, trajectory: entry.trajectory }] : []))+ .sort((a, b) => b.mtime - a.mtime)+ .filter(({ trajectory }) => {+ if (seen.has(trajectory.goalId)) return false;+ seen.add(trajectory.goalId);+ return true;+ })+ .slice(0, limit)+ .map(({ trajectory }) => toSummary(trajectory));+ }++ async listPartials(): Promise<string[]> {+ try {+ const entries = await fs.readdir(this.partialDir());+ return entries.filter((file) => file.endsWith('.json')).sort();+ } catch {+ return [];+ }+ }++ async loadPartial(goalId: string): Promise<Partial<GoalTrajectory> | null> {+ return readJson<Partial<GoalTrajectory>>(this.partialPath(goalId));+ }++ async savePartial(goalId: string, partial: Partial<GoalTrajectory>): Promise<void> {+ await fs.mkdir(this.partialDir(), { recursive: true });+ await fs.writeFile(this.partialPath(goalId), JSON.stringify(partial), 'utf8');+ }++ async removePartial(goalId: string): Promise<void> {+ try {+ await fs.unlink(this.partialPath(goalId));+ } catch {+ // already gone+ }+ }++ private async listFiles(): Promise<string[]> {+ try {+ const entries = await fs.readdir(this.dir);+ return entries.filter((file) => file.endsWith('.json'));+ } catch {+ return [];+ }+ }+}++const safeName = (goalId: string): string => goalId.replaceAll(/[^\w-]/g, '_');++/** The file name is an id, so ordering has to come from the filesystem. */+const mtimeOf = async (filePath: string): Promise<number> =>+ fs+ .stat(filePath)+ .then((stat) => stat.mtimeMs)+ .catch(() => 0);++async function readJson<T>(filePath: string): Promise<T | null> {+ try {+ return JSON.parse(await fs.readFile(filePath, 'utf8')) as T;+ } catch {+ return null;+ }+}++export function partialToTrajectory(+ goalId: string,+ partial: Partial<GoalTrajectory>,+): GoalTrajectory {+ const advances = partial.advances ?? [];+ return {+ ...partial,+ advances,+ goalId: partial.goalId ?? goalId,+ graphBaseline: partial.graphBaseline ?? {+ decisions: [],+ edges: [],+ goal: { id: goalId, status: 'unknown', title: partial.title ?? goalId },+ nodes: [],+ },+ startedAt: partial.startedAt ?? Date.now(),+ title: partial.title ?? goalId,+ totalAdvances: advances.length,+ totalTicks: advances.reduce((sum, advance) => sum + advance.ticks.length, 0),+ traceId: partial.traceId ?? goalId,+ };+}++export function toSummary(trajectory: GoalTrajectory): GoalTraceSummary {+ return {+ advances: trajectory.totalAdvances,+ completionReason: trajectory.completionReason,+ createdAt: trajectory.startedAt,+ durationMs: (trajectory.completedAt ?? Date.now()) - trajectory.startedAt,+ goalId: trajectory.goalId,+ title: trajectory.title,+ };+}diff --git a/packages/agent-tracing/src/goal/store/loadTrajectory.ts b/packages/agent-tracing/src/goal/store/loadTrajectory.tsnew file mode 100644index 00000000000..c8e8389c384--- /dev/null+++ b/packages/agent-tracing/src/goal/store/loadTrajectory.ts@@ -0,0 +1,61 @@+import { readFile } from 'node:fs/promises';++import type { GoalTrajectory } from '../types';+import { FileGoalTraceStore } from './file-store';+import { RemoteGoalTraceStore } from './remote-store';++export interface LoadGoalTrajectoryOptions {+ /** Fetch through `resolveDownloadUrl` when the goal is not on disk. */+ allowDownload?: boolean;+ /**+ * Sign a download URL for a goal id. There is no public fallback: unlike an+ * operation snapshot, whose key can be derived from its id, a goal+ * trajectory is only reachable through the server, which looks the key up on+ * `goal_traces` and signs it for the caller's own scope.+ */+ resolveDownloadUrl?: (goalId: string) => Promise<string | null>;+ /** Root that `.goal-tracing/` resolves against. Defaults to `process.cwd()`. */+ rootDir?: string;+}++const isUrl = (target: string) => target.startsWith('http://') || target.startsWith('https://');++/**+ * Resolve one goal trajectory from a CLI-style target: a `.json` path, an+ * http(s) URL, or a goal id (local store → `_remote/` cache → optional+ * download).+ *+ * The local store already falls through to the in-progress partial, so a goal+ * that is still running resolves without a special flag — for a long-horizon+ * goal that is the normal case, not the exception.+ */+export async function loadGoalTrajectory(+ target: string,+ options: LoadGoalTrajectoryOptions = {},+): Promise<GoalTrajectory | undefined> {+ const { allowDownload = false, resolveDownloadUrl, rootDir } = options;++ if (target.endsWith('.json') && !isUrl(target)) {+ return JSON.parse(await readFile(target, 'utf8')) as GoalTrajectory;+ }++ if (isUrl(target)) {+ const response = await fetch(target);+ if (!response.ok) {+ throw new Error(`Failed to fetch goal trajectory: ${response.status} ${response.statusText}`);+ }+ return (await response.json()) as GoalTrajectory;+ }++ const local = await new FileGoalTraceStore(rootDir).get(target);+ if (local) return local;++ const remote = new RemoteGoalTraceStore(rootDir);+ const cached = await remote.getCached(target);+ if (cached) return cached;++ if (!allowDownload) return undefined;++ const signedUrl = await resolveDownloadUrl?.(target);+ return signedUrl ? remote.fetch(signedUrl, target) : undefined;+}diff --git a/packages/agent-tracing/src/goal/store/remote-store.ts b/packages/agent-tracing/src/goal/store/remote-store.tsnew file mode 100644index 00000000000..91034b59767--- /dev/null+++ b/packages/agent-tracing/src/goal/store/remote-store.ts@@ -0,0 +1,67 @@+import fs from 'node:fs/promises';+import path from 'node:path';+import { promisify } from 'node:util';+import { zstdDecompress } from 'node:zlib';++import type { GoalTrajectory } from '../types';++const decompressZstd = promisify(zstdDecompress);++const DEFAULT_DIR = '.goal-tracing';+const REMOTE_DIR = '_remote';++// Zstd frame magic — first 4 bytes of any zstd stream.+// https://datatracker.ietf.org/doc/html/rfc8478#section-3.1.1+const isZstdFrame = (buffer: Buffer): boolean =>+ buffer.length >= 4 &&+ buffer[0] === 0x28 &&+ buffer[1] === 0xb5 &&+ buffer[2] === 0x2f &&+ buffer[3] === 0xfd;++/**+ * Downloaded goal trajectories, cached as plain JSON for easy inspection.+ *+ * Unlike the operation store there is no URL to build from the id: a goal+ * trajectory is only reachable through a signed URL the server hands out, so+ * this never guesses a bucket layout.+ */+export class RemoteGoalTraceStore {+ private cacheDir: string;++ constructor(rootDir?: string) {+ this.cacheDir = path.resolve(rootDir ?? process.cwd(), DEFAULT_DIR, REMOTE_DIR);+ }++ private cachePath(goalId: string): string {+ return path.join(this.cacheDir, `${goalId.replaceAll(/[^\w-]/g, '_')}.json`);+ }++ async getCached(goalId: string): Promise<GoalTrajectory | null> {+ try {+ return JSON.parse(await fs.readFile(this.cachePath(goalId), 'utf8')) as GoalTrajectory;+ } catch {+ return null;+ }+ }++ async fetch(url: string, goalId: string): Promise<GoalTrajectory> {+ console.error(`↓ Downloading trajectory: ${goalId}`);+ const response = await fetch(url);+ if (!response.ok) {+ throw new Error(`Failed to fetch goal trajectory: ${response.status} ${response.statusText}`);+ }++ // Decode by content rather than by URL suffix, so a signed URL whose query+ // string hides the extension still decompresses correctly.+ const body = Buffer.from(await response.arrayBuffer());+ const decoded = isZstdFrame(body) ? await decompressZstd(body) : body;+ const trajectory = JSON.parse(decoded.toString('utf8')) as GoalTrajectory;++ await fs.mkdir(this.cacheDir, { recursive: true });+ await fs.writeFile(this.cachePath(goalId), JSON.stringify(trajectory, null, 2), 'utf8');+ console.error(`✓ Cached to: ${DEFAULT_DIR}/${REMOTE_DIR}/${goalId}.json`);++ return trajectory;+ }+}diff --git a/packages/agent-tracing/src/goal/store/types.ts b/packages/agent-tracing/src/goal/store/types.tsnew file mode 100644index 00000000000..ad8c921c22d--- /dev/null+++ b/packages/agent-tracing/src/goal/store/types.ts@@ -0,0 +1,16 @@+import type { GoalTraceSummary, GoalTrajectory } from '../types';++/**+ * Storage for goal trajectories. Mirrors `ISnapshotStore`: a finalized object+ * per goal plus an in-progress partial, because a goal is advanced from many+ * separate requests and has to accumulate across them.+ */+export interface IGoalTraceStore {+ get: (goalId: string) => Promise<GoalTrajectory | null>;+ list: (options?: { limit?: number }) => Promise<GoalTraceSummary[]>;+ listPartials: () => Promise<string[]>;+ loadPartial: (goalId: string) => Promise<Partial<GoalTrajectory> | null>;+ removePartial: (goalId: string) => Promise<void>;+ save: (trajectory: GoalTrajectory) => Promise<void>;+ savePartial: (goalId: string, partial: Partial<GoalTrajectory>) => Promise<void>;+}diff --git a/packages/agent-tracing/src/goal/types.ts b/packages/agent-tracing/src/goal/types.tsnew file mode 100644index 00000000000..8b4f903f133--- /dev/null+++ b/packages/agent-tracing/src/goal/types.ts@@ -0,0 +1,247 @@+/**+ * Goal trajectory — the same trace format as {@link ExecutionSnapshot}, one+ * level up.+ *+ * An operation is one complete agent execution and gets one `ExecutionSnapshot`+ * whose steps are LLM/tool calls. A goal is one complete *goal* execution and+ * gets one `GoalTrajectory` whose steps are advances. The nesting closes at the+ * leaf: an advance dispatches a task run, that run is an operation, and its+ * `operationId` is recorded here rather than its content copied — so+ * `agent-tracing inspect <opId>` continues from where the goal trace stops.+ *+ * Graph entities are typed structurally instead of importing `@lobechat/types`,+ * matching how `StepSnapshot.messages` stays loose: a trace format has to keep+ * reading objects written by older code.+ */++/** What caused this advance. `unknown` covers traces written before a caller was labelled. */+export type GoalAdvanceTrigger =+ 'create' | 'decide' | 'settle' | 'sweep' | 'resume' | 'budget' | 'manual' | 'unknown';++/** Which arm of the coordinator ran. One per `tick` return path. */+export type GoalTickBranch =+ /** Goal is paused or already terminal — nothing to decide. */+ | 'goal_paused'+ | 'goal_terminal'+ /** A gate is open; the goal is parked on a person. */+ | 'pending_decision'+ /** No work node is eligible: none exists, or all remaining ones are blocked. */+ | 'no_frontier'+ /** Every work node finished; the goal-level acceptance contract is next. */+ | 'terminal_acceptance'+ /** The chosen work has no responsible task yet. */+ | 'create_task'+ /** Its task row is gone. */+ | 'missing_task'+ /** Its task finished; fold the outcome into a finding. */+ | 'consume_completed'+ /** Its operation outlived the lease / failed verification — automatic recovery. */+ | 'recover_lease'+ | 'recover_verification'+ /** Recovery is exhausted or the failure is not recoverable; open a gate. */+ | 'failure_decision'+ /** Task is parked or already in flight. */+ | 'task_paused'+ | 'task_running'+ /** Budget stopped the goal before this work could be dispatched. */+ | 'budget_exhausted'+ /** Start a run for the chosen work. */+ | 'dispatch_task';++export type GoalTickOutcome =+ 'advanced' | 'achieved' | 'waiting_human' | 'waiting_external' | 'no_progress' | 'failed';++// ==================== Graph state ====================++export interface GoalTraceGoal {+ agentId?: string | null;+ id: string;+ maxRounds?: number | null;+ maxTotalCost?: number | null;+ requirement?: string | null;+ status: string;+ title: string;+}++export interface GoalTraceNode {+ /** Epoch ms. Drives the frontier tie-break, so replay needs it. */+ createdAt: number;+ id: string;+ kind: string;+ priority: number;+ status: string;+ taskId?: string | null;+ title: string;+}++export interface GoalTraceEdge {+ id: string;+ kind: string;+ sourceNodeId: string;+ targetNodeId: string;+}++export interface GoalTraceDecision {+ id: string;+ nodeId: string;+ question: string;+ resolvedOptionId?: string | null;+ status: string;+}++/** Everything the coordinator reads about the graph when it decides. */+export interface GoalGraphState {+ decisions: GoalTraceDecision[];+ edges: GoalTraceEdge[];+ goal: GoalTraceGoal;+ nodes: GoalTraceNode[];+}++/**+ * Change relative to the previous advance's state. Same baseline+delta shape as+ * `messagesBaseline` / `messagesDelta`: the trajectory carries one full state+ * and every later advance stores only what moved.+ */+export interface GoalGraphDelta {+ decisionsUpserted?: GoalTraceDecision[];+ edgesAdded?: GoalTraceEdge[];+ edgesRemoved?: string[];+ goal?: Partial<GoalTraceGoal>;+ nodesRemoved?: string[];+ nodesUpserted?: GoalTraceNode[];+}++// ==================== Decision input surface ====================++/**+ * A work node that was eligible this tick. Losers are recorded too — without+ * them a trace cannot answer "why not that node", which is the whole point of+ * keeping the input surface rather than the result.+ */+export interface FrontierCandidate {+ blockedBy: string[];+ nodeId: string;+ priority: number;+ status: string;+ title: string;+}++/** Budget as the coordinator read it, not as it looks now. */+export interface GoalBudgetState {+ costLimitReached: boolean;+ maxRounds?: number | null;+ maxTotalCost?: number | null;+ roundLimitReached: boolean;+ runs: number;+ totalCost: number;+}++/** The responsible task's state at decision time; drives every post-dispatch branch. */+export interface GoalFrontierTaskState {+ error?: string | null;+ id: string;+ identifier?: string;+ status: string;+ updatedAt: number;+}++/** Cheap shape metrics — enough to chart convergence without re-folding the graph. */+export interface GoalGraphShape {+ edgesTotal: number;+ findings: number;+ gatesPending: number;+ nodesTotal: number;+ tasksBlocked: number;+ tasksCompleted: number;+ tasksOpen: number;+ tasksReady: number;+}++// ==================== Snapshots ====================++export interface GoalTickSnapshot {+ /** When the coordinator entered this tick. Staleness branches read the clock, so replay needs it. */+ at: number;+ branch: GoalTickBranch;+ /**+ * Absent on branches that never funded anything — a paused goal, an open+ * gate, an empty frontier. Recording a budget the coordinator did not read+ * would put a number in the decision input that never influenced it.+ */+ budget?: GoalBudgetState;+ candidates: FrontierCandidate[];+ chosenNodeId?: string;+ /** What this tick changed. Attributed per tick so an advance's writes stay ordered. */+ effects: GoalAdvanceEffect[];+ frontierTask?: GoalFrontierTaskState;+ /**+ * Graph change since the previously recorded tick, observed on entry to this+ * one. Folding every delta up to and including this field reproduces exactly+ * what the coordinator read before it decided — which is what makes replay+ * possible. Ticks carry it rather than advances because an advance runs a+ * loop of them and each one re-reads the graph.+ */+ graphDelta?: GoalGraphDelta;+ graphShape: GoalGraphShape;+ index: number;+ message: string;+ outcome: GoalTickOutcome;+ taskId?: string;+}++export type GoalEffectType =+ | 'created_task'+ | 'started_run'+ | 'opened_decision'+ | 'resolved_decision'+ | 'created_node'+ | 'attached_work_version'+ | 'node_status'+ | 'goal_status'+ | 'released_claim';++export interface GoalAdvanceEffect {+ detail?: string;+ nodeId?: string;+ /** The agent operation this effect put in flight or consumed — the drill-down key. */+ operationId?: string;+ targetId?: string;+ type: GoalEffectType;+}++export interface GoalAdvanceSnapshot {+ /** Operations this advance put in flight. The hand-off to `inspect <opId>`. */+ childOperationIds?: string[];+ completedAt: number;+ durationMs: number;+ error?: { message: string; type: string };+ seq: number;+ startedAt: number;+ ticks: GoalTickSnapshot[];+ trigger: GoalAdvanceTrigger;+}++export interface GoalTrajectory {+ advances: GoalAdvanceSnapshot[];+ completedAt?: number;+ /** Terminal goal status — `achieved` / `failed` / `canceled`. */+ completionReason?: string;+ goalId: string;+ /** State before the first recorded advance; later states fold forward from here. */+ graphBaseline: GoalGraphState;+ startedAt: number;+ title: string;+ totalAdvances: number;+ totalTicks: number;+ traceId: string;+ userId?: string;+}++export interface GoalTraceSummary {+ advances: number;+ completionReason?: string;+ createdAt: number;+ durationMs: number;+ goalId: string;+ title: string;+}diff --git a/packages/agent-tracing/src/goal/viewer.ts b/packages/agent-tracing/src/goal/viewer.tsnew file mode 100644index 00000000000..b750c3e20f6--- /dev/null+++ b/packages/agent-tracing/src/goal/viewer.ts@@ -0,0 +1,138 @@+import { buildGoalTraceRollup } from './rollup';+import type { GoalAdvanceSnapshot, GoalTickSnapshot, GoalTrajectory } from './types';++const pad = (value: string | number, width: number): string => String(value).padEnd(width);++const duration = (ms: number): string => {+ if (ms < 1000) return `${ms}ms`;+ if (ms < 60_000) return `${(ms / 1000).toFixed(1)}s`;+ if (ms < 3_600_000) return `${Math.round(ms / 60_000)}m`;+ return `${(ms / 3_600_000).toFixed(1)}h`;+};++const clock = (at: number): string => new Date(at).toISOString().slice(11, 19);++const OUTCOME_GLYPH: Record<string, string> = {+ achieved: '★',+ advanced: '→',+ failed: '✗',+ no_progress: '·',+ waiting_external: '⋯',+ waiting_human: '⏸',+};++/** One line per tick, nested under the advance that ran it. */+const renderTick = (tick: GoalTickSnapshot, last: boolean): string => {+ const branch = pad(tick.branch, 20);+ const chosen = tick.chosenNodeId ? ` ${tick.chosenNodeId.slice(0, 8)}` : '';+ const others = tick.candidates.length > 1 ? ` (+${tick.candidates.length - 1} eligible)` : '';+ return ` ${last ? '└─' : '├─'} ${OUTCOME_GLYPH[tick.outcome] ?? '?'} ${branch}${chosen}${others} ${tick.message}`;+};++const renderAdvance = (advance: GoalAdvanceSnapshot): string => {+ const head = [+ `#${pad(advance.seq, 4)}`,+ pad(advance.trigger, 8),+ pad(clock(advance.startedAt), 9),+ pad(duration(advance.durationMs), 7),+ `${advance.ticks.length} tick${advance.ticks.length === 1 ? '' : 's'}`,+ advance.childOperationIds?.length ? `→ ${advance.childOperationIds.join(', ')}` : '',+ advance.error ? `!! ${advance.error.message}` : '',+ ]+ .filter(Boolean)+ .join(' ');++ const ticks = advance.ticks.map((tick, index) =>+ renderTick(tick, index === advance.ticks.length - 1),+ );+ return [head, ...ticks].join('\n');+};++/** The whole run: what it cost, where it went, and how it ended. */+export const renderGoalTrajectory = (trajectory: GoalTrajectory): string => {+ const rollup = buildGoalTraceRollup(trajectory);+ const end = trajectory.completedAt ?? Date.now();++ const bucket = (counts: Record<string, number>) =>+ Object.entries(counts)+ .sort((a, b) => b[1] - a[1])+ .map(([key, count]) => `${key}=${count}`)+ .join(' ') || '—';++ const header = [+ `Goal ${trajectory.goalId} ${trajectory.title}`,+ `Status ${trajectory.completionReason ?? 'in flight'} ${duration(end - trajectory.startedAt)}`,+ `Advances ${rollup.advancesTotal} (${rollup.ticksTotal} ticks) by trigger: ${bucket(rollup.advancesByTrigger)}`,+ `Outcomes ${bucket(rollup.advancesByOutcome)}`,+ `Graph ${rollup.nodesTotal} nodes · ${rollup.tasksCompleted} tasks done · ${rollup.findingsTotal} findings`,+ `Human ${rollup.gatesOpened} gate(s), ${duration(rollup.humanWaitingMs)} waiting`,+ `Ops ${rollup.operationsTotal} operation(s) — lh trace op inspect <opId> to go deeper`,+ ].join('\n');++ return [header, '', ...trajectory.advances.map((advance) => renderAdvance(advance))].join('\n');+};++/**+ * One advance in full: the decision surface of each of its ticks, including the+ * candidates it passed over — which is what the summary view cannot show and+ * what any question about "why not that node" needs.+ */+export const renderGoalAdvanceDetail = (trajectory: GoalTrajectory, seq: number): string => {+ const advance = trajectory.advances.find((item) => item.seq === seq);+ if (!advance) return `No advance #${seq} in ${trajectory.goalId}`;++ const lines = [+ `Advance #${advance.seq} trigger=${advance.trigger} ${clock(advance.startedAt)} ${duration(advance.durationMs)}`,+ ];+ if (advance.error) lines.push(`Error: ${advance.error.type} — ${advance.error.message}`);++ for (const tick of advance.ticks) {+ lines.push(+ '',+ ` tick ${tick.index} ${tick.branch} → ${tick.outcome}`,+ ` ${tick.message}`,+ ` graph: ${tick.graphShape.nodesTotal} nodes, tasks ${tick.graphShape.tasksReady} ready / ${tick.graphShape.tasksBlocked} blocked / ${tick.graphShape.tasksCompleted} done, ${tick.graphShape.gatesPending} gate(s) pending`,+ );++ if (tick.budget) {+ const limits = [+ tick.budget.maxRounds == null+ ? 'rounds ∞'+ : `rounds ${tick.budget.runs}/${tick.budget.maxRounds}`,+ tick.budget.maxTotalCost == null+ ? 'cost ∞'+ : `cost $${tick.budget.totalCost.toFixed(4)}/$${tick.budget.maxTotalCost}`,+ ].join(' ');+ lines.push(` budget: ${limits}`);+ }++ if (tick.frontierTask) {+ const error = tick.frontierTask.error ? ` — ${tick.frontierTask.error}` : '';+ lines.push(+ ` task: ${tick.frontierTask.identifier ?? tick.frontierTask.id} ${tick.frontierTask.status}${error}`,+ );+ }++ if (tick.candidates.length > 0) {+ lines.push(' frontier:');+ for (const candidate of tick.candidates) {+ const mark = candidate.nodeId === tick.chosenNodeId ? '▸' : ' ';+ const blocked = candidate.blockedBy.length+ ? ` blocked by ${candidate.blockedBy.map((id) => id.slice(0, 8)).join(', ')}`+ : '';+ lines.push(+ ` ${mark} ${candidate.nodeId.slice(0, 8)} p${candidate.priority} ${candidate.status} ${candidate.title}${blocked}`,+ );+ }+ }++ for (const effect of tick.effects) {+ const target = effect.targetId ? ` ${effect.targetId}` : '';+ const operation = effect.operationId ? ` op=${effect.operationId}` : '';+ const detail = effect.detail ? ` (${effect.detail})` : '';+ lines.push(` effect: ${effect.type}${target}${operation}${detail}`);+ }+ }++ return lines.join('\n');+};diff --git a/packages/agent-tracing/src/index.ts b/packages/agent-tracing/src/index.tsindex a1321ca4730..9143bdb5b31 100644--- a/packages/agent-tracing/src/index.ts+++ b/packages/agent-tracing/src/index.ts@@ -12,6 +12,7 @@ export {type ContextSegment,type SegmentKind,} from './analysis/contextMap';+export * from './goal';export { InspectError, type InspectOptions, inspectSnapshot } from './inspect/inspectSnapshot';export { appendStepToPartial, finalizeSnapshot } from './recorder';export * from './replay';diff --git a/packages/builtin-tool-goal/src/client/executor/index.ts b/packages/builtin-tool-goal/src/client/executor/index.tsindex 0a258858019..b55d33d03fb 100644--- a/packages/builtin-tool-goal/src/client/executor/index.ts+++ b/packages/builtin-tool-goal/src/client/executor/index.ts@@ -55,7 +55,7 @@ class GoalExecutor extends BaseExecutor<typeof GoalApiName> {agentId: ctx.agentId,createdByAgentId: ctx.agentId,config: {- recovery: { maxAttemptsPerWork: resolveGoalAttemptBudget(params.maxIterations) },+ recovery: { maxAttemptsPerTask: resolveGoalAttemptBudget(params.maxIterations) },},// `maxIterations` caps attempts on one Work; it is deliberately not// passed as `maxRounds`, which counts runs across every Work in thediff --git a/packages/builtin-tool-goal/src/createGoalInput.ts b/packages/builtin-tool-goal/src/createGoalInput.tsindex 6f250870bfa..6aa0711600e 100644--- a/packages/builtin-tool-goal/src/createGoalInput.ts+++ b/packages/builtin-tool-goal/src/createGoalInput.ts@@ -16,7 +16,7 @@ export interface GoalCriterionInput {* `null` is the manifest's documented "no user-specified cap" — the cleared* input field — and must stay distinct from a chosen number, or clearing the* field would quietly pin the goal to three attempts. Returning `undefined`- * leaves `maxAttemptsPerWork` off the config so `resolveWorkAttemptBudget`+ * leaves `maxAttemptsPerTask` off the config so `resolveTaskAttemptBudget`* applies its own default.*/export const resolveGoalAttemptBudget = (maxIterations?: number | null): number | undefined =>diff --git a/packages/database/migrations/0154_goal_node_task_kind.sql b/packages/database/migrations/0154_goal_node_task_kind.sqlnew file mode 100644index 00000000000..f9b3a235a06--- /dev/null+++ b/packages/database/migrations/0154_goal_node_task_kind.sql@@ -0,0 +1,14 @@+-- A Goal Graph node that owns a task is now `task`, not `work`: the two were+-- always 1:1, and `work` still names the works/work_versions artifact registry.+--+-- The CHECK goes rather than moving to the new value. `bindTask` is the only+-- writer of `task_id` and its WHERE already requires the kind, so the+-- constraint was redundant with the write path while pinning the kind+-- vocabulary into DDL — an ALTER for every future kind. The unique index on+-- `task_id` stays: one task belonging to one node is an invariant no single+-- write can check for itself.+--+-- Drop before backfilling: the old constraint reads `kind = 'work'`, so+-- updating a row that owns a task would violate it on the way past.+ALTER TABLE "goal_nodes" DROP CONSTRAINT IF EXISTS "goal_nodes_task_requires_work_kind";--> statement-breakpoint+UPDATE "goal_nodes" SET "kind" = 'task' WHERE "kind" = 'work';diff --git a/packages/database/migrations/meta/0154_snapshot.json b/packages/database/migrations/meta/0154_snapshot.jsonnew file mode 100644index 00000000000..f7d10d1df50--- /dev/null+++ b/packages/database/migrations/meta/0154_snapshot.json@@ -0,0 +1,36394 @@+{+ "id": "d4603cf5-c4e3-4764-91e0-768cd9cfd736",+ "prevId": "ce060b2d-2042-4ce9-aa4d-5fff9bff81ba",+ "version": "7",+ "dialect": "postgresql",+ "tables": {+ "public.agents": {+ "name": "agents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "slug": {+ "name": "slug",+ "type": "varchar(100)",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "varchar(1000)",+ "primaryKey": false,+ "notNull": false+ },+ "tags": {+ "name": "tags",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'[]'::jsonb"+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "avatar": {+ "name": "avatar",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "background_color": {+ "name": "background_color",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "market_identifier": {+ "name": "market_identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "profile": {+ "name": "profile",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "society_id": {+ "name": "society_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "plugins": {+ "name": "plugins",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agency_config": {+ "name": "agency_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "chat_config": {+ "name": "chat_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "few_shots": {+ "name": "few_shots",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "params": {+ "name": "params",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "system_role": {+ "name": "system_role",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "tts": {+ "name": "tts",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "virtual": {+ "name": "virtual",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "pinned": {+ "name": "pinned",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "opening_message": {+ "name": "opening_message",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "opening_questions": {+ "name": "opening_questions",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'"+ },+ "session_group_id": {+ "name": "session_group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_deleted": {+ "name": "is_deleted",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "client_id_user_id_unique": {+ "name": "client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_slug_user_id_unique": {+ "name": "agents_slug_user_id_unique",+ "columns": [+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agents\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_created_at_idx": {+ "name": "agents_created_at_idx",+ "columns": [+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_user_id_idx": {+ "name": "agents_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_title_idx": {+ "name": "agents_title_idx",+ "columns": [+ {+ "expression": "title",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_description_idx": {+ "name": "agents_description_idx",+ "columns": [+ {+ "expression": "description",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_session_group_id_idx": {+ "name": "agents_session_group_id_idx",+ "columns": [+ {+ "expression": "session_group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_workspace_id_idx": {+ "name": "agents_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_workspace_visibility_idx": {+ "name": "agents_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_slug_workspace_id_unique": {+ "name": "agents_slug_workspace_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agents\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agents_user_id_users_id_fk": {+ "name": "agents_user_id_users_id_fk",+ "tableFrom": "agents",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agents_workspace_id_workspaces_id_fk": {+ "name": "agents_workspace_id_workspaces_id_fk",+ "tableFrom": "agents",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agents_session_group_id_session_groups_id_fk": {+ "name": "agents_session_group_id_session_groups_id_fk",+ "tableFrom": "agents",+ "tableTo": "session_groups",+ "columnsFrom": [+ "session_group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agents_files": {+ "name": "agents_files",+ "schema": "",+ "columns": {+ "file_id": {+ "name": "file_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agents_files_agent_id_idx": {+ "name": "agents_files_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_files_file_id_idx": {+ "name": "agents_files_file_id_idx",+ "columns": [+ {+ "expression": "file_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_files_user_id_idx": {+ "name": "agents_files_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_files_workspace_id_idx": {+ "name": "agents_files_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agents_files_file_id_files_id_fk": {+ "name": "agents_files_file_id_files_id_fk",+ "tableFrom": "agents_files",+ "tableTo": "files",+ "columnsFrom": [+ "file_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agents_files_agent_id_agents_id_fk": {+ "name": "agents_files_agent_id_agents_id_fk",+ "tableFrom": "agents_files",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agents_files_user_id_users_id_fk": {+ "name": "agents_files_user_id_users_id_fk",+ "tableFrom": "agents_files",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agents_files_workspace_id_workspaces_id_fk": {+ "name": "agents_files_workspace_id_workspaces_id_fk",+ "tableFrom": "agents_files",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agents_files_file_id_agent_id_user_id_pk": {+ "name": "agents_files_file_id_agent_id_user_id_pk",+ "columns": [+ "file_id",+ "agent_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agents_knowledge_bases": {+ "name": "agents_knowledge_bases",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "knowledge_base_id": {+ "name": "knowledge_base_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": true+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agents_knowledge_bases_agent_id_idx": {+ "name": "agents_knowledge_bases_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_knowledge_bases_knowledge_base_id_idx": {+ "name": "agents_knowledge_bases_knowledge_base_id_idx",+ "columns": [+ {+ "expression": "knowledge_base_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_knowledge_bases_user_id_idx": {+ "name": "agents_knowledge_bases_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_knowledge_bases_workspace_id_idx": {+ "name": "agents_knowledge_bases_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agents_knowledge_bases_agent_id_agents_id_fk": {+ "name": "agents_knowledge_bases_agent_id_agents_id_fk",+ "tableFrom": "agents_knowledge_bases",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agents_knowledge_bases_knowledge_base_id_knowledge_bases_id_fk": {+ "name": "agents_knowledge_bases_knowledge_base_id_knowledge_bases_id_fk",+ "tableFrom": "agents_knowledge_bases",+ "tableTo": "knowledge_bases",+ "columnsFrom": [+ "knowledge_base_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agents_knowledge_bases_user_id_users_id_fk": {+ "name": "agents_knowledge_bases_user_id_users_id_fk",+ "tableFrom": "agents_knowledge_bases",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agents_knowledge_bases_workspace_id_workspaces_id_fk": {+ "name": "agents_knowledge_bases_workspace_id_workspaces_id_fk",+ "tableFrom": "agents_knowledge_bases",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agents_knowledge_bases_agent_id_knowledge_base_id_pk": {+ "name": "agents_knowledge_bases_agent_id_knowledge_base_id_pk",+ "columns": [+ "agent_id",+ "knowledge_base_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_bot_providers": {+ "name": "agent_bot_providers",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "platform": {+ "name": "platform",+ "type": "varchar(50)",+ "primaryKey": false,+ "notNull": true+ },+ "application_id": {+ "name": "application_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "credentials": {+ "name": "credentials",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "settings": {+ "name": "settings",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_bot_providers_platform_app_id_unique": {+ "name": "agent_bot_providers_platform_app_id_unique",+ "columns": [+ {+ "expression": "platform",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "application_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_bot_providers_platform_idx": {+ "name": "agent_bot_providers_platform_idx",+ "columns": [+ {+ "expression": "platform",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_bot_providers_agent_id_idx": {+ "name": "agent_bot_providers_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_bot_providers_user_id_idx": {+ "name": "agent_bot_providers_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_bot_providers_workspace_id_idx": {+ "name": "agent_bot_providers_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_bot_providers_agent_id_agents_id_fk": {+ "name": "agent_bot_providers_agent_id_agents_id_fk",+ "tableFrom": "agent_bot_providers",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_bot_providers_user_id_users_id_fk": {+ "name": "agent_bot_providers_user_id_users_id_fk",+ "tableFrom": "agent_bot_providers",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_bot_providers_workspace_id_workspaces_id_fk": {+ "name": "agent_bot_providers_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_bot_providers",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_cron_jobs": {+ "name": "agent_cron_jobs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": true+ },+ "cron_pattern": {+ "name": "cron_pattern",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "timezone": {+ "name": "timezone",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "default": "'UTC'"+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "edit_data": {+ "name": "edit_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "max_executions": {+ "name": "max_executions",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "remaining_executions": {+ "name": "remaining_executions",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "execution_conditions": {+ "name": "execution_conditions",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "last_executed_at": {+ "name": "last_executed_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "total_executions": {+ "name": "total_executions",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_deleted": {+ "name": "is_deleted",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_cron_jobs_agent_id_idx": {+ "name": "agent_cron_jobs_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_cron_jobs_group_id_idx": {+ "name": "agent_cron_jobs_group_id_idx",+ "columns": [+ {+ "expression": "group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_cron_jobs_user_id_idx": {+ "name": "agent_cron_jobs_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_cron_jobs_workspace_id_idx": {+ "name": "agent_cron_jobs_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_cron_jobs_enabled_idx": {+ "name": "agent_cron_jobs_enabled_idx",+ "columns": [+ {+ "expression": "enabled",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_cron_jobs_remaining_executions_idx": {+ "name": "agent_cron_jobs_remaining_executions_idx",+ "columns": [+ {+ "expression": "remaining_executions",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_cron_jobs_last_executed_at_idx": {+ "name": "agent_cron_jobs_last_executed_at_idx",+ "columns": [+ {+ "expression": "last_executed_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_cron_jobs_agent_id_agents_id_fk": {+ "name": "agent_cron_jobs_agent_id_agents_id_fk",+ "tableFrom": "agent_cron_jobs",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_cron_jobs_group_id_chat_groups_id_fk": {+ "name": "agent_cron_jobs_group_id_chat_groups_id_fk",+ "tableFrom": "agent_cron_jobs",+ "tableTo": "chat_groups",+ "columnsFrom": [+ "group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_cron_jobs_user_id_users_id_fk": {+ "name": "agent_cron_jobs_user_id_users_id_fk",+ "tableFrom": "agent_cron_jobs",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_cron_jobs_workspace_id_workspaces_id_fk": {+ "name": "agent_cron_jobs_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_cron_jobs",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_documents": {+ "name": "agent_documents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "document_id": {+ "name": "document_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "template_id": {+ "name": "template_id",+ "type": "varchar(100)",+ "primaryKey": false,+ "notNull": false+ },+ "access_self": {+ "name": "access_self",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 31+ },+ "access_shared": {+ "name": "access_shared",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "access_public": {+ "name": "access_public",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "policy_load": {+ "name": "policy_load",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "default": "'always'"+ },+ "policy": {+ "name": "policy",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "policy_load_position": {+ "name": "policy_load_position",+ "type": "varchar(50)",+ "primaryKey": false,+ "notNull": true,+ "default": "'before-first-user'"+ },+ "policy_load_format": {+ "name": "policy_load_format",+ "type": "varchar(20)",+ "primaryKey": false,+ "notNull": true,+ "default": "'raw'"+ },+ "policy_load_rule": {+ "name": "policy_load_rule",+ "type": "varchar(50)",+ "primaryKey": false,+ "notNull": true,+ "default": "'always'"+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_by_user_id": {+ "name": "deleted_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_by_agent_id": {+ "name": "deleted_by_agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "delete_reason": {+ "name": "delete_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_documents_workspace_id_idx": {+ "name": "agent_documents_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_user_id_idx": {+ "name": "agent_documents_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_agent_id_idx": {+ "name": "agent_documents_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_access_self_idx": {+ "name": "agent_documents_access_self_idx",+ "columns": [+ {+ "expression": "access_self",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_access_shared_idx": {+ "name": "agent_documents_access_shared_idx",+ "columns": [+ {+ "expression": "access_shared",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_access_public_idx": {+ "name": "agent_documents_access_public_idx",+ "columns": [+ {+ "expression": "access_public",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_policy_load_idx": {+ "name": "agent_documents_policy_load_idx",+ "columns": [+ {+ "expression": "policy_load",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_template_id_idx": {+ "name": "agent_documents_template_id_idx",+ "columns": [+ {+ "expression": "template_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_policy_load_position_idx": {+ "name": "agent_documents_policy_load_position_idx",+ "columns": [+ {+ "expression": "policy_load_position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_policy_load_format_idx": {+ "name": "agent_documents_policy_load_format_idx",+ "columns": [+ {+ "expression": "policy_load_format",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_policy_load_rule_idx": {+ "name": "agent_documents_policy_load_rule_idx",+ "columns": [+ {+ "expression": "policy_load_rule",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_agent_load_position_idx": {+ "name": "agent_documents_agent_load_position_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "policy_load_position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_deleted_at_idx": {+ "name": "agent_documents_deleted_at_idx",+ "columns": [+ {+ "expression": "deleted_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_agent_autoload_deleted_idx": {+ "name": "agent_documents_agent_autoload_deleted_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "deleted_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "policy_load",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_document_id_idx": {+ "name": "agent_documents_document_id_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_agent_document_user_unique": {+ "name": "agent_documents_agent_document_user_unique",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_documents_user_id_users_id_fk": {+ "name": "agent_documents_user_id_users_id_fk",+ "tableFrom": "agent_documents",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_documents_workspace_id_workspaces_id_fk": {+ "name": "agent_documents_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_documents",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_documents_agent_id_agents_id_fk": {+ "name": "agent_documents_agent_id_agents_id_fk",+ "tableFrom": "agent_documents",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_documents_document_id_documents_id_fk": {+ "name": "agent_documents_document_id_documents_id_fk",+ "tableFrom": "agent_documents",+ "tableTo": "documents",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_documents_deleted_by_user_id_users_id_fk": {+ "name": "agent_documents_deleted_by_user_id_users_id_fk",+ "tableFrom": "agent_documents",+ "tableTo": "users",+ "columnsFrom": [+ "deleted_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_documents_deleted_by_agent_id_agents_id_fk": {+ "name": "agent_documents_deleted_by_agent_id_agents_id_fk",+ "tableFrom": "agent_documents",+ "tableTo": "agents",+ "columnsFrom": [+ "deleted_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_eval_benchmarks": {+ "name": "agent_eval_benchmarks",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "rubrics": {+ "name": "rubrics",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "reference_url": {+ "name": "reference_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "is_system": {+ "name": "is_system",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_eval_benchmarks_identifier_user_id_unique": {+ "name": "agent_eval_benchmarks_identifier_user_id_unique",+ "columns": [+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_eval_benchmarks\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_benchmarks_is_system_idx": {+ "name": "agent_eval_benchmarks_is_system_idx",+ "columns": [+ {+ "expression": "is_system",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_benchmarks_user_id_idx": {+ "name": "agent_eval_benchmarks_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_benchmarks_workspace_id_idx": {+ "name": "agent_eval_benchmarks_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_benchmarks_identifier_workspace_id_unique": {+ "name": "agent_eval_benchmarks_identifier_workspace_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_eval_benchmarks\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_eval_benchmarks_user_id_users_id_fk": {+ "name": "agent_eval_benchmarks_user_id_users_id_fk",+ "tableFrom": "agent_eval_benchmarks",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_benchmarks_workspace_id_workspaces_id_fk": {+ "name": "agent_eval_benchmarks_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_eval_benchmarks",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_eval_datasets": {+ "name": "agent_eval_datasets",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "benchmark_id": {+ "name": "benchmark_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source_experiment_id": {+ "name": "source_experiment_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "eval_mode": {+ "name": "eval_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "eval_config": {+ "name": "eval_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_eval_datasets_identifier_user_id_unique": {+ "name": "agent_eval_datasets_identifier_user_id_unique",+ "columns": [+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_eval_datasets\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_datasets_benchmark_id_idx": {+ "name": "agent_eval_datasets_benchmark_id_idx",+ "columns": [+ {+ "expression": "benchmark_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_datasets_source_experiment_id_idx": {+ "name": "agent_eval_datasets_source_experiment_id_idx",+ "columns": [+ {+ "expression": "source_experiment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_datasets_user_id_idx": {+ "name": "agent_eval_datasets_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_datasets_workspace_id_idx": {+ "name": "agent_eval_datasets_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_datasets_identifier_workspace_id_unique": {+ "name": "agent_eval_datasets_identifier_workspace_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_eval_datasets\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_eval_datasets_benchmark_id_agent_eval_benchmarks_id_fk": {+ "name": "agent_eval_datasets_benchmark_id_agent_eval_benchmarks_id_fk",+ "tableFrom": "agent_eval_datasets",+ "tableTo": "agent_eval_benchmarks",+ "columnsFrom": [+ "benchmark_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_datasets_source_experiment_id_agent_eval_experiments_id_fk": {+ "name": "agent_eval_datasets_source_experiment_id_agent_eval_experiments_id_fk",+ "tableFrom": "agent_eval_datasets",+ "tableTo": "agent_eval_experiments",+ "columnsFrom": [+ "source_experiment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_eval_datasets_user_id_users_id_fk": {+ "name": "agent_eval_datasets_user_id_users_id_fk",+ "tableFrom": "agent_eval_datasets",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_datasets_workspace_id_workspaces_id_fk": {+ "name": "agent_eval_datasets_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_eval_datasets",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_eval_experiment_benchmarks": {+ "name": "agent_eval_experiment_benchmarks",+ "schema": "",+ "columns": {+ "experiment_id": {+ "name": "experiment_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "benchmark_id": {+ "name": "benchmark_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_eval_experiment_benchmarks_benchmark_id_idx": {+ "name": "agent_eval_experiment_benchmarks_benchmark_id_idx",+ "columns": [+ {+ "expression": "benchmark_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_experiment_benchmarks_user_id_idx": {+ "name": "agent_eval_experiment_benchmarks_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_experiment_benchmarks_workspace_id_idx": {+ "name": "agent_eval_experiment_benchmarks_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_eval_experiment_benchmarks_experiment_id_agent_eval_experiments_id_fk": {+ "name": "agent_eval_experiment_benchmarks_experiment_id_agent_eval_experiments_id_fk",+ "tableFrom": "agent_eval_experiment_benchmarks",+ "tableTo": "agent_eval_experiments",+ "columnsFrom": [+ "experiment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_experiment_benchmarks_benchmark_id_agent_eval_benchmarks_id_fk": {+ "name": "agent_eval_experiment_benchmarks_benchmark_id_agent_eval_benchmarks_id_fk",+ "tableFrom": "agent_eval_experiment_benchmarks",+ "tableTo": "agent_eval_benchmarks",+ "columnsFrom": [+ "benchmark_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_experiment_benchmarks_user_id_users_id_fk": {+ "name": "agent_eval_experiment_benchmarks_user_id_users_id_fk",+ "tableFrom": "agent_eval_experiment_benchmarks",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_experiment_benchmarks_workspace_id_workspaces_id_fk": {+ "name": "agent_eval_experiment_benchmarks_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_eval_experiment_benchmarks",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agent_eval_experiment_benchmarks_experiment_id_benchmark_id_pk": {+ "name": "agent_eval_experiment_benchmarks_experiment_id_benchmark_id_pk",+ "columns": [+ "experiment_id",+ "benchmark_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_eval_experiments": {+ "name": "agent_eval_experiments",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_eval_experiments_user_id_idx": {+ "name": "agent_eval_experiments_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_experiments_workspace_id_idx": {+ "name": "agent_eval_experiments_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_eval_experiments_user_id_users_id_fk": {+ "name": "agent_eval_experiments_user_id_users_id_fk",+ "tableFrom": "agent_eval_experiments",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_experiments_workspace_id_workspaces_id_fk": {+ "name": "agent_eval_experiments_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_eval_experiments",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_eval_run_topics": {+ "name": "agent_eval_run_topics",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "run_id": {+ "name": "run_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "test_case_id": {+ "name": "test_case_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "score": {+ "name": "score",+ "type": "real",+ "primaryKey": false,+ "notNull": false+ },+ "passed": {+ "name": "passed",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "eval_result": {+ "name": "eval_result",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_eval_run_topics_user_id_idx": {+ "name": "agent_eval_run_topics_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_run_topics_run_id_idx": {+ "name": "agent_eval_run_topics_run_id_idx",+ "columns": [+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_run_topics_test_case_id_idx": {+ "name": "agent_eval_run_topics_test_case_id_idx",+ "columns": [+ {+ "expression": "test_case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_run_topics_workspace_id_idx": {+ "name": "agent_eval_run_topics_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_eval_run_topics_user_id_users_id_fk": {+ "name": "agent_eval_run_topics_user_id_users_id_fk",+ "tableFrom": "agent_eval_run_topics",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_run_topics_workspace_id_workspaces_id_fk": {+ "name": "agent_eval_run_topics_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_eval_run_topics",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_run_topics_run_id_agent_eval_runs_id_fk": {+ "name": "agent_eval_run_topics_run_id_agent_eval_runs_id_fk",+ "tableFrom": "agent_eval_run_topics",+ "tableTo": "agent_eval_runs",+ "columnsFrom": [+ "run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_run_topics_topic_id_topics_id_fk": {+ "name": "agent_eval_run_topics_topic_id_topics_id_fk",+ "tableFrom": "agent_eval_run_topics",+ "tableTo": "topics",+ "columnsFrom": [+ "topic_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_run_topics_test_case_id_agent_eval_test_cases_id_fk": {+ "name": "agent_eval_run_topics_test_case_id_agent_eval_test_cases_id_fk",+ "tableFrom": "agent_eval_run_topics",+ "tableTo": "agent_eval_test_cases",+ "columnsFrom": [+ "test_case_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agent_eval_run_topics_run_id_topic_id_pk": {+ "name": "agent_eval_run_topics_run_id_topic_id_pk",+ "columns": [+ "run_id",+ "topic_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_eval_runs": {+ "name": "agent_eval_runs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "dataset_id": {+ "name": "dataset_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "experiment_id": {+ "name": "experiment_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "parent_run_id": {+ "name": "parent_run_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "target_agent_id": {+ "name": "target_agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'idle'"+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metrics": {+ "name": "metrics",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_eval_runs_dataset_id_idx": {+ "name": "agent_eval_runs_dataset_id_idx",+ "columns": [+ {+ "expression": "dataset_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_runs_experiment_id_idx": {+ "name": "agent_eval_runs_experiment_id_idx",+ "columns": [+ {+ "expression": "experiment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_runs_parent_run_id_idx": {+ "name": "agent_eval_runs_parent_run_id_idx",+ "columns": [+ {+ "expression": "parent_run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_runs_user_id_idx": {+ "name": "agent_eval_runs_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_runs_status_idx": {+ "name": "agent_eval_runs_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_runs_target_agent_id_idx": {+ "name": "agent_eval_runs_target_agent_id_idx",+ "columns": [+ {+ "expression": "target_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_runs_workspace_id_idx": {+ "name": "agent_eval_runs_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_eval_runs_dataset_id_agent_eval_datasets_id_fk": {+ "name": "agent_eval_runs_dataset_id_agent_eval_datasets_id_fk",+ "tableFrom": "agent_eval_runs",+ "tableTo": "agent_eval_datasets",+ "columnsFrom": [+ "dataset_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_runs_experiment_id_agent_eval_experiments_id_fk": {+ "name": "agent_eval_runs_experiment_id_agent_eval_experiments_id_fk",+ "tableFrom": "agent_eval_runs",+ "tableTo": "agent_eval_experiments",+ "columnsFrom": [+ "experiment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "agent_eval_runs_target_agent_id_agents_id_fk": {+ "name": "agent_eval_runs_target_agent_id_agents_id_fk",+ "tableFrom": "agent_eval_runs",+ "tableTo": "agents",+ "columnsFrom": [+ "target_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_runs_user_id_users_id_fk": {+ "name": "agent_eval_runs_user_id_users_id_fk",+ "tableFrom": "agent_eval_runs",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_runs_workspace_id_workspaces_id_fk": {+ "name": "agent_eval_runs_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_eval_runs",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_runs_parent_run_id_agent_eval_runs_id_fk": {+ "name": "agent_eval_runs_parent_run_id_agent_eval_runs_id_fk",+ "tableFrom": "agent_eval_runs",+ "tableTo": "agent_eval_runs",+ "columnsFrom": [+ "parent_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_eval_test_cases": {+ "name": "agent_eval_test_cases",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "dataset_id": {+ "name": "dataset_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "eval_mode": {+ "name": "eval_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "eval_config": {+ "name": "eval_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "sort_order": {+ "name": "sort_order",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_eval_test_cases_user_id_idx": {+ "name": "agent_eval_test_cases_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_test_cases_dataset_id_idx": {+ "name": "agent_eval_test_cases_dataset_id_idx",+ "columns": [+ {+ "expression": "dataset_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_test_cases_sort_order_idx": {+ "name": "agent_eval_test_cases_sort_order_idx",+ "columns": [+ {+ "expression": "sort_order",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_test_cases_workspace_id_idx": {+ "name": "agent_eval_test_cases_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_eval_test_cases_user_id_users_id_fk": {+ "name": "agent_eval_test_cases_user_id_users_id_fk",+ "tableFrom": "agent_eval_test_cases",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_test_cases_workspace_id_workspaces_id_fk": {+ "name": "agent_eval_test_cases_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_eval_test_cases",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_test_cases_dataset_id_agent_eval_datasets_id_fk": {+ "name": "agent_eval_test_cases_dataset_id_agent_eval_datasets_id_fk",+ "tableFrom": "agent_eval_test_cases",+ "tableTo": "agent_eval_datasets",+ "columnsFrom": [+ "dataset_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_history_job_agents": {+ "name": "agent_history_job_agents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "job_id": {+ "name": "job_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "agent_history_job_agents_job_id_agent_id_unique": {+ "name": "agent_history_job_agents_job_id_agent_id_unique",+ "columns": [+ {+ "expression": "job_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_history_job_agents_agent_id_idx": {+ "name": "agent_history_job_agents_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_history_job_agents_job_id_agent_history_jobs_id_fk": {+ "name": "agent_history_job_agents_job_id_agent_history_jobs_id_fk",+ "tableFrom": "agent_history_job_agents",+ "tableTo": "agent_history_jobs",+ "columnsFrom": [+ "job_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_history_job_agents_agent_id_agents_id_fk": {+ "name": "agent_history_job_agents_agent_id_agents_id_fk",+ "tableFrom": "agent_history_job_agents",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_history_job_groups": {+ "name": "agent_history_job_groups",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "job_id": {+ "name": "job_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "agent_history_job_groups_job_id_group_id_unique": {+ "name": "agent_history_job_groups_job_id_group_id_unique",+ "columns": [+ {+ "expression": "job_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_history_job_groups_group_id_idx": {+ "name": "agent_history_job_groups_group_id_idx",+ "columns": [+ {+ "expression": "group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_history_job_groups_job_id_agent_history_jobs_id_fk": {+ "name": "agent_history_job_groups_job_id_agent_history_jobs_id_fk",+ "tableFrom": "agent_history_job_groups",+ "tableTo": "agent_history_jobs",+ "columnsFrom": [+ "job_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_history_job_groups_group_id_chat_groups_id_fk": {+ "name": "agent_history_job_groups_group_id_chat_groups_id_fk",+ "tableFrom": "agent_history_job_groups",+ "tableTo": "chat_groups",+ "columnsFrom": [+ "group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_history_job_topics": {+ "name": "agent_history_job_topics",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "job_id": {+ "name": "job_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "priority": {+ "name": "priority",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "activity_at": {+ "name": "activity_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "agent_history_job_topics_job_id_topic_id_unique": {+ "name": "agent_history_job_topics_job_id_topic_id_unique",+ "columns": [+ {+ "expression": "job_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_history_job_topics_topic_id_idx": {+ "name": "agent_history_job_topics_topic_id_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_history_job_topics_pick_idx": {+ "name": "agent_history_job_topics_pick_idx",+ "columns": [+ {+ "expression": "job_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "priority",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "activity_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_history_job_topics_job_id_agent_history_jobs_id_fk": {+ "name": "agent_history_job_topics_job_id_agent_history_jobs_id_fk",+ "tableFrom": "agent_history_job_topics",+ "tableTo": "agent_history_jobs",+ "columnsFrom": [+ "job_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_history_job_topics_topic_id_topics_id_fk": {+ "name": "agent_history_job_topics_topic_id_topics_id_fk",+ "tableFrom": "agent_history_job_topics",+ "tableTo": "topics",+ "columnsFrom": [+ "topic_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_history_jobs": {+ "name": "agent_history_jobs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'transfer'"+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "agent_ids": {+ "name": "agent_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "session_ids": {+ "name": "session_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "group_ids": {+ "name": "group_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "source_user_id": {+ "name": "source_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_workspace_id": {+ "name": "source_workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "target_user_id": {+ "name": "target_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "target_workspace_id": {+ "name": "target_workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "total_topics": {+ "name": "total_topics",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "completed_topics": {+ "name": "completed_topics",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_history_jobs_status_idx": {+ "name": "agent_history_jobs_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_history_jobs_source_user_id_idx": {+ "name": "agent_history_jobs_source_user_id_idx",+ "columns": [+ {+ "expression": "source_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_history_jobs_target_user_id_idx": {+ "name": "agent_history_jobs_target_user_id_idx",+ "columns": [+ {+ "expression": "target_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_history_jobs_source_workspace_id_idx": {+ "name": "agent_history_jobs_source_workspace_id_idx",+ "columns": [+ {+ "expression": "source_workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_history_jobs_target_workspace_id_idx": {+ "name": "agent_history_jobs_target_workspace_id_idx",+ "columns": [+ {+ "expression": "target_workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_intervention_resolutions": {+ "name": "agent_intervention_resolutions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "resolution_request_id": {+ "name": "resolution_request_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "operation_id": {+ "name": "operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "batch_id": {+ "name": "batch_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "actor_id": {+ "name": "actor_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "selected_intervention_ids": {+ "name": "selected_intervention_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "expected_versions": {+ "name": "expected_versions",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "expected_request_revision_hashes": {+ "name": "expected_request_revision_hashes",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "expected_item_count": {+ "name": "expected_item_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "action": {+ "name": "action",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "custom_execution_input_hash": {+ "name": "custom_execution_input_hash",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false+ },+ "custom_execution_state": {+ "name": "custom_execution_state",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "custom_execution_attempt": {+ "name": "custom_execution_attempt",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "custom_execution_lease_token": {+ "name": "custom_execution_lease_token",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "custom_execution_lease_expires_at": {+ "name": "custom_execution_lease_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "custom_execution_result": {+ "name": "custom_execution_result",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "remember_tool_key": {+ "name": "remember_tool_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "remember_effect_status": {+ "name": "remember_effect_status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "original_arguments": {+ "name": "original_arguments",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "edited_arguments": {+ "name": "edited_arguments",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "original_request_revision_hash": {+ "name": "original_request_revision_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "edited_request_revision_hash": {+ "name": "edited_request_revision_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "argument_effect_status": {+ "name": "argument_effect_status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'resolving'"+ },+ "resolving_at": {+ "name": "resolving_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "published_at": {+ "name": "published_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "continuation_started_at": {+ "name": "continuation_started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "producer_ack_at": {+ "name": "producer_ack_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "terminal_at": {+ "name": "terminal_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "rolled_back_at": {+ "name": "rolled_back_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_intervention_resolutions_request_unique": {+ "name": "agent_intervention_resolutions_request_unique",+ "columns": [+ {+ "expression": "resolution_request_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_intervention_resolutions_owner_batch_idx": {+ "name": "agent_intervention_resolutions_owner_batch_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "batch_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_intervention_resolutions_status_created_idx": {+ "name": "agent_intervention_resolutions_status_created_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_intervention_resolutions_operation_id_agent_operations_id_fk": {+ "name": "agent_intervention_resolutions_operation_id_agent_operations_id_fk",+ "tableFrom": "agent_intervention_resolutions",+ "tableTo": "agent_operations",+ "columnsFrom": [+ "operation_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_intervention_resolutions_user_id_users_id_fk": {+ "name": "agent_intervention_resolutions_user_id_users_id_fk",+ "tableFrom": "agent_intervention_resolutions",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_intervention_resolutions_workspace_id_workspaces_id_fk": {+ "name": "agent_intervention_resolutions_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_intervention_resolutions",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "agent_intervention_resolutions_expected_item_count_check": {+ "name": "agent_intervention_resolutions_expected_item_count_check",+ "value": "\"agent_intervention_resolutions\".\"expected_item_count\" > 0"+ },+ "agent_intervention_resolutions_custom_execution_input_hash_check": {+ "name": "agent_intervention_resolutions_custom_execution_input_hash_check",+ "value": "\"agent_intervention_resolutions\".\"custom_execution_input_hash\" IS NULL OR \"agent_intervention_resolutions\".\"custom_execution_input_hash\" ~ '^[a-f0-9]{64}$'"+ },+ "agent_intervention_resolutions_custom_execution_state_check": {+ "name": "agent_intervention_resolutions_custom_execution_state_check",+ "value": "(\n (\"agent_intervention_resolutions\".\"custom_execution_state\" IS NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_input_hash\" IS NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_attempt\" IS NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_token\" IS NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_expires_at\" IS NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_result\" IS NULL)\n OR\n (\"agent_intervention_resolutions\".\"custom_execution_state\" = 'pending'\n AND \"agent_intervention_resolutions\".\"custom_execution_attempt\" = 0\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_token\" IS NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_expires_at\" IS NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_result\" IS NULL)\n OR\n (\"agent_intervention_resolutions\".\"custom_execution_state\" = 'executing'\n AND \"agent_intervention_resolutions\".\"custom_execution_input_hash\" IS NOT NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_attempt\" > 0\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_token\" IS NOT NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_expires_at\" IS NOT NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_result\" IS NULL)\n OR\n (\"agent_intervention_resolutions\".\"custom_execution_state\" = 'completed'\n AND \"agent_intervention_resolutions\".\"custom_execution_input_hash\" IS NOT NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_attempt\" > 0\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_token\" IS NOT NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_expires_at\" IS NOT NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_result\" IS NOT NULL)\n )"+ },+ "agent_intervention_resolutions_custom_execution_parent_status_check": {+ "name": "agent_intervention_resolutions_custom_execution_parent_status_check",+ "value": "\"agent_intervention_resolutions\".\"custom_execution_state\" NOT IN ('executing', 'completed') OR \"agent_intervention_resolutions\".\"status\" IN ('resolving', 'published', 'acknowledged', 'completed')"+ },+ "agent_intervention_resolutions_version_check": {+ "name": "agent_intervention_resolutions_version_check",+ "value": "\"agent_intervention_resolutions\".\"version\" > 0"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_interventions": {+ "name": "agent_interventions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "operation_id": {+ "name": "operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "tool_call_id": {+ "name": "tool_call_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "tool_message_id": {+ "name": "tool_message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "interaction_kind": {+ "name": "interaction_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "surface": {+ "name": "surface",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "system_action_eligibility": {+ "name": "system_action_eligibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "approval_mode": {+ "name": "approval_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "batch_id": {+ "name": "batch_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "activity_key": {+ "name": "activity_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "step_index": {+ "name": "step_index",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "item_index": {+ "name": "item_index",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "item_count": {+ "name": "item_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "sealed": {+ "name": "sealed",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "canonical_tool_key": {+ "name": "canonical_tool_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "request_revision_hash": {+ "name": "request_revision_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "allowed_actions": {+ "name": "allowed_actions",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "risk": {+ "name": "risk",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "review_token_hash": {+ "name": "review_token_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "review_context": {+ "name": "review_context",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "sanitized_request": {+ "name": "sanitized_request",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "deadline": {+ "name": "deadline",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "resolution_id": {+ "name": "resolution_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "resolving_at": {+ "name": "resolving_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "published_at": {+ "name": "published_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_at": {+ "name": "resolved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "producer_ack_at": {+ "name": "producer_ack_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_interventions_operation_tool_call_unique": {+ "name": "agent_interventions_operation_tool_call_unique",+ "columns": [+ {+ "expression": "operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "tool_call_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_interventions_review_token_hash_unique": {+ "name": "agent_interventions_review_token_hash_unique",+ "columns": [+ {+ "expression": "review_token_hash",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_interventions_operation_batch_item_unique": {+ "name": "agent_interventions_operation_batch_item_unique",+ "columns": [+ {+ "expression": "operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "batch_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "item_index",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_interventions_owner_activity_item_unique": {+ "name": "agent_interventions_owner_activity_item_unique",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "activity_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "item_index",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_interventions_owner_status_deadline_idx": {+ "name": "agent_interventions_owner_status_deadline_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "deadline",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_interventions_owner_batch_idx": {+ "name": "agent_interventions_owner_batch_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "batch_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "item_index",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_interventions_activity_key_idx": {+ "name": "agent_interventions_activity_key_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "activity_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_interventions_status_deadline_idx": {+ "name": "agent_interventions_status_deadline_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "deadline",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_interventions_operation_id_agent_operations_id_fk": {+ "name": "agent_interventions_operation_id_agent_operations_id_fk",+ "tableFrom": "agent_interventions",+ "tableTo": "agent_operations",+ "columnsFrom": [+ "operation_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_interventions_user_id_users_id_fk": {+ "name": "agent_interventions_user_id_users_id_fk",+ "tableFrom": "agent_interventions",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_interventions_workspace_id_workspaces_id_fk": {+ "name": "agent_interventions_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_interventions",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_interventions_resolution_id_agent_intervention_resolutions_id_fk": {+ "name": "agent_interventions_resolution_id_agent_intervention_resolutions_id_fk",+ "tableFrom": "agent_interventions",+ "tableTo": "agent_intervention_resolutions",+ "columnsFrom": [+ "resolution_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "agent_interventions_review_token_hash_check": {+ "name": "agent_interventions_review_token_hash_check",+ "value": "\"agent_interventions\".\"review_token_hash\" ~ '^[a-f0-9]{64}$'"+ },+ "agent_interventions_request_revision_hash_check": {+ "name": "agent_interventions_request_revision_hash_check",+ "value": "\"agent_interventions\".\"request_revision_hash\" ~ '^[a-f0-9]{64}$'"+ },+ "agent_interventions_step_index_check": {+ "name": "agent_interventions_step_index_check",+ "value": "\"agent_interventions\".\"step_index\" >= 0"+ },+ "agent_interventions_item_bounds_check": {+ "name": "agent_interventions_item_bounds_check",+ "value": "\"agent_interventions\".\"item_count\" > 0 AND \"agent_interventions\".\"item_index\" >= 0 AND \"agent_interventions\".\"item_index\" < \"agent_interventions\".\"item_count\""+ },+ "agent_interventions_version_check": {+ "name": "agent_interventions_version_check",+ "value": "\"agent_interventions\".\"version\" > 0"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_label_assignments": {+ "name": "agent_label_assignments",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "label_id": {+ "name": "label_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_label_assignments_label_id_agent_id_unique": {+ "name": "agent_label_assignments_label_id_agent_id_unique",+ "columns": [+ {+ "expression": "label_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_label_assignments_agent_id_idx": {+ "name": "agent_label_assignments_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_label_assignments_workspace_id_idx": {+ "name": "agent_label_assignments_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_label_assignments_label_id_agent_labels_id_fk": {+ "name": "agent_label_assignments_label_id_agent_labels_id_fk",+ "tableFrom": "agent_label_assignments",+ "tableTo": "agent_labels",+ "columnsFrom": [+ "label_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_label_assignments_agent_id_agents_id_fk": {+ "name": "agent_label_assignments_agent_id_agents_id_fk",+ "tableFrom": "agent_label_assignments",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_label_assignments_user_id_users_id_fk": {+ "name": "agent_label_assignments_user_id_users_id_fk",+ "tableFrom": "agent_label_assignments",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_label_assignments_workspace_id_workspaces_id_fk": {+ "name": "agent_label_assignments_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_label_assignments",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_labels": {+ "name": "agent_labels",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "archived": {+ "name": "archived",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_labels_user_id_idx": {+ "name": "agent_labels_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_labels_workspace_id_idx": {+ "name": "agent_labels_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_labels_user_id_name_unique": {+ "name": "agent_labels_user_id_name_unique",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_labels\".\"workspace_id\" IS NULL AND \"agent_labels\".\"archived\" = false",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_labels_workspace_id_name_unique": {+ "name": "agent_labels_workspace_id_name_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_labels\".\"workspace_id\" IS NOT NULL AND \"agent_labels\".\"archived\" = false",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_labels_user_id_users_id_fk": {+ "name": "agent_labels_user_id_users_id_fk",+ "tableFrom": "agent_labels",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_labels_workspace_id_workspaces_id_fk": {+ "name": "agent_labels_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_labels",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_operations": {+ "name": "agent_operations",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "task_id": {+ "name": "task_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "chat_group_id": {+ "name": "chat_group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "parent_operation_id": {+ "name": "parent_operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "completion_reason": {+ "name": "completion_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "verify_status": {+ "name": "verify_status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "verify_plan": {+ "name": "verify_plan",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "verify_plan_confirmed_at": {+ "name": "verify_plan_confirmed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "step_count": {+ "name": "step_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "max_steps": {+ "name": "max_steps",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "force_finish": {+ "name": "force_finish",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "interruption": {+ "name": "interruption",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "error": {+ "name": "error",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "total_cost": {+ "name": "total_cost",+ "type": "numeric(20, 6)",+ "primaryKey": false,+ "notNull": false+ },+ "currency": {+ "name": "currency",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'USD'"+ },+ "total_input_tokens": {+ "name": "total_input_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "total_output_tokens": {+ "name": "total_output_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "total_tokens": {+ "name": "total_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "llm_calls": {+ "name": "llm_calls",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "tool_calls": {+ "name": "tool_calls",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "human_interventions": {+ "name": "human_interventions",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "processing_time_ms": {+ "name": "processing_time_ms",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "human_waiting_time_ms": {+ "name": "human_waiting_time_ms",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "cost": {+ "name": "cost",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "usage": {+ "name": "usage",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "cost_limit": {+ "name": "cost_limit",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "model_runtime_config": {+ "name": "model_runtime_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "trigger": {+ "name": "trigger",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "app_context": {+ "name": "app_context",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "trace_s3_key": {+ "name": "trace_s3_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_operations_user_id_idx": {+ "name": "agent_operations_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_operations_workspace_id_idx": {+ "name": "agent_operations_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_operations_agent_id_idx": {+ "name": "agent_operations_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_operations_topic_id_idx": {+ "name": "agent_operations_topic_id_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_operations_thread_id_idx": {+ "name": "agent_operations_thread_id_idx",+ "columns": [+ {+ "expression": "thread_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_operations_task_id_idx": {+ "name": "agent_operations_task_id_idx",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_operations_chat_group_id_idx": {+ "name": "agent_operations_chat_group_id_idx",+ "columns": [+ {+ "expression": "chat_group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_operations_parent_operation_id_idx": {+ "name": "agent_operations_parent_operation_id_idx",+ "columns": [+ {+ "expression": "parent_operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_operations_status_idx": {+ "name": "agent_operations_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_operations_user_id_created_at_idx": {+ "name": "agent_operations_user_id_created_at_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_operations_metadata_idx": {+ "name": "agent_operations_metadata_idx",+ "columns": [+ {+ "expression": "metadata",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "gin",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_operations_workspace_id_workspaces_id_fk": {+ "name": "agent_operations_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_operations",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_operations_agent_id_agents_id_fk": {+ "name": "agent_operations_agent_id_agents_id_fk",+ "tableFrom": "agent_operations",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_operations_topic_id_topics_id_fk": {+ "name": "agent_operations_topic_id_topics_id_fk",+ "tableFrom": "agent_operations",+ "tableTo": "topics",+ "columnsFrom": [+ "topic_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_operations_thread_id_threads_id_fk": {+ "name": "agent_operations_thread_id_threads_id_fk",+ "tableFrom": "agent_operations",+ "tableTo": "threads",+ "columnsFrom": [+ "thread_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_operations_task_id_tasks_id_fk": {+ "name": "agent_operations_task_id_tasks_id_fk",+ "tableFrom": "agent_operations",+ "tableTo": "tasks",+ "columnsFrom": [+ "task_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_operations_chat_group_id_chat_groups_id_fk": {+ "name": "agent_operations_chat_group_id_chat_groups_id_fk",+ "tableFrom": "agent_operations",+ "tableTo": "chat_groups",+ "columnsFrom": [+ "chat_group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_account_bindings": {+ "name": "agent_account_bindings",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "account_id": {+ "name": "account_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pool'"+ },+ "priority": {+ "name": "priority",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "weight": {+ "name": "weight",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_account_bindings_agent_account_unique": {+ "name": "agent_account_bindings_agent_account_unique",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_account_bindings_agent_pinned_unique": {+ "name": "agent_account_bindings_agent_pinned_unique",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_account_bindings\".\"role\" = 'pinned'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_account_bindings_agent_id_idx": {+ "name": "agent_account_bindings_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_account_bindings_account_id_idx": {+ "name": "agent_account_bindings_account_id_idx",+ "columns": [+ {+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_account_bindings_user_id_idx": {+ "name": "agent_account_bindings_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_account_bindings_workspace_id_idx": {+ "name": "agent_account_bindings_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_account_bindings_agent_id_agents_id_fk": {+ "name": "agent_account_bindings_agent_id_agents_id_fk",+ "tableFrom": "agent_account_bindings",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_account_bindings_account_id_agent_provider_accounts_id_fk": {+ "name": "agent_account_bindings_account_id_agent_provider_accounts_id_fk",+ "tableFrom": "agent_account_bindings",+ "tableTo": "agent_provider_accounts",+ "columnsFrom": [+ "account_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_account_bindings_user_id_users_id_fk": {+ "name": "agent_account_bindings_user_id_users_id_fk",+ "tableFrom": "agent_account_bindings",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_account_bindings_workspace_id_workspaces_id_fk": {+ "name": "agent_account_bindings_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_account_bindings",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_provider_accounts": {+ "name": "agent_provider_accounts",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "external_account_id": {+ "name": "external_account_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "display_name": {+ "name": "display_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "organization_id": {+ "name": "organization_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "plan_tier": {+ "name": "plan_tier",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "rate_limit_tier": {+ "name": "rate_limit_tier",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "label": {+ "name": "label",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "credential_mode": {+ "name": "credential_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'referenced'"+ },+ "credentials": {+ "name": "credentials",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "credential_ref": {+ "name": "credential_ref",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "token_expires_at": {+ "name": "token_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "last_validated_at": {+ "name": "last_validated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_provider_accounts_user_id_idx": {+ "name": "agent_provider_accounts_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_provider_accounts_workspace_id_idx": {+ "name": "agent_provider_accounts_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_provider_accounts_token_expires_at_idx": {+ "name": "agent_provider_accounts_token_expires_at_idx",+ "columns": [+ {+ "expression": "token_expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_provider_accounts_identity_unique": {+ "name": "agent_provider_accounts_identity_unique",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "external_account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_provider_accounts\".\"external_account_id\" IS NOT NULL and \"agent_provider_accounts\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_provider_accounts_identity_workspace_unique": {+ "name": "agent_provider_accounts_identity_workspace_unique",+ "columns": [+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "external_account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_provider_accounts\".\"external_account_id\" IS NOT NULL and \"agent_provider_accounts\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_provider_accounts_user_id_users_id_fk": {+ "name": "agent_provider_accounts_user_id_users_id_fk",+ "tableFrom": "agent_provider_accounts",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_provider_accounts_workspace_id_workspaces_id_fk": {+ "name": "agent_provider_accounts_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_provider_accounts",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_quota_calibrations": {+ "name": "agent_quota_calibrations",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "account_id": {+ "name": "account_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "limit_type": {+ "name": "limit_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope_key": {+ "name": "scope_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "capacity_usd": {+ "name": "capacity_usd",+ "type": "numeric(20, 6)",+ "primaryKey": false,+ "notNull": true+ },+ "capacity_tokens_equivalent": {+ "name": "capacity_tokens_equivalent",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false+ },+ "model_mix": {+ "name": "model_mix",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "sample_count": {+ "name": "sample_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "confidence": {+ "name": "confidence",+ "type": "numeric(20, 6)",+ "primaryKey": false,+ "notNull": false+ },+ "method": {+ "name": "method",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "window_seconds": {+ "name": "window_seconds",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "calibrated_at": {+ "name": "calibrated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_quota_calibrations_account_type_scope_idx": {+ "name": "agent_quota_calibrations_account_type_scope_idx",+ "columns": [+ {+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "limit_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "scope_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "calibrated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_calibrations_workspace_id_idx": {+ "name": "agent_quota_calibrations_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_quota_calibrations_account_id_agent_provider_accounts_id_fk": {+ "name": "agent_quota_calibrations_account_id_agent_provider_accounts_id_fk",+ "tableFrom": "agent_quota_calibrations",+ "tableTo": "agent_provider_accounts",+ "columnsFrom": [+ "account_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_quota_calibrations_user_id_users_id_fk": {+ "name": "agent_quota_calibrations_user_id_users_id_fk",+ "tableFrom": "agent_quota_calibrations",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_quota_calibrations_workspace_id_workspaces_id_fk": {+ "name": "agent_quota_calibrations_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_quota_calibrations",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_quota_snapshots": {+ "name": "agent_quota_snapshots",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "account_id": {+ "name": "account_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "device_id": {+ "name": "device_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "limit_type": {+ "name": "limit_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope_key": {+ "name": "scope_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "resets_at": {+ "name": "resets_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "utilization": {+ "name": "utilization",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "severity": {+ "name": "severity",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "is_active": {+ "name": "is_active",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "raw": {+ "name": "raw",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_quota_snapshots_account_type_scope_idx": {+ "name": "agent_quota_snapshots_account_type_scope_idx",+ "columns": [+ {+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "limit_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "scope_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "captured_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_snapshots_account_captured_idx": {+ "name": "agent_quota_snapshots_account_captured_idx",+ "columns": [+ {+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "captured_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_snapshots_resets_at_idx": {+ "name": "agent_quota_snapshots_resets_at_idx",+ "columns": [+ {+ "expression": "resets_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_snapshots_workspace_id_idx": {+ "name": "agent_quota_snapshots_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_quota_snapshots_account_id_agent_provider_accounts_id_fk": {+ "name": "agent_quota_snapshots_account_id_agent_provider_accounts_id_fk",+ "tableFrom": "agent_quota_snapshots",+ "tableTo": "agent_provider_accounts",+ "columnsFrom": [+ "account_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_quota_snapshots_user_id_users_id_fk": {+ "name": "agent_quota_snapshots_user_id_users_id_fk",+ "tableFrom": "agent_quota_snapshots",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_quota_snapshots_workspace_id_workspaces_id_fk": {+ "name": "agent_quota_snapshots_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_quota_snapshots",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_quota_snapshots_device_id_devices_id_fk": {+ "name": "agent_quota_snapshots_device_id_devices_id_fk",+ "tableFrom": "agent_quota_snapshots",+ "tableTo": "devices",+ "columnsFrom": [+ "device_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_quota_usage_ledger": {+ "name": "agent_quota_usage_ledger",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "account_id": {+ "name": "account_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "occurred_at": {+ "name": "occurred_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "input_tokens": {+ "name": "input_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "output_tokens": {+ "name": "output_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "cache_read_tokens": {+ "name": "cache_read_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "cache_write_tokens": {+ "name": "cache_write_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "reasoning_tokens": {+ "name": "reasoning_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "cost_usd": {+ "name": "cost_usd",+ "type": "numeric(20, 6)",+ "primaryKey": false,+ "notNull": false+ },+ "cost_source": {+ "name": "cost_source",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "message_id": {+ "name": "message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "operation_id": {+ "name": "operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "external_event_id": {+ "name": "external_event_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_quota_usage_ledger_account_occurred_idx": {+ "name": "agent_quota_usage_ledger_account_occurred_idx",+ "columns": [+ {+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "occurred_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_usage_ledger_account_model_occurred_idx": {+ "name": "agent_quota_usage_ledger_account_model_occurred_idx",+ "columns": [+ {+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "model",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "occurred_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_usage_ledger_message_id_idx": {+ "name": "agent_quota_usage_ledger_message_id_idx",+ "columns": [+ {+ "expression": "message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_usage_ledger_operation_id_idx": {+ "name": "agent_quota_usage_ledger_operation_id_idx",+ "columns": [+ {+ "expression": "operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_usage_ledger_workspace_id_idx": {+ "name": "agent_quota_usage_ledger_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_usage_ledger_external_event_unique": {+ "name": "agent_quota_usage_ledger_external_event_unique",+ "columns": [+ {+ "expression": "external_event_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_quota_usage_ledger\".\"external_event_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_quota_usage_ledger_account_id_agent_provider_accounts_id_fk": {+ "name": "agent_quota_usage_ledger_account_id_agent_provider_accounts_id_fk",+ "tableFrom": "agent_quota_usage_ledger",+ "tableTo": "agent_provider_accounts",+ "columnsFrom": [+ "account_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_quota_usage_ledger_user_id_users_id_fk": {+ "name": "agent_quota_usage_ledger_user_id_users_id_fk",+ "tableFrom": "agent_quota_usage_ledger",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_quota_usage_ledger_workspace_id_workspaces_id_fk": {+ "name": "agent_quota_usage_ledger_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_quota_usage_ledger",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_quota_usage_ledger_message_id_messages_id_fk": {+ "name": "agent_quota_usage_ledger_message_id_messages_id_fk",+ "tableFrom": "agent_quota_usage_ledger",+ "tableTo": "messages",+ "columnsFrom": [+ "message_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_quota_usage_ledger_operation_id_agent_operations_id_fk": {+ "name": "agent_quota_usage_ledger_operation_id_agent_operations_id_fk",+ "tableFrom": "agent_quota_usage_ledger",+ "tableTo": "agent_operations",+ "columnsFrom": [+ "operation_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_quota_usage_ledger_topic_id_topics_id_fk": {+ "name": "agent_quota_usage_ledger_topic_id_topics_id_fk",+ "tableFrom": "agent_quota_usage_ledger",+ "tableTo": "topics",+ "columnsFrom": [+ "topic_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_quota_usage_ledger_agent_id_agents_id_fk": {+ "name": "agent_quota_usage_ledger_agent_id_agents_id_fk",+ "tableFrom": "agent_quota_usage_ledger",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_quota_windows": {+ "name": "agent_quota_windows",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "account_id": {+ "name": "account_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "limit_type": {+ "name": "limit_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope_key": {+ "name": "scope_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "resets_at": {+ "name": "resets_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "window_start_at": {+ "name": "window_start_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "window_seconds": {+ "name": "window_seconds",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "peak_utilization": {+ "name": "peak_utilization",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "last_utilization": {+ "name": "last_utilization",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "rate_limited_at": {+ "name": "rate_limited_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "observed_cost_usd": {+ "name": "observed_cost_usd",+ "type": "numeric(20, 6)",+ "primaryKey": false,+ "notNull": false+ },+ "observed_tokens": {+ "name": "observed_tokens",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false+ },+ "estimated_capacity_usd": {+ "name": "estimated_capacity_usd",+ "type": "numeric(20, 6)",+ "primaryKey": false,+ "notNull": false+ },+ "contaminated": {+ "name": "contaminated",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "first_seen_at": {+ "name": "first_seen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_seen_at": {+ "name": "last_seen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_quota_windows_natural_key_unique": {+ "name": "agent_quota_windows_natural_key_unique",+ "columns": [+ {+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "limit_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "scope_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resets_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_windows_account_resets_idx": {+ "name": "agent_quota_windows_account_resets_idx",+ "columns": [+ {+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resets_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_windows_user_id_idx": {+ "name": "agent_quota_windows_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_windows_workspace_id_idx": {+ "name": "agent_quota_windows_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_quota_windows_account_id_agent_provider_accounts_id_fk": {+ "name": "agent_quota_windows_account_id_agent_provider_accounts_id_fk",+ "tableFrom": "agent_quota_windows",+ "tableTo": "agent_provider_accounts",+ "columnsFrom": [+ "account_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_quota_windows_user_id_users_id_fk": {+ "name": "agent_quota_windows_user_id_users_id_fk",+ "tableFrom": "agent_quota_windows",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_quota_windows_workspace_id_workspaces_id_fk": {+ "name": "agent_quota_windows_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_quota_windows",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_shares": {+ "name": "agent_shares",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'private'"+ },+ "share_config": {+ "name": "share_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "user_view_count": {+ "name": "user_view_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_shares_agent_id_unique": {+ "name": "agent_shares_agent_id_unique",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_shares_visibility_idx": {+ "name": "agent_shares_visibility_idx",+ "columns": [+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_shares_agent_id_agents_id_fk": {+ "name": "agent_shares_agent_id_agents_id_fk",+ "tableFrom": "agent_shares",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_skills": {+ "name": "agent_skills",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "manifest": {+ "name": "manifest",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "resources": {+ "name": "resources",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "zip_file_hash": {+ "name": "zip_file_hash",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_deleted": {+ "name": "is_deleted",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_skills_user_name_idx": {+ "name": "agent_skills_user_name_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_skills\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_skills_identifier_idx": {+ "name": "agent_skills_identifier_idx",+ "columns": [+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_skills_user_id_idx": {+ "name": "agent_skills_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_skills_source_idx": {+ "name": "agent_skills_source_idx",+ "columns": [+ {+ "expression": "source",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_skills_zip_hash_idx": {+ "name": "agent_skills_zip_hash_idx",+ "columns": [+ {+ "expression": "zip_file_hash",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_skills_workspace_id_idx": {+ "name": "agent_skills_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_skills_name_workspace_id_unique": {+ "name": "agent_skills_name_workspace_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_skills\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_skills_zip_file_hash_global_files_hash_id_fk": {+ "name": "agent_skills_zip_file_hash_global_files_hash_id_fk",+ "tableFrom": "agent_skills",+ "tableTo": "global_files",+ "columnsFrom": [+ "zip_file_hash"+ ],+ "columnsTo": [+ "hash_id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_skills_user_id_users_id_fk": {+ "name": "agent_skills_user_id_users_id_fk",+ "tableFrom": "agent_skills",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_skills_workspace_id_workspaces_id_fk": {+ "name": "agent_skills_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_skills",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.ai_models": {+ "name": "ai_models",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(150)",+ "primaryKey": false,+ "notNull": true+ },+ "_id": {+ "name": "_id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "display_name": {+ "name": "display_name",+ "type": "varchar(200)",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "organization": {+ "name": "organization",+ "type": "varchar(100)",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "provider_id": {+ "name": "provider_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true+ },+ "type": {+ "name": "type",+ "type": "varchar(20)",+ "primaryKey": false,+ "notNull": true,+ "default": "'chat'"+ },+ "sort": {+ "name": "sort",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "pricing": {+ "name": "pricing",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "parameters": {+ "name": "parameters",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "abilities": {+ "name": "abilities",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "context_window_tokens": {+ "name": "context_window_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "source": {+ "name": "source",+ "type": "varchar(20)",+ "primaryKey": false,+ "notNull": false+ },+ "released_at": {+ "name": "released_at",+ "type": "varchar(10)",+ "primaryKey": false,+ "notNull": false+ },+ "settings": {+ "name": "settings",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "ai_models_id_provider_id_user_id_unique": {+ "name": "ai_models_id_provider_id_user_id_unique",+ "columns": [+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"ai_models\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "ai_models_id_provider_id_user_id_workspace_id_unique": {+ "name": "ai_models_id_provider_id_user_id_workspace_id_unique",+ "columns": [+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"ai_models\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "ai_models_user_id_idx": {+ "name": "ai_models_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "ai_models_workspace_id_idx": {+ "name": "ai_models_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "ai_models_user_id_users_id_fk": {+ "name": "ai_models_user_id_users_id_fk",+ "tableFrom": "ai_models",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "ai_models_workspace_id_workspaces_id_fk": {+ "name": "ai_models_workspace_id_workspaces_id_fk",+ "tableFrom": "ai_models",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.ai_providers": {+ "name": "ai_providers",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "_id": {+ "name": "_id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "sort": {+ "name": "sort",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "fetch_on_client": {+ "name": "fetch_on_client",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "check_model": {+ "name": "check_model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "logo": {+ "name": "logo",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "key_vaults": {+ "name": "key_vaults",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source": {+ "name": "source",+ "type": "varchar(20)",+ "primaryKey": false,+ "notNull": false+ },+ "settings": {+ "name": "settings",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "ai_providers_id_user_id_unique": {+ "name": "ai_providers_id_user_id_unique",+ "columns": [+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"ai_providers\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "ai_providers_id_user_id_workspace_id_unique": {+ "name": "ai_providers_id_user_id_workspace_id_unique",+ "columns": [+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"ai_providers\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "ai_providers_user_id_idx": {+ "name": "ai_providers_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "ai_providers_workspace_id_idx": {+ "name": "ai_providers_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "ai_providers_user_id_users_id_fk": {+ "name": "ai_providers_user_id_users_id_fk",+ "tableFrom": "ai_providers",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "ai_providers_workspace_id_workspaces_id_fk": {+ "name": "ai_providers_workspace_id_workspaces_id_fk",+ "tableFrom": "ai_providers",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.api_keys": {+ "name": "api_keys",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "varchar(256)",+ "primaryKey": false,+ "notNull": true+ },+ "key": {+ "name": "key",+ "type": "varchar(256)",+ "primaryKey": false,+ "notNull": true+ },+ "key_hash": {+ "name": "key_hash",+ "type": "varchar(128)",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": true+ },+ "scopes": {+ "name": "scopes",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_used_at": {+ "name": "last_used_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "api_keys_user_id_idx": {+ "name": "api_keys_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "api_keys_workspace_id_idx": {+ "name": "api_keys_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "api_keys_user_id_users_id_fk": {+ "name": "api_keys_user_id_users_id_fk",+ "tableFrom": "api_keys",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "api_keys_workspace_id_workspaces_id_fk": {+ "name": "api_keys_workspace_id_workspaces_id_fk",+ "tableFrom": "api_keys",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "api_keys_key_unique": {+ "name": "api_keys_key_unique",+ "nullsNotDistinct": false,+ "columns": [+ "key"+ ]+ },+ "api_keys_key_hash_unique": {+ "name": "api_keys_key_hash_unique",+ "nullsNotDistinct": false,+ "columns": [+ "key_hash"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.async_tasks": {+ "name": "async_tasks",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "error": {+ "name": "error",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "inference_id": {+ "name": "inference_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "duration": {+ "name": "duration",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "parent_id": {+ "name": "parent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "async_tasks_user_id_idx": {+ "name": "async_tasks_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "async_tasks_parent_id_idx": {+ "name": "async_tasks_parent_id_idx",+ "columns": [+ {+ "expression": "parent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "async_tasks_type_status_idx": {+ "name": "async_tasks_type_status_idx",+ "columns": [+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "async_tasks_inference_id_idx": {+ "name": "async_tasks_inference_id_idx",+ "columns": [+ {+ "expression": "inference_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "async_tasks_metadata_idx": {+ "name": "async_tasks_metadata_idx",+ "columns": [+ {+ "expression": "metadata",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "gin",+ "with": {}+ },+ "async_tasks_workspace_id_idx": {+ "name": "async_tasks_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "async_tasks_user_id_users_id_fk": {+ "name": "async_tasks_user_id_users_id_fk",+ "tableFrom": "async_tasks",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "async_tasks_workspace_id_workspaces_id_fk": {+ "name": "async_tasks_workspace_id_workspaces_id_fk",+ "tableFrom": "async_tasks",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.accounts": {+ "name": "accounts",+ "schema": "",+ "columns": {+ "access_token": {+ "name": "access_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "access_token_expires_at": {+ "name": "access_token_expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "account_id": {+ "name": "account_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "id_token": {+ "name": "id_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "password": {+ "name": "password",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider_id": {+ "name": "provider_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "refresh_token": {+ "name": "refresh_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "refresh_token_expires_at": {+ "name": "refresh_token_expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "account_userId_idx": {+ "name": "account_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "accounts_user_id_users_id_fk": {+ "name": "accounts_user_id_users_id_fk",+ "tableFrom": "accounts",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.passkey": {+ "name": "passkey",+ "schema": "",+ "columns": {+ "aaguid": {+ "name": "aaguid",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "backedUp": {+ "name": "backedUp",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "counter": {+ "name": "counter",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "default": "now()"+ },+ "credentialID": {+ "name": "credentialID",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "deviceType": {+ "name": "deviceType",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "publicKey": {+ "name": "publicKey",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "transports": {+ "name": "transports",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "userId": {+ "name": "userId",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "passkey_credential_id_unique": {+ "name": "passkey_credential_id_unique",+ "columns": [+ {+ "expression": "credentialID",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "passkey_user_id_idx": {+ "name": "passkey_user_id_idx",+ "columns": [+ {+ "expression": "userId",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "passkey_userId_users_id_fk": {+ "name": "passkey_userId_users_id_fk",+ "tableFrom": "passkey",+ "tableTo": "users",+ "columnsFrom": [+ "userId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.auth_sessions": {+ "name": "auth_sessions",+ "schema": "",+ "columns": {+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "impersonated_by": {+ "name": "impersonated_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "ip_address": {+ "name": "ip_address",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "user_agent": {+ "name": "user_agent",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "auth_session_userId_idx": {+ "name": "auth_session_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "auth_sessions_user_id_users_id_fk": {+ "name": "auth_sessions_user_id_users_id_fk",+ "tableFrom": "auth_sessions",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "auth_sessions_token_unique": {+ "name": "auth_sessions_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "token"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.two_factor": {+ "name": "two_factor",+ "schema": "",+ "columns": {+ "backup_codes": {+ "name": "backup_codes",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "secret": {+ "name": "secret",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "two_factor_secret_idx": {+ "name": "two_factor_secret_idx",+ "columns": [+ {+ "expression": "secret",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "two_factor_user_id_idx": {+ "name": "two_factor_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "two_factor_user_id_users_id_fk": {+ "name": "two_factor_user_id_users_id_fk",+ "tableFrom": "two_factor",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.verifications": {+ "name": "verifications",+ "schema": "",+ "columns": {+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "verification_identifier_idx": {+ "name": "verification_identifier_idx",+ "columns": [+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.chat_groups": {+ "name": "chat_groups",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "avatar": {+ "name": "avatar",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "background_color": {+ "name": "background_color",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "market_identifier": {+ "name": "market_identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "pinned": {+ "name": "pinned",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_deleted": {+ "name": "is_deleted",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "chat_groups_client_id_user_id_unique": {+ "name": "chat_groups_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_groups_user_id_idx": {+ "name": "chat_groups_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_groups_group_id_idx": {+ "name": "chat_groups_group_id_idx",+ "columns": [+ {+ "expression": "group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_groups_workspace_id_idx": {+ "name": "chat_groups_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_groups_workspace_visibility_idx": {+ "name": "chat_groups_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "chat_groups_user_id_users_id_fk": {+ "name": "chat_groups_user_id_users_id_fk",+ "tableFrom": "chat_groups",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_groups_workspace_id_workspaces_id_fk": {+ "name": "chat_groups_workspace_id_workspaces_id_fk",+ "tableFrom": "chat_groups",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_groups_group_id_session_groups_id_fk": {+ "name": "chat_groups_group_id_session_groups_id_fk",+ "tableFrom": "chat_groups",+ "tableTo": "session_groups",+ "columnsFrom": [+ "group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.chat_groups_agents": {+ "name": "chat_groups_agents",+ "schema": "",+ "columns": {+ "chat_group_id": {+ "name": "chat_group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": true+ },+ "order": {+ "name": "order",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "default": "'participant'"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "chat_groups_agents_user_id_idx": {+ "name": "chat_groups_agents_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_groups_agents_workspace_id_idx": {+ "name": "chat_groups_agents_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "chat_groups_agents_chat_group_id_chat_groups_id_fk": {+ "name": "chat_groups_agents_chat_group_id_chat_groups_id_fk",+ "tableFrom": "chat_groups_agents",+ "tableTo": "chat_groups",+ "columnsFrom": [+ "chat_group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_groups_agents_agent_id_agents_id_fk": {+ "name": "chat_groups_agents_agent_id_agents_id_fk",+ "tableFrom": "chat_groups_agents",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_groups_agents_user_id_users_id_fk": {+ "name": "chat_groups_agents_user_id_users_id_fk",+ "tableFrom": "chat_groups_agents",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_groups_agents_workspace_id_workspaces_id_fk": {+ "name": "chat_groups_agents_workspace_id_workspaces_id_fk",+ "tableFrom": "chat_groups_agents",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "chat_groups_agents_chat_group_id_agent_id_pk": {+ "name": "chat_groups_agents_chat_group_id_agent_id_pk",+ "columns": [+ "chat_group_id",+ "agent_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_connector_tools": {+ "name": "user_connector_tools",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_connector_id": {+ "name": "user_connector_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "tool_name": {+ "name": "tool_name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "display_name": {+ "name": "display_name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "input_schema": {+ "name": "input_schema",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "output_schema": {+ "name": "output_schema",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "crud_type": {+ "name": "crud_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "render_config": {+ "name": "render_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "permission": {+ "name": "permission",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "is_work_artifact": {+ "name": "is_work_artifact",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "work_artifact_config": {+ "name": "work_artifact_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "limit_config": {+ "name": "limit_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_connector_tools_connector_tool_unique": {+ "name": "user_connector_tools_connector_tool_unique",+ "columns": [+ {+ "expression": "user_connector_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "tool_name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_connector_tools_user_id_idx": {+ "name": "user_connector_tools_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_connector_tools_connector_id_idx": {+ "name": "user_connector_tools_connector_id_idx",+ "columns": [+ {+ "expression": "user_connector_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_connector_tools_workspace_id_idx": {+ "name": "user_connector_tools_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_connector_tools_user_connector_id_user_connectors_id_fk": {+ "name": "user_connector_tools_user_connector_id_user_connectors_id_fk",+ "tableFrom": "user_connector_tools",+ "tableTo": "user_connectors",+ "columnsFrom": [+ "user_connector_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_connector_tools_user_id_users_id_fk": {+ "name": "user_connector_tools_user_id_users_id_fk",+ "tableFrom": "user_connector_tools",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_connector_tools_workspace_id_workspaces_id_fk": {+ "name": "user_connector_tools_workspace_id_workspaces_id_fk",+ "tableFrom": "user_connector_tools",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_connectors": {+ "name": "user_connectors",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "identifier": {+ "name": "identifier",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "source_type": {+ "name": "source_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "mcp_server_url": {+ "name": "mcp_server_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "mcp_connection_type": {+ "name": "mcp_connection_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "mcp_stdio_config": {+ "name": "mcp_stdio_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "is_enabled": {+ "name": "is_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "oidc_config": {+ "name": "oidc_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "credentials": {+ "name": "credentials",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "token_expires_at": {+ "name": "token_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_connectors_personal_identifier_idx": {+ "name": "user_connectors_personal_identifier_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"user_connectors\".\"workspace_id\" IS NULL AND \"user_connectors\".\"agent_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_connectors_workspace_identifier_idx": {+ "name": "user_connectors_workspace_identifier_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"user_connectors\".\"workspace_id\" IS NOT NULL AND \"user_connectors\".\"agent_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_connectors_agent_identifier_idx": {+ "name": "user_connectors_agent_identifier_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"user_connectors\".\"agent_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_connectors_user_id_idx": {+ "name": "user_connectors_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_connectors_token_expires_at_idx": {+ "name": "user_connectors_token_expires_at_idx",+ "columns": [+ {+ "expression": "token_expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_connectors_workspace_id_idx": {+ "name": "user_connectors_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_connectors_agent_id_idx": {+ "name": "user_connectors_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_connectors_user_id_users_id_fk": {+ "name": "user_connectors_user_id_users_id_fk",+ "tableFrom": "user_connectors",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_connectors_workspace_id_workspaces_id_fk": {+ "name": "user_connectors_workspace_id_workspaces_id_fk",+ "tableFrom": "user_connectors",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_connectors_agent_id_agents_id_fk": {+ "name": "user_connectors_agent_id_agents_id_fk",+ "tableFrom": "user_connectors",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_installed_plugins": {+ "name": "user_installed_plugins",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "manifest": {+ "name": "manifest",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "settings": {+ "name": "settings",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "custom_params": {+ "name": "custom_params",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "source": {+ "name": "source",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_installed_plugins_workspace_id_idx": {+ "name": "user_installed_plugins_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_installed_plugins_user_id_users_id_fk": {+ "name": "user_installed_plugins_user_id_users_id_fk",+ "tableFrom": "user_installed_plugins",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_installed_plugins_workspace_id_workspaces_id_fk": {+ "name": "user_installed_plugins_workspace_id_workspaces_id_fk",+ "tableFrom": "user_installed_plugins",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "user_installed_plugins_user_id_identifier_pk": {+ "name": "user_installed_plugins_user_id_identifier_pk",+ "columns": [+ "user_id",+ "identifier"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.devices": {+ "name": "devices",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'private'"+ },+ "shared_from_device_id": {+ "name": "shared_from_device_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false+ },+ "device_id": {+ "name": "device_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true+ },+ "identity_source": {+ "name": "identity_source",+ "type": "varchar(20)",+ "primaryKey": false,+ "notNull": true+ },+ "hostname": {+ "name": "hostname",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "platform": {+ "name": "platform",+ "type": "varchar(20)",+ "primaryKey": false,+ "notNull": false+ },+ "friendly_name": {+ "name": "friendly_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "default_cwd": {+ "name": "default_cwd",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "recent_cwds": {+ "name": "recent_cwds",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'"+ },+ "working_dirs": {+ "name": "working_dirs",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'[]'::jsonb"+ },+ "first_seen_at": {+ "name": "first_seen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_seen_at": {+ "name": "last_seen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "devices_user_id_device_id_unique": {+ "name": "devices_user_id_device_id_unique",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "device_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"devices\".\"workspace_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "devices_workspace_id_device_id_unique": {+ "name": "devices_workspace_id_device_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "device_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"devices\".\"workspace_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "devices_user_id_idx": {+ "name": "devices_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "devices_workspace_id_idx": {+ "name": "devices_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "devices_workspace_visibility_idx": {+ "name": "devices_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "devices_user_id_users_id_fk": {+ "name": "devices_user_id_users_id_fk",+ "tableFrom": "devices",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "devices_workspace_id_workspaces_id_fk": {+ "name": "devices_workspace_id_workspaces_id_fk",+ "tableFrom": "devices",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.document_comment_mentions": {+ "name": "document_comment_mentions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "comment_id": {+ "name": "comment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "mentioned_user_id": {+ "name": "mentioned_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "document_comment_mentions_comment_id_mentioned_user_id_unique": {+ "name": "document_comment_mentions_comment_id_mentioned_user_id_unique",+ "columns": [+ {+ "expression": "comment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "mentioned_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_comment_mentions_mentioned_user_id_created_at_idx": {+ "name": "document_comment_mentions_mentioned_user_id_created_at_idx",+ "columns": [+ {+ "expression": "mentioned_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_comment_mentions_workspace_id_idx": {+ "name": "document_comment_mentions_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "document_comment_mentions_comment_id_document_comments_id_fk": {+ "name": "document_comment_mentions_comment_id_document_comments_id_fk",+ "tableFrom": "document_comment_mentions",+ "tableTo": "document_comments",+ "columnsFrom": [+ "comment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_comment_mentions_mentioned_user_id_users_id_fk": {+ "name": "document_comment_mentions_mentioned_user_id_users_id_fk",+ "tableFrom": "document_comment_mentions",+ "tableTo": "users",+ "columnsFrom": [+ "mentioned_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_comment_mentions_workspace_id_workspaces_id_fk": {+ "name": "document_comment_mentions_workspace_id_workspaces_id_fk",+ "tableFrom": "document_comment_mentions",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.document_comments": {+ "name": "document_comments",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "document_id": {+ "name": "document_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "parent_comment_id": {+ "name": "parent_comment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "reply_to_comment_id": {+ "name": "reply_to_comment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "author_user_id": {+ "name": "author_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "document_comments_document_id_author_user_id_client_id_unique": {+ "name": "document_comments_document_id_author_user_id_client_id_unique",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "author_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_comments_parent_comment_id_created_at_id_idx": {+ "name": "document_comments_parent_comment_id_created_at_id_idx",+ "columns": [+ {+ "expression": "parent_comment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_comments_reply_to_comment_id_idx": {+ "name": "document_comments_reply_to_comment_id_idx",+ "columns": [+ {+ "expression": "reply_to_comment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_comments_document_id_created_at_id_idx": {+ "name": "document_comments_document_id_created_at_id_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_comments_author_user_id_idx": {+ "name": "document_comments_author_user_id_idx",+ "columns": [+ {+ "expression": "author_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_comments_workspace_id_idx": {+ "name": "document_comments_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "document_comments_document_id_documents_id_fk": {+ "name": "document_comments_document_id_documents_id_fk",+ "tableFrom": "document_comments",+ "tableTo": "documents",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_comments_parent_comment_id_document_comments_id_fk": {+ "name": "document_comments_parent_comment_id_document_comments_id_fk",+ "tableFrom": "document_comments",+ "tableTo": "document_comments",+ "columnsFrom": [+ "parent_comment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "document_comments_reply_to_comment_id_document_comments_id_fk": {+ "name": "document_comments_reply_to_comment_id_document_comments_id_fk",+ "tableFrom": "document_comments",+ "tableTo": "document_comments",+ "columnsFrom": [+ "reply_to_comment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "document_comments_author_user_id_users_id_fk": {+ "name": "document_comments_author_user_id_users_id_fk",+ "tableFrom": "document_comments",+ "tableTo": "users",+ "columnsFrom": [+ "author_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "document_comments_workspace_id_workspaces_id_fk": {+ "name": "document_comments_workspace_id_workspaces_id_fk",+ "tableFrom": "document_comments",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.document_histories": {+ "name": "document_histories",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "document_id": {+ "name": "document_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "save_source": {+ "name": "save_source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "saved_at": {+ "name": "saved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "document_histories_document_id_idx": {+ "name": "document_histories_document_id_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_histories_user_id_idx": {+ "name": "document_histories_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_histories_workspace_id_idx": {+ "name": "document_histories_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_histories_saved_at_idx": {+ "name": "document_histories_saved_at_idx",+ "columns": [+ {+ "expression": "saved_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "document_histories_document_id_documents_id_fk": {+ "name": "document_histories_document_id_documents_id_fk",+ "tableFrom": "document_histories",+ "tableTo": "documents",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_histories_user_id_users_id_fk": {+ "name": "document_histories_user_id_users_id_fk",+ "tableFrom": "document_histories",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_histories_workspace_id_workspaces_id_fk": {+ "name": "document_histories_workspace_id_workspaces_id_fk",+ "tableFrom": "document_histories",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.document_shares": {+ "name": "document_shares",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "document_id": {+ "name": "document_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'private'"+ },+ "permission": {+ "name": "permission",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'read'"+ },+ "page_view_count": {+ "name": "page_view_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "document_shares_document_id_unique": {+ "name": "document_shares_document_id_unique",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_shares_user_id_idx": {+ "name": "document_shares_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_shares_workspace_id_idx": {+ "name": "document_shares_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "document_shares_document_id_documents_id_fk": {+ "name": "document_shares_document_id_documents_id_fk",+ "tableFrom": "document_shares",+ "tableTo": "documents",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_shares_user_id_users_id_fk": {+ "name": "document_shares_user_id_users_id_fk",+ "tableFrom": "document_shares",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_shares_workspace_id_workspaces_id_fk": {+ "name": "document_shares_workspace_id_workspaces_id_fk",+ "tableFrom": "document_shares",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.expertise_bindings": {+ "name": "expertise_bindings",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "domain_id": {+ "name": "domain_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "bound_workspace_id": {+ "name": "bound_workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "bound_user_id": {+ "name": "bound_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "contribution_mode": {+ "name": "contribution_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'derive'"+ },+ "added_by_user_id": {+ "name": "added_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "sort_order": {+ "name": "sort_order",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "expertise_bindings_agent_domain_unique": {+ "name": "expertise_bindings_agent_domain_unique",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"expertise_bindings\".\"agent_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_bindings_project_domain_unique": {+ "name": "expertise_bindings_project_domain_unique",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"expertise_bindings\".\"project_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_bindings_workspace_domain_unique": {+ "name": "expertise_bindings_workspace_domain_unique",+ "columns": [+ {+ "expression": "bound_workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"expertise_bindings\".\"bound_workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_bindings_user_domain_unique": {+ "name": "expertise_bindings_user_domain_unique",+ "columns": [+ {+ "expression": "bound_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"expertise_bindings\".\"bound_user_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_bindings_domain_idx": {+ "name": "expertise_bindings_domain_idx",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_bindings_workspace_id_idx": {+ "name": "expertise_bindings_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "expertise_bindings_domain_id_expertise_domains_id_fk": {+ "name": "expertise_bindings_domain_id_expertise_domains_id_fk",+ "tableFrom": "expertise_bindings",+ "tableTo": "expertise_domains",+ "columnsFrom": [+ "domain_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_bindings_agent_id_agents_id_fk": {+ "name": "expertise_bindings_agent_id_agents_id_fk",+ "tableFrom": "expertise_bindings",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_bindings_project_id_projects_id_fk": {+ "name": "expertise_bindings_project_id_projects_id_fk",+ "tableFrom": "expertise_bindings",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_bindings_bound_workspace_id_workspaces_id_fk": {+ "name": "expertise_bindings_bound_workspace_id_workspaces_id_fk",+ "tableFrom": "expertise_bindings",+ "tableTo": "workspaces",+ "columnsFrom": [+ "bound_workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_bindings_bound_user_id_users_id_fk": {+ "name": "expertise_bindings_bound_user_id_users_id_fk",+ "tableFrom": "expertise_bindings",+ "tableTo": "users",+ "columnsFrom": [+ "bound_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_bindings_added_by_user_id_users_id_fk": {+ "name": "expertise_bindings_added_by_user_id_users_id_fk",+ "tableFrom": "expertise_bindings",+ "tableTo": "users",+ "columnsFrom": [+ "added_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "expertise_bindings_workspace_id_workspaces_id_fk": {+ "name": "expertise_bindings_workspace_id_workspaces_id_fk",+ "tableFrom": "expertise_bindings",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "expertise_bindings_exactly_one_carrier": {+ "name": "expertise_bindings_exactly_one_carrier",+ "value": "(\"expertise_bindings\".\"agent_id\" IS NOT NULL)::int + (\"expertise_bindings\".\"project_id\" IS NOT NULL)::int + (\"expertise_bindings\".\"bound_workspace_id\" IS NOT NULL)::int + (\"expertise_bindings\".\"bound_user_id\" IS NOT NULL)::int = 1"+ }+ },+ "isRLSEnabled": false+ },+ "public.expertise_domain_snapshots": {+ "name": "expertise_domain_snapshots",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "domain_id": {+ "name": "domain_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "run_index": {+ "name": "run_index",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "learned_total": {+ "name": "learned_total",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "retired_total": {+ "name": "retired_total",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "active_count": {+ "name": "active_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "compiled_count": {+ "name": "compiled_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "layer_counts": {+ "name": "layer_counts",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "p_inf": {+ "name": "p_inf",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false+ },+ "tau": {+ "name": "tau",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false+ },+ "maturity": {+ "name": "maturity",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false+ },+ "fit_sample_size": {+ "name": "fit_sample_size",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "fit_r2": {+ "name": "fit_r2",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false+ },+ "fit_confidence": {+ "name": "fit_confidence",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "fit_computed_at": {+ "name": "fit_computed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "tau_pinned": {+ "name": "tau_pinned",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "observed_span": {+ "name": "observed_span",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false+ },+ "plateau_kind": {+ "name": "plateau_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "layer_coverage": {+ "name": "layer_coverage",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false+ },+ "canon_coverage": {+ "name": "canon_coverage",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false+ },+ "active_rate": {+ "name": "active_rate",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "expertise_domain_snapshots_domain_run_index_unique": {+ "name": "expertise_domain_snapshots_domain_run_index_unique",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "run_index",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_domain_snapshots_domain_captured_idx": {+ "name": "expertise_domain_snapshots_domain_captured_idx",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "captured_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_domain_snapshots_pending_fit_idx": {+ "name": "expertise_domain_snapshots_pending_fit_idx",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"expertise_domain_snapshots\".\"fit_computed_at\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "expertise_domain_snapshots_domain_id_expertise_domains_id_fk": {+ "name": "expertise_domain_snapshots_domain_id_expertise_domains_id_fk",+ "tableFrom": "expertise_domain_snapshots",+ "tableTo": "expertise_domains",+ "columnsFrom": [+ "domain_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_domain_snapshots_run_id_expertise_runs_id_fk": {+ "name": "expertise_domain_snapshots_run_id_expertise_runs_id_fk",+ "tableFrom": "expertise_domain_snapshots",+ "tableTo": "expertise_runs",+ "columnsFrom": [+ "run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "expertise_domain_snapshots_run_domain_fk": {+ "name": "expertise_domain_snapshots_run_domain_fk",+ "tableFrom": "expertise_domain_snapshots",+ "tableTo": "expertise_runs",+ "columnsFrom": [+ "run_id",+ "domain_id"+ ],+ "columnsTo": [+ "id",+ "domain_id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.expertise_domains": {+ "name": "expertise_domains",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "slug": {+ "name": "slug",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'private'"+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'user'"+ },+ "parent_domain_id": {+ "name": "parent_domain_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "domain_filter": {+ "name": "domain_filter",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "out_of_scope": {+ "name": "out_of_scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "layers": {+ "name": "layers",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "layer_source": {+ "name": "layer_source",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'invented'"+ },+ "canon_entries": {+ "name": "canon_entries",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "canon_document_id": {+ "name": "canon_document_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "flow": {+ "name": "flow",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "evidence_spec": {+ "name": "evidence_spec",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "lesson_base_document_id": {+ "name": "lesson_base_document_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "anchor_candidates": {+ "name": "anchor_candidates",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "anchor_chosen_at": {+ "name": "anchor_chosen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "anchor_chosen_by_user_id": {+ "name": "anchor_chosen_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "seed_state": {+ "name": "seed_state",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'seeding'"+ },+ "seed_run_id": {+ "name": "seed_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "expertise_domains_slug_user_unique": {+ "name": "expertise_domains_slug_user_unique",+ "columns": [+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"expertise_domains\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_domains_slug_workspace_unique": {+ "name": "expertise_domains_slug_workspace_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"expertise_domains\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_domains_user_id_idx": {+ "name": "expertise_domains_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_domains_workspace_visibility_idx": {+ "name": "expertise_domains_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_domains_parent_idx": {+ "name": "expertise_domains_parent_idx",+ "columns": [+ {+ "expression": "parent_domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "expertise_domains_user_id_users_id_fk": {+ "name": "expertise_domains_user_id_users_id_fk",+ "tableFrom": "expertise_domains",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_domains_workspace_id_workspaces_id_fk": {+ "name": "expertise_domains_workspace_id_workspaces_id_fk",+ "tableFrom": "expertise_domains",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_domains_parent_domain_id_expertise_domains_id_fk": {+ "name": "expertise_domains_parent_domain_id_expertise_domains_id_fk",+ "tableFrom": "expertise_domains",+ "tableTo": "expertise_domains",+ "columnsFrom": [+ "parent_domain_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "expertise_domains_canon_document_id_documents_id_fk": {+ "name": "expertise_domains_canon_document_id_documents_id_fk",+ "tableFrom": "expertise_domains",+ "tableTo": "documents",+ "columnsFrom": [+ "canon_document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "expertise_domains_lesson_base_document_id_documents_id_fk": {+ "name": "expertise_domains_lesson_base_document_id_documents_id_fk",+ "tableFrom": "expertise_domains",+ "tableTo": "documents",+ "columnsFrom": [+ "lesson_base_document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "expertise_domains_anchor_chosen_by_user_id_users_id_fk": {+ "name": "expertise_domains_anchor_chosen_by_user_id_users_id_fk",+ "tableFrom": "expertise_domains",+ "tableTo": "users",+ "columnsFrom": [+ "anchor_chosen_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.expertise_hits": {+ "name": "expertise_hits",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "lesson_id": {+ "name": "lesson_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "domain_id": {+ "name": "domain_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "outcome": {+ "name": "outcome",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "where": {+ "name": "where",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "note": {+ "name": "note",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "example": {+ "name": "example",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "severity": {+ "name": "severity",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "evidence_id": {+ "name": "evidence_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "operation_id": {+ "name": "operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_decision": {+ "name": "user_decision",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_decision_at": {+ "name": "user_decision_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "expertise_hits_lesson_created_idx": {+ "name": "expertise_hits_lesson_created_idx",+ "columns": [+ {+ "expression": "lesson_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_hits_run_idx": {+ "name": "expertise_hits_run_idx",+ "columns": [+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_hits_domain_outcome_idx": {+ "name": "expertise_hits_domain_outcome_idx",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "outcome",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_hits_operation_idx": {+ "name": "expertise_hits_operation_idx",+ "columns": [+ {+ "expression": "operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "expertise_hits_domain_id_expertise_domains_id_fk": {+ "name": "expertise_hits_domain_id_expertise_domains_id_fk",+ "tableFrom": "expertise_hits",+ "tableTo": "expertise_domains",+ "columnsFrom": [+ "domain_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_hits_evidence_id_verify_evidence_id_fk": {+ "name": "expertise_hits_evidence_id_verify_evidence_id_fk",+ "tableFrom": "expertise_hits",+ "tableTo": "verify_evidence",+ "columnsFrom": [+ "evidence_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "expertise_hits_operation_id_agent_operations_id_fk": {+ "name": "expertise_hits_operation_id_agent_operations_id_fk",+ "tableFrom": "expertise_hits",+ "tableTo": "agent_operations",+ "columnsFrom": [+ "operation_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "expertise_hits_run_domain_fk": {+ "name": "expertise_hits_run_domain_fk",+ "tableFrom": "expertise_hits",+ "tableTo": "expertise_runs",+ "columnsFrom": [+ "run_id",+ "domain_id"+ ],+ "columnsTo": [+ "id",+ "domain_id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_hits_lesson_domain_fk": {+ "name": "expertise_hits_lesson_domain_fk",+ "tableFrom": "expertise_hits",+ "tableTo": "expertise_lessons",+ "columnsFrom": [+ "lesson_id",+ "domain_id"+ ],+ "columnsTo": [+ "id",+ "domain_id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.expertise_insights": {+ "name": "expertise_insights",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "domain_id": {+ "name": "domain_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "kind": {+ "name": "kind",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "headline": {+ "name": "headline",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "body": {+ "name": "body",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "action_label": {+ "name": "action_label",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "action_target": {+ "name": "action_target",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "evidence": {+ "name": "evidence",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "confidence": {+ "name": "confidence",+ "type": "real",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "dismiss_reason": {+ "name": "dismiss_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "stale_after_run_index": {+ "name": "stale_after_run_index",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "generated_by_operation_id": {+ "name": "generated_by_operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "expertise_insights_domain_status_idx": {+ "name": "expertise_insights_domain_status_idx",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_insights_user_status_idx": {+ "name": "expertise_insights_user_status_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_insights_workspace_idx": {+ "name": "expertise_insights_workspace_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "expertise_insights_domain_id_expertise_domains_id_fk": {+ "name": "expertise_insights_domain_id_expertise_domains_id_fk",+ "tableFrom": "expertise_insights",+ "tableTo": "expertise_domains",+ "columnsFrom": [+ "domain_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_insights_user_id_users_id_fk": {+ "name": "expertise_insights_user_id_users_id_fk",+ "tableFrom": "expertise_insights",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_insights_workspace_id_workspaces_id_fk": {+ "name": "expertise_insights_workspace_id_workspaces_id_fk",+ "tableFrom": "expertise_insights",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_insights_generated_by_operation_id_agent_operations_id_fk": {+ "name": "expertise_insights_generated_by_operation_id_agent_operations_id_fk",+ "tableFrom": "expertise_insights",+ "tableTo": "agent_operations",+ "columnsFrom": [+ "generated_by_operation_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.expertise_lesson_revisions": {+ "name": "expertise_lesson_revisions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "lesson_id": {+ "name": "lesson_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "revision": {+ "name": "revision",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "sections": {+ "name": "sections",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "feedback": {+ "name": "feedback",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "changed_by": {+ "name": "changed_by",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'user-feedback'"+ },+ "prev_title": {+ "name": "prev_title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "changed_by_user_id": {+ "name": "changed_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source_run_id": {+ "name": "source_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "operation_id": {+ "name": "operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "expertise_lesson_revisions_lesson_revision_unique": {+ "name": "expertise_lesson_revisions_lesson_revision_unique",+ "columns": [+ {+ "expression": "lesson_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "revision",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_lesson_revisions_lesson_idx": {+ "name": "expertise_lesson_revisions_lesson_idx",+ "columns": [+ {+ "expression": "lesson_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "expertise_lesson_revisions_lesson_id_expertise_lessons_id_fk": {+ "name": "expertise_lesson_revisions_lesson_id_expertise_lessons_id_fk",+ "tableFrom": "expertise_lesson_revisions",+ "tableTo": "expertise_lessons",+ "columnsFrom": [+ "lesson_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_lesson_revisions_changed_by_user_id_users_id_fk": {+ "name": "expertise_lesson_revisions_changed_by_user_id_users_id_fk",+ "tableFrom": "expertise_lesson_revisions",+ "tableTo": "users",+ "columnsFrom": [+ "changed_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "expertise_lesson_revisions_operation_id_agent_operations_id_fk": {+ "name": "expertise_lesson_revisions_operation_id_agent_operations_id_fk",+ "tableFrom": "expertise_lesson_revisions",+ "tableTo": "agent_operations",+ "columnsFrom": [+ "operation_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.expertise_lessons": {+ "name": "expertise_lessons",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "domain_id": {+ "name": "domain_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "code": {+ "name": "code",+ "type": "varchar(20)",+ "primaryKey": false,+ "notNull": true+ },+ "polarity": {+ "name": "polarity",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "sections": {+ "name": "sections",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "layer": {+ "name": "layer",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "tags": {+ "name": "tags",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "canon_anchor": {+ "name": "canon_anchor",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "origin_run_id": {+ "name": "origin_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "origin_hit_id": {+ "name": "origin_hit_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "rejected_reason": {+ "name": "rejected_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "salvaged_from_id": {+ "name": "salvaged_from_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "retired_at": {+ "name": "retired_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "compilability": {+ "name": "compilability",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'compilable'"+ },+ "compiled_criterion_id": {+ "name": "compiled_criterion_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "hit_count": {+ "name": "hit_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "hit_run_count": {+ "name": "hit_run_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "false_positive_count": {+ "name": "false_positive_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "last_hit_at": {+ "name": "last_hit_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_hit_run_id": {+ "name": "last_hit_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "generalized_from_ids": {+ "name": "generalized_from_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "specificity": {+ "name": "specificity",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "example_count": {+ "name": "example_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "current_revision": {+ "name": "current_revision",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "expertise_lessons_domain_code_unique": {+ "name": "expertise_lessons_domain_code_unique",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "code",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_lessons_domain_status_hits_idx": {+ "name": "expertise_lessons_domain_status_hits_idx",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "hit_count",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_lessons_domain_layer_idx": {+ "name": "expertise_lessons_domain_layer_idx",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "layer",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_lessons_compiled_criterion_idx": {+ "name": "expertise_lessons_compiled_criterion_idx",+ "columns": [+ {+ "expression": "compiled_criterion_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "expertise_lessons_domain_id_expertise_domains_id_fk": {+ "name": "expertise_lessons_domain_id_expertise_domains_id_fk",+ "tableFrom": "expertise_lessons",+ "tableTo": "expertise_domains",+ "columnsFrom": [+ "domain_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_lessons_created_by_user_id_users_id_fk": {+ "name": "expertise_lessons_created_by_user_id_users_id_fk",+ "tableFrom": "expertise_lessons",+ "tableTo": "users",+ "columnsFrom": [+ "created_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "expertise_lessons_salvaged_from_id_expertise_lessons_id_fk": {+ "name": "expertise_lessons_salvaged_from_id_expertise_lessons_id_fk",+ "tableFrom": "expertise_lessons",+ "tableTo": "expertise_lessons",+ "columnsFrom": [+ "salvaged_from_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "expertise_lessons_compiled_criterion_id_verify_criteria_id_fk": {+ "name": "expertise_lessons_compiled_criterion_id_verify_criteria_id_fk",+ "tableFrom": "expertise_lessons",+ "tableTo": "verify_criteria",+ "columnsFrom": [+ "compiled_criterion_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "expertise_lessons_id_domain_unique": {+ "name": "expertise_lessons_id_domain_unique",+ "nullsNotDistinct": false,+ "columns": [+ "id",+ "domain_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.expertise_runs": {+ "name": "expertise_runs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "domain_id": {+ "name": "domain_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "run_index": {+ "name": "run_index",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "is_seed_run": {+ "name": "is_seed_run",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "actor_type": {+ "name": "actor_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "actor_id": {+ "name": "actor_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "subject_type": {+ "name": "subject_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "subject_id": {+ "name": "subject_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "window_start": {+ "name": "window_start",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "window_end": {+ "name": "window_end",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "reflection_key": {+ "name": "reflection_key",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "had_human_in_loop": {+ "name": "had_human_in_loop",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "instance_count": {+ "name": "instance_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "refine_count": {+ "name": "refine_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "new_count": {+ "name": "new_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "expertise_runs_domain_run_index_unique": {+ "name": "expertise_runs_domain_run_index_unique",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "run_index",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_runs_domain_reflection_key_unique": {+ "name": "expertise_runs_domain_reflection_key_unique",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "reflection_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"expertise_runs\".\"reflection_key\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_runs_domain_started_idx": {+ "name": "expertise_runs_domain_started_idx",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "started_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_runs_actor_idx": {+ "name": "expertise_runs_actor_idx",+ "columns": [+ {+ "expression": "actor_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "actor_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_runs_subject_idx": {+ "name": "expertise_runs_subject_idx",+ "columns": [+ {+ "expression": "subject_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "expertise_runs_domain_id_expertise_domains_id_fk": {+ "name": "expertise_runs_domain_id_expertise_domains_id_fk",+ "tableFrom": "expertise_runs",+ "tableTo": "expertise_domains",+ "columnsFrom": [+ "domain_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_runs_user_id_users_id_fk": {+ "name": "expertise_runs_user_id_users_id_fk",+ "tableFrom": "expertise_runs",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "expertise_runs_workspace_id_workspaces_id_fk": {+ "name": "expertise_runs_workspace_id_workspaces_id_fk",+ "tableFrom": "expertise_runs",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "expertise_runs_id_domain_unique": {+ "name": "expertise_runs_id_domain_unique",+ "nullsNotDistinct": false,+ "columns": [+ "id",+ "domain_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.documents": {+ "name": "documents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "file_type": {+ "name": "file_type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "filename": {+ "name": "filename",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "total_char_count": {+ "name": "total_char_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "total_line_count": {+ "name": "total_line_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "pages": {+ "name": "pages",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "source_type": {+ "name": "source_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "file_id": {+ "name": "file_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "knowledge_base_id": {+ "name": "knowledge_base_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "parent_id": {+ "name": "parent_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "slug": {+ "name": "slug",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_deleted": {+ "name": "is_deleted",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "documents_source_idx": {+ "name": "documents_source_idx",+ "columns": [+ {+ "expression": "source",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_file_type_idx": {+ "name": "documents_file_type_idx",+ "columns": [+ {+ "expression": "file_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_source_type_idx": {+ "name": "documents_source_type_idx",+ "columns": [+ {+ "expression": "source_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_user_id_idx": {+ "name": "documents_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_file_id_idx": {+ "name": "documents_file_id_idx",+ "columns": [+ {+ "expression": "file_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_parent_id_idx": {+ "name": "documents_parent_id_idx",+ "columns": [+ {+ "expression": "parent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_knowledge_base_id_idx": {+ "name": "documents_knowledge_base_id_idx",+ "columns": [+ {+ "expression": "knowledge_base_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_client_id_user_id_unique": {+ "name": "documents_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_slug_user_id_unique": {+ "name": "documents_slug_user_id_unique",+ "columns": [+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"documents\".\"workspace_id\" IS NULL AND \"documents\".\"slug\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_workspace_id_idx": {+ "name": "documents_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_workspace_visibility_idx": {+ "name": "documents_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_slug_workspace_id_unique": {+ "name": "documents_slug_workspace_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"documents\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "documents_file_id_files_id_fk": {+ "name": "documents_file_id_files_id_fk",+ "tableFrom": "documents",+ "tableTo": "files",+ "columnsFrom": [+ "file_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "documents_knowledge_base_id_knowledge_bases_id_fk": {+ "name": "documents_knowledge_base_id_knowledge_bases_id_fk",+ "tableFrom": "documents",+ "tableTo": "knowledge_bases",+ "columnsFrom": [+ "knowledge_base_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "documents_parent_id_documents_id_fk": {+ "name": "documents_parent_id_documents_id_fk",+ "tableFrom": "documents",+ "tableTo": "documents",+ "columnsFrom": [+ "parent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "documents_user_id_users_id_fk": {+ "name": "documents_user_id_users_id_fk",+ "tableFrom": "documents",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "documents_workspace_id_workspaces_id_fk": {+ "name": "documents_workspace_id_workspaces_id_fk",+ "tableFrom": "documents",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.files": {+ "name": "files",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "file_type": {+ "name": "file_type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "file_hash": {+ "name": "file_hash",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "size": {+ "name": "size",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "parent_id": {+ "name": "parent_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "chunk_task_id": {+ "name": "chunk_task_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "embedding_task_id": {+ "name": "embedding_task_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_deleted": {+ "name": "is_deleted",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "file_hash_idx": {+ "name": "file_hash_idx",+ "columns": [+ {+ "expression": "file_hash",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "files_user_id_idx": {+ "name": "files_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "files_parent_id_idx": {+ "name": "files_parent_id_idx",+ "columns": [+ {+ "expression": "parent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "files_chunk_task_id_idx": {+ "name": "files_chunk_task_id_idx",+ "columns": [+ {+ "expression": "chunk_task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "files_embedding_task_id_idx": {+ "name": "files_embedding_task_id_idx",+ "columns": [+ {+ "expression": "embedding_task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "files_client_id_user_id_unique": {+ "name": "files_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "files_workspace_id_idx": {+ "name": "files_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "files_workspace_visibility_idx": {+ "name": "files_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "files_user_id_users_id_fk": {+ "name": "files_user_id_users_id_fk",+ "tableFrom": "files",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "files_file_hash_global_files_hash_id_fk": {+ "name": "files_file_hash_global_files_hash_id_fk",+ "tableFrom": "files",+ "tableTo": "global_files",+ "columnsFrom": [+ "file_hash"+ ],+ "columnsTo": [+ "hash_id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "files_parent_id_documents_id_fk": {+ "name": "files_parent_id_documents_id_fk",+ "tableFrom": "files",+ "tableTo": "documents",+ "columnsFrom": [+ "parent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "files_chunk_task_id_async_tasks_id_fk": {+ "name": "files_chunk_task_id_async_tasks_id_fk",+ "tableFrom": "files",+ "tableTo": "async_tasks",+ "columnsFrom": [+ "chunk_task_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "files_embedding_task_id_async_tasks_id_fk": {+ "name": "files_embedding_task_id_async_tasks_id_fk",+ "tableFrom": "files",+ "tableTo": "async_tasks",+ "columnsFrom": [+ "embedding_task_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "files_workspace_id_workspaces_id_fk": {+ "name": "files_workspace_id_workspaces_id_fk",+ "tableFrom": "files",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.global_files": {+ "name": "global_files",+ "schema": "",+ "columns": {+ "hash_id": {+ "name": "hash_id",+ "type": "varchar(64)",+ "primaryKey": true,+ "notNull": true+ },+ "file_type": {+ "name": "file_type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "size": {+ "name": "size",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "creator": {+ "name": "creator",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "global_files_creator_idx": {+ "name": "global_files_creator_idx",+ "columns": [+ {+ "expression": "creator",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "global_files_creator_users_id_fk": {+ "name": "global_files_creator_users_id_fk",+ "tableFrom": "global_files",+ "tableTo": "users",+ "columnsFrom": [+ "creator"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.knowledge_base_files": {+ "name": "knowledge_base_files",+ "schema": "",+ "columns": {+ "knowledge_base_id": {+ "name": "knowledge_base_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "file_id": {+ "name": "file_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "knowledge_base_files_kb_id_idx": {+ "name": "knowledge_base_files_kb_id_idx",+ "columns": [+ {+ "expression": "knowledge_base_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "knowledge_base_files_user_id_idx": {+ "name": "knowledge_base_files_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "knowledge_base_files_file_id_idx": {+ "name": "knowledge_base_files_file_id_idx",+ "columns": [+ {+ "expression": "file_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "knowledge_base_files_workspace_id_idx": {+ "name": "knowledge_base_files_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "knowledge_base_files_knowledge_base_id_knowledge_bases_id_fk": {+ "name": "knowledge_base_files_knowledge_base_id_knowledge_bases_id_fk",+ "tableFrom": "knowledge_base_files",+ "tableTo": "knowledge_bases",+ "columnsFrom": [+ "knowledge_base_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "knowledge_base_files_file_id_files_id_fk": {+ "name": "knowledge_base_files_file_id_files_id_fk",+ "tableFrom": "knowledge_base_files",+ "tableTo": "files",+ "columnsFrom": [+ "file_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "knowledge_base_files_user_id_users_id_fk": {+ "name": "knowledge_base_files_user_id_users_id_fk",+ "tableFrom": "knowledge_base_files",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "knowledge_base_files_workspace_id_workspaces_id_fk": {+ "name": "knowledge_base_files_workspace_id_workspaces_id_fk",+ "tableFrom": "knowledge_base_files",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "knowledge_base_files_knowledge_base_id_file_id_pk": {+ "name": "knowledge_base_files_knowledge_base_id_file_id_pk",+ "columns": [+ "knowledge_base_id",+ "file_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.knowledge_bases": {+ "name": "knowledge_bases",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "avatar": {+ "name": "avatar",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "is_public": {+ "name": "is_public",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "settings": {+ "name": "settings",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_deleted": {+ "name": "is_deleted",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "knowledge_bases_client_id_user_id_unique": {+ "name": "knowledge_bases_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "knowledge_bases_user_id_idx": {+ "name": "knowledge_bases_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "knowledge_bases_workspace_id_idx": {+ "name": "knowledge_bases_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "knowledge_bases_workspace_visibility_idx": {+ "name": "knowledge_bases_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "knowledge_bases_user_id_users_id_fk": {+ "name": "knowledge_bases_user_id_users_id_fk",+ "tableFrom": "knowledge_bases",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "knowledge_bases_workspace_id_workspaces_id_fk": {+ "name": "knowledge_bases_workspace_id_workspaces_id_fk",+ "tableFrom": "knowledge_bases",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.fts_search_sync_outbox": {+ "name": "fts_search_sync_outbox",+ "schema": "",+ "columns": {+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "available_at": {+ "name": "available_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "dead_at": {+ "name": "dead_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "document_id": {+ "name": "document_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "entity": {+ "name": "entity",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "locked_until": {+ "name": "locked_until",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "priority": {+ "name": "priority",+ "type": "smallint",+ "primaryKey": false,+ "notNull": true,+ "default": 10+ },+ "revision": {+ "name": "revision",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "default": "nextval('fts_search_sync_revision_seq')"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "fts_search_sync_outbox_entity_document_id_unique": {+ "name": "fts_search_sync_outbox_entity_document_id_unique",+ "columns": [+ {+ "expression": "entity",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "fts_search_sync_outbox_claim_idx": {+ "name": "fts_search_sync_outbox_claim_idx",+ "columns": [+ {+ "expression": "priority",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "available_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "revision",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"fts_search_sync_outbox\".\"dead_at\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "fts_search_sync_outbox_dead_idx": {+ "name": "fts_search_sync_outbox_dead_idx",+ "columns": [+ {+ "expression": "dead_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"fts_search_sync_outbox\".\"dead_at\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "fts_search_sync_outbox_lease_idx": {+ "name": "fts_search_sync_outbox_lease_idx",+ "columns": [+ {+ "expression": "locked_until",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"fts_search_sync_outbox\".\"dead_at\" IS NULL AND \"fts_search_sync_outbox\".\"locked_until\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.generation_batches": {+ "name": "generation_batches",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "generation_topic_id": {+ "name": "generation_topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "prompt": {+ "name": "prompt",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "width": {+ "name": "width",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "height": {+ "name": "height",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "ratio": {+ "name": "ratio",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_deleted": {+ "name": "is_deleted",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "generation_batches_user_id_idx": {+ "name": "generation_batches_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "generation_batches_topic_id_idx": {+ "name": "generation_batches_topic_id_idx",+ "columns": [+ {+ "expression": "generation_topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "generation_batches_workspace_id_idx": {+ "name": "generation_batches_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "generation_batches_user_id_users_id_fk": {+ "name": "generation_batches_user_id_users_id_fk",+ "tableFrom": "generation_batches",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "generation_batches_workspace_id_workspaces_id_fk": {+ "name": "generation_batches_workspace_id_workspaces_id_fk",+ "tableFrom": "generation_batches",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "generation_batches_generation_topic_id_generation_topics_id_fk": {+ "name": "generation_batches_generation_topic_id_generation_topics_id_fk",+ "tableFrom": "generation_batches",+ "tableTo": "generation_topics",+ "columnsFrom": [+ "generation_topic_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.generation_topics": {+ "name": "generation_topics",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "cover_url": {+ "name": "cover_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "varchar(32)",+ "primaryKey": false,+ "notNull": true,+ "default": "'image'"+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_deleted": {+ "name": "is_deleted",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "generation_topics_user_id_idx": {+ "name": "generation_topics_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "generation_topics_workspace_id_idx": {+ "name": "generation_topics_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "generation_topics_workspace_visibility_idx": {+ "name": "generation_topics_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "generation_topics_user_id_users_id_fk": {+ "name": "generation_topics_user_id_users_id_fk",+ "tableFrom": "generation_topics",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "generation_topics_workspace_id_workspaces_id_fk": {+ "name": "generation_topics_workspace_id_workspaces_id_fk",+ "tableFrom": "generation_topics",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.generations": {+ "name": "generations",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "generation_batch_id": {+ "name": "generation_batch_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true+ },+ "async_task_id": {+ "name": "async_task_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "file_id": {+ "name": "file_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "seed": {+ "name": "seed",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "asset": {+ "name": "asset",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_deleted": {+ "name": "is_deleted",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "generations_user_id_idx": {+ "name": "generations_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "generations_batch_id_idx": {+ "name": "generations_batch_id_idx",+ "columns": [+ {+ "expression": "generation_batch_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "generations_file_id_idx": {+ "name": "generations_file_id_idx",+ "columns": [+ {+ "expression": "file_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "generations_workspace_id_idx": {+ "name": "generations_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "generations_user_id_users_id_fk": {+ "name": "generations_user_id_users_id_fk",+ "tableFrom": "generations",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "generations_workspace_id_workspaces_id_fk": {+ "name": "generations_workspace_id_workspaces_id_fk",+ "tableFrom": "generations",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "generations_generation_batch_id_generation_batches_id_fk": {+ "name": "generations_generation_batch_id_generation_batches_id_fk",+ "tableFrom": "generations",+ "tableTo": "generation_batches",+ "columnsFrom": [+ "generation_batch_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "generations_async_task_id_async_tasks_id_fk": {+ "name": "generations_async_task_id_async_tasks_id_fk",+ "tableFrom": "generations",+ "tableTo": "async_tasks",+ "columnsFrom": [+ "async_task_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "generations_file_id_files_id_fk": {+ "name": "generations_file_id_files_id_fk",+ "tableFrom": "generations",+ "tableTo": "files",+ "columnsFrom": [+ "file_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.goals": {+ "name": "goals",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "requirement": {+ "name": "requirement",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "max_rounds": {+ "name": "max_rounds",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "max_total_cost": {+ "name": "max_total_cost",+ "type": "numeric(20, 6)",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'planning'"+ },+ "subject_type": {+ "name": "subject_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "subject_id": {+ "name": "subject_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_deleted": {+ "name": "is_deleted",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "goals_user_id_idx": {+ "name": "goals_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goals_workspace_id_idx": {+ "name": "goals_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goals_agent_id_idx": {+ "name": "goals_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goals_project_id_idx": {+ "name": "goals_project_id_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goals_status_idx": {+ "name": "goals_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goals_subject_idx": {+ "name": "goals_subject_idx",+ "columns": [+ {+ "expression": "subject_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "goals_user_id_users_id_fk": {+ "name": "goals_user_id_users_id_fk",+ "tableFrom": "goals",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "goals_workspace_id_workspaces_id_fk": {+ "name": "goals_workspace_id_workspaces_id_fk",+ "tableFrom": "goals",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "goals_agent_id_agents_id_fk": {+ "name": "goals_agent_id_agents_id_fk",+ "tableFrom": "goals",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "goals_project_id_projects_id_fk": {+ "name": "goals_project_id_projects_id_fk",+ "tableFrom": "goals",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.goal_edges": {+ "name": "goal_edges",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "goal_id": {+ "name": "goal_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_node_id": {+ "name": "source_node_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "target_node_id": {+ "name": "target_node_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "goal_edges_source_target_kind_unique": {+ "name": "goal_edges_source_target_kind_unique",+ "columns": [+ {+ "expression": "source_node_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_node_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goal_edges_goal_id_idx": {+ "name": "goal_edges_goal_id_idx",+ "columns": [+ {+ "expression": "goal_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goal_edges_target_node_id_idx": {+ "name": "goal_edges_target_node_id_idx",+ "columns": [+ {+ "expression": "target_node_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "goal_edges_goal_id_goals_id_fk": {+ "name": "goal_edges_goal_id_goals_id_fk",+ "tableFrom": "goal_edges",+ "tableTo": "goals",+ "columnsFrom": [+ "goal_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "goal_edges_goal_source_node_fk": {+ "name": "goal_edges_goal_source_node_fk",+ "tableFrom": "goal_edges",+ "tableTo": "goal_nodes",+ "columnsFrom": [+ "goal_id",+ "source_node_id"+ ],+ "columnsTo": [+ "goal_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "goal_edges_goal_target_node_fk": {+ "name": "goal_edges_goal_target_node_fk",+ "tableFrom": "goal_edges",+ "tableTo": "goal_nodes",+ "columnsFrom": [+ "goal_id",+ "target_node_id"+ ],+ "columnsTo": [+ "goal_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "goal_edges_distinct_nodes": {+ "name": "goal_edges_distinct_nodes",+ "value": "\"goal_edges\".\"source_node_id\" <> \"goal_edges\".\"target_node_id\""+ }+ },+ "isRLSEnabled": false+ },+ "public.goal_events": {+ "name": "goal_events",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "goal_id": {+ "name": "goal_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "event_type": {+ "name": "event_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "entity_type": {+ "name": "entity_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "entity_id": {+ "name": "entity_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "actor_type": {+ "name": "actor_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "actor_id": {+ "name": "actor_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "task_id": {+ "name": "task_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "operation_id": {+ "name": "operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "reason": {+ "name": "reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "goal_events_goal_id_created_at_idx": {+ "name": "goal_events_goal_id_created_at_idx",+ "columns": [+ {+ "expression": "goal_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goal_events_entity_idx": {+ "name": "goal_events_entity_idx",+ "columns": [+ {+ "expression": "entity_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "entity_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goal_events_task_id_idx": {+ "name": "goal_events_task_id_idx",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goal_events_operation_id_idx": {+ "name": "goal_events_operation_id_idx",+ "columns": [+ {+ "expression": "operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "goal_events_goal_id_goals_id_fk": {+ "name": "goal_events_goal_id_goals_id_fk",+ "tableFrom": "goal_events",+ "tableTo": "goals",+ "columnsFrom": [+ "goal_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "goal_events_task_id_tasks_id_fk": {+ "name": "goal_events_task_id_tasks_id_fk",+ "tableFrom": "goal_events",+ "tableTo": "tasks",+ "columnsFrom": [+ "task_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.goal_node_decisions": {+ "name": "goal_node_decisions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "node_id": {+ "name": "node_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "authority": {+ "name": "authority",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "question": {+ "name": "question",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "options": {+ "name": "options",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "recommended_option_id": {+ "name": "recommended_option_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "requested_user_id": {+ "name": "requested_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "requested_project_role": {+ "name": "requested_project_role",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_option_id": {+ "name": "resolved_option_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resolution": {+ "name": "resolution",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_by_user_id": {+ "name": "resolved_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_by_agent_id": {+ "name": "resolved_by_agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_at": {+ "name": "resolved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "canceled_at": {+ "name": "canceled_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "goal_node_decisions_node_id_unique": {+ "name": "goal_node_decisions_node_id_unique",+ "columns": [+ {+ "expression": "node_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goal_node_decisions_status_idx": {+ "name": "goal_node_decisions_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goal_node_decisions_requested_user_id_status_idx": {+ "name": "goal_node_decisions_requested_user_id_status_idx",+ "columns": [+ {+ "expression": "requested_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "goal_node_decisions_node_id_goal_nodes_id_fk": {+ "name": "goal_node_decisions_node_id_goal_nodes_id_fk",+ "tableFrom": "goal_node_decisions",+ "tableTo": "goal_nodes",+ "columnsFrom": [+ "node_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "goal_node_decisions_requested_user_id_users_id_fk": {+ "name": "goal_node_decisions_requested_user_id_users_id_fk",+ "tableFrom": "goal_node_decisions",+ "tableTo": "users",+ "columnsFrom": [+ "requested_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "goal_node_decisions_resolved_by_user_id_users_id_fk": {+ "name": "goal_node_decisions_resolved_by_user_id_users_id_fk",+ "tableFrom": "goal_node_decisions",+ "tableTo": "users",+ "columnsFrom": [+ "resolved_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "goal_node_decisions_resolved_by_agent_id_agents_id_fk": {+ "name": "goal_node_decisions_resolved_by_agent_id_agents_id_fk",+ "tableFrom": "goal_node_decisions",+ "tableTo": "agents",+ "columnsFrom": [+ "resolved_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.goal_node_work_versions": {+ "name": "goal_node_work_versions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "node_id": {+ "name": "node_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "work_version_id": {+ "name": "work_version_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "relation": {+ "name": "relation",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "goal_node_work_versions_node_version_relation_unique": {+ "name": "goal_node_work_versions_node_version_relation_unique",+ "columns": [+ {+ "expression": "node_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "work_version_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "relation",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goal_node_work_versions_work_version_id_idx": {+ "name": "goal_node_work_versions_work_version_id_idx",+ "columns": [+ {+ "expression": "work_version_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "goal_node_work_versions_node_id_goal_nodes_id_fk": {+ "name": "goal_node_work_versions_node_id_goal_nodes_id_fk",+ "tableFrom": "goal_node_work_versions",+ "tableTo": "goal_nodes",+ "columnsFrom": [+ "node_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "goal_node_work_versions_work_version_id_work_versions_id_fk": {+ "name": "goal_node_work_versions_work_version_id_work_versions_id_fk",+ "tableFrom": "goal_node_work_versions",+ "tableTo": "work_versions",+ "columnsFrom": [+ "work_version_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.goal_nodes": {+ "name": "goal_nodes",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "goal_id": {+ "name": "goal_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'proposed'"+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "task_id": {+ "name": "task_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "priority": {+ "name": "priority",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "confidence": {+ "name": "confidence",+ "type": "numeric(4, 3)",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_at": {+ "name": "resolved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "goal_nodes_goal_id_status_idx": {+ "name": "goal_nodes_goal_id_status_idx",+ "columns": [+ {+ "expression": "goal_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goal_nodes_goal_id_kind_idx": {+ "name": "goal_nodes_goal_id_kind_idx",+ "columns": [+ {+ "expression": "goal_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goal_nodes_task_id_unique": {+ "name": "goal_nodes_task_id_unique",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"goal_nodes\".\"task_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "goal_nodes_goal_id_goals_id_fk": {+ "name": "goal_nodes_goal_id_goals_id_fk",+ "tableFrom": "goal_nodes",+ "tableTo": "goals",+ "columnsFrom": [+ "goal_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "goal_nodes_task_id_tasks_id_fk": {+ "name": "goal_nodes_task_id_tasks_id_fk",+ "tableFrom": "goal_nodes",+ "tableTo": "tasks",+ "columnsFrom": [+ "task_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "goal_nodes_created_by_user_id_users_id_fk": {+ "name": "goal_nodes_created_by_user_id_users_id_fk",+ "tableFrom": "goal_nodes",+ "tableTo": "users",+ "columnsFrom": [+ "created_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "goal_nodes_created_by_agent_id_agents_id_fk": {+ "name": "goal_nodes_created_by_agent_id_agents_id_fk",+ "tableFrom": "goal_nodes",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "goal_nodes_goal_id_id_unique": {+ "name": "goal_nodes_goal_id_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "goal_id",+ "id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "goal_nodes_confidence_range": {+ "name": "goal_nodes_confidence_range",+ "value": "\"goal_nodes\".\"confidence\" IS NULL OR (\"goal_nodes\".\"confidence\" >= 0 AND \"goal_nodes\".\"confidence\" <= 1)"+ }+ },+ "isRLSEnabled": false+ },+ "public.goal_traces": {+ "name": "goal_traces",+ "schema": "",+ "columns": {+ "goal_id": {+ "name": "goal_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "trace_s3_key": {+ "name": "trace_s3_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "final_status": {+ "name": "final_status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "advances_total": {+ "name": "advances_total",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "ticks_total": {+ "name": "ticks_total",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "advances_by_trigger": {+ "name": "advances_by_trigger",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "advances_by_outcome": {+ "name": "advances_by_outcome",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "ticks_by_branch": {+ "name": "ticks_by_branch",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "total_cost": {+ "name": "total_cost",+ "type": "numeric(20, 6)",+ "primaryKey": false,+ "notNull": false+ },+ "work_operations": {+ "name": "work_operations",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "nodes_total": {+ "name": "nodes_total",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "work_resolved": {+ "name": "work_resolved",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "work_retired": {+ "name": "work_retired",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "findings_total": {+ "name": "findings_total",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "gates_opened": {+ "name": "gates_opened",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "gates_resolved": {+ "name": "gates_resolved",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "human_waiting_ms": {+ "name": "human_waiting_ms",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "goal_traces_started_at_idx": {+ "name": "goal_traces_started_at_idx",+ "columns": [+ {+ "expression": "started_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goal_traces_final_status_idx": {+ "name": "goal_traces_final_status_idx",+ "columns": [+ {+ "expression": "final_status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "goal_traces_goal_id_goals_id_fk": {+ "name": "goal_traces_goal_id_goals_id_fk",+ "tableFrom": "goal_traces",+ "tableTo": "goals",+ "columnsFrom": [+ "goal_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.llm_generation_tracing": {+ "name": "llm_generation_tracing",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "scenario": {+ "name": "scenario",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "prompt_version": {+ "name": "prompt_version",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "prompt_hash": {+ "name": "prompt_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "schema_name": {+ "name": "schema_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "trigger": {+ "name": "trigger",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "parent_tracing_id": {+ "name": "parent_tracing_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "success": {+ "name": "success",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true+ },+ "error_code": {+ "name": "error_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "error_detail": {+ "name": "error_detail",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "validation_failed": {+ "name": "validation_failed",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "input_hash": {+ "name": "input_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "input_hint": {+ "name": "input_hint",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "latency_ms": {+ "name": "latency_ms",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "input_tokens": {+ "name": "input_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "output_tokens": {+ "name": "output_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "cost_usd": {+ "name": "cost_usd",+ "type": "numeric(12, 8)",+ "primaryKey": false,+ "notNull": false+ },+ "storage_key": {+ "name": "storage_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "feedback_signal": {+ "name": "feedback_signal",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "feedback_score": {+ "name": "feedback_score",+ "type": "numeric(3, 2)",+ "primaryKey": false,+ "notNull": false+ },+ "feedback_source": {+ "name": "feedback_source",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "feedback_data": {+ "name": "feedback_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "feedback_updated_at": {+ "name": "feedback_updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "trace_id": {+ "name": "trace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "span_id": {+ "name": "span_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "llm_generation_tracing_scenario_idx": {+ "name": "llm_generation_tracing_scenario_idx",+ "columns": [+ {+ "expression": "scenario",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_prompt_version_idx": {+ "name": "llm_generation_tracing_prompt_version_idx",+ "columns": [+ {+ "expression": "prompt_version",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_user_id_idx": {+ "name": "llm_generation_tracing_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_agent_id_idx": {+ "name": "llm_generation_tracing_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_topic_id_idx": {+ "name": "llm_generation_tracing_topic_id_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_workspace_id_idx": {+ "name": "llm_generation_tracing_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_provider_idx": {+ "name": "llm_generation_tracing_provider_idx",+ "columns": [+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_model_idx": {+ "name": "llm_generation_tracing_model_idx",+ "columns": [+ {+ "expression": "model",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_success_idx": {+ "name": "llm_generation_tracing_success_idx",+ "columns": [+ {+ "expression": "success",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_error_code_idx": {+ "name": "llm_generation_tracing_error_code_idx",+ "columns": [+ {+ "expression": "error_code",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_validation_failed_idx": {+ "name": "llm_generation_tracing_validation_failed_idx",+ "columns": [+ {+ "expression": "validation_failed",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_feedback_signal_idx": {+ "name": "llm_generation_tracing_feedback_signal_idx",+ "columns": [+ {+ "expression": "feedback_signal",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_created_at_idx": {+ "name": "llm_generation_tracing_created_at_idx",+ "columns": [+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "llm_generation_tracing_workspace_id_workspaces_id_fk": {+ "name": "llm_generation_tracing_workspace_id_workspaces_id_fk",+ "tableFrom": "llm_generation_tracing",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.message_chunks": {+ "name": "message_chunks",+ "schema": "",+ "columns": {+ "message_id": {+ "name": "message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "chunk_id": {+ "name": "chunk_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "message_chunks_user_id_idx": {+ "name": "message_chunks_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_chunks_message_id_idx": {+ "name": "message_chunks_message_id_idx",+ "columns": [+ {+ "expression": "message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_chunks_workspace_id_idx": {+ "name": "message_chunks_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "message_chunks_message_id_messages_id_fk": {+ "name": "message_chunks_message_id_messages_id_fk",+ "tableFrom": "message_chunks",+ "tableTo": "messages",+ "columnsFrom": [+ "message_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_chunks_chunk_id_chunks_id_fk": {+ "name": "message_chunks_chunk_id_chunks_id_fk",+ "tableFrom": "message_chunks",+ "tableTo": "chunks",+ "columnsFrom": [+ "chunk_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_chunks_user_id_users_id_fk": {+ "name": "message_chunks_user_id_users_id_fk",+ "tableFrom": "message_chunks",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_chunks_workspace_id_workspaces_id_fk": {+ "name": "message_chunks_workspace_id_workspaces_id_fk",+ "tableFrom": "message_chunks",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "message_chunks_chunk_id_message_id_pk": {+ "name": "message_chunks_chunk_id_message_id_pk",+ "columns": [+ "chunk_id",+ "message_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.message_groups": {+ "name": "message_groups",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "parent_group_id": {+ "name": "parent_group_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "parent_message_id": {+ "name": "parent_message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "message_groups_client_id_user_id_unique": {+ "name": "message_groups_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_groups_user_id_idx": {+ "name": "message_groups_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_groups_topic_id_idx": {+ "name": "message_groups_topic_id_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_groups_type_idx": {+ "name": "message_groups_type_idx",+ "columns": [+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_groups_parent_group_id_idx": {+ "name": "message_groups_parent_group_id_idx",+ "columns": [+ {+ "expression": "parent_group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_groups_parent_message_id_idx": {+ "name": "message_groups_parent_message_id_idx",+ "columns": [+ {+ "expression": "parent_message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_groups_workspace_id_idx": {+ "name": "message_groups_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "message_groups_topic_id_topics_id_fk": {+ "name": "message_groups_topic_id_topics_id_fk",+ "tableFrom": "message_groups",+ "tableTo": "topics",+ "columnsFrom": [+ "topic_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_groups_user_id_users_id_fk": {+ "name": "message_groups_user_id_users_id_fk",+ "tableFrom": "message_groups",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_groups_workspace_id_workspaces_id_fk": {+ "name": "message_groups_workspace_id_workspaces_id_fk",+ "tableFrom": "message_groups",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_groups_parent_group_id_message_groups_id_fk": {+ "name": "message_groups_parent_group_id_message_groups_id_fk",+ "tableFrom": "message_groups",+ "tableTo": "message_groups",+ "columnsFrom": [+ "parent_group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_groups_parent_message_id_messages_id_fk": {+ "name": "message_groups_parent_message_id_messages_id_fk",+ "tableFrom": "message_groups",+ "tableTo": "messages",+ "columnsFrom": [+ "parent_message_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.message_plugins": {+ "name": "message_plugins",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "tool_call_id": {+ "name": "tool_call_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "default": "'default'"+ },+ "intervention": {+ "name": "intervention",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "api_name": {+ "name": "api_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "arguments": {+ "name": "arguments",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "state": {+ "name": "state",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "error": {+ "name": "error",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "message_plugins_client_id_user_id_unique": {+ "name": "message_plugins_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_plugins_user_id_idx": {+ "name": "message_plugins_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_plugins_tool_call_id_idx": {+ "name": "message_plugins_tool_call_id_idx",+ "columns": [+ {+ "expression": "tool_call_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_plugins_workspace_id_idx": {+ "name": "message_plugins_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "message_plugins_id_messages_id_fk": {+ "name": "message_plugins_id_messages_id_fk",+ "tableFrom": "message_plugins",+ "tableTo": "messages",+ "columnsFrom": [+ "id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_plugins_user_id_users_id_fk": {+ "name": "message_plugins_user_id_users_id_fk",+ "tableFrom": "message_plugins",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_plugins_workspace_id_workspaces_id_fk": {+ "name": "message_plugins_workspace_id_workspaces_id_fk",+ "tableFrom": "message_plugins",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.message_queries": {+ "name": "message_queries",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "message_id": {+ "name": "message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "rewrite_query": {+ "name": "rewrite_query",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_query": {+ "name": "user_query",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "embeddings_id": {+ "name": "embeddings_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "message_queries_client_id_user_id_unique": {+ "name": "message_queries_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_queries_user_id_idx": {+ "name": "message_queries_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_queries_message_id_idx": {+ "name": "message_queries_message_id_idx",+ "columns": [+ {+ "expression": "message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_queries_embeddings_id_idx": {+ "name": "message_queries_embeddings_id_idx",+ "columns": [+ {+ "expression": "embeddings_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_queries_workspace_id_idx": {+ "name": "message_queries_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "message_queries_message_id_messages_id_fk": {+ "name": "message_queries_message_id_messages_id_fk",+ "tableFrom": "message_queries",+ "tableTo": "messages",+ "columnsFrom": [+ "message_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_queries_user_id_users_id_fk": {+ "name": "message_queries_user_id_users_id_fk",+ "tableFrom": "message_queries",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_queries_workspace_id_workspaces_id_fk": {+ "name": "message_queries_workspace_id_workspaces_id_fk",+ "tableFrom": "message_queries",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_queries_embeddings_id_embeddings_id_fk": {+ "name": "message_queries_embeddings_id_embeddings_id_fk",+ "tableFrom": "message_queries",+ "tableTo": "embeddings",+ "columnsFrom": [+ "embeddings_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.message_query_chunks": {+ "name": "message_query_chunks",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "query_id": {+ "name": "query_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "chunk_id": {+ "name": "chunk_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "similarity": {+ "name": "similarity",+ "type": "numeric(6, 5)",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "message_query_chunks_user_id_idx": {+ "name": "message_query_chunks_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_query_chunks_message_id_idx": {+ "name": "message_query_chunks_message_id_idx",+ "columns": [+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_query_chunks_query_id_idx": {+ "name": "message_query_chunks_query_id_idx",+ "columns": [+ {+ "expression": "query_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_query_chunks_workspace_id_idx": {+ "name": "message_query_chunks_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "message_query_chunks_id_messages_id_fk": {+ "name": "message_query_chunks_id_messages_id_fk",+ "tableFrom": "message_query_chunks",+ "tableTo": "messages",+ "columnsFrom": [+ "id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_query_chunks_query_id_message_queries_id_fk": {+ "name": "message_query_chunks_query_id_message_queries_id_fk",+ "tableFrom": "message_query_chunks",+ "tableTo": "message_queries",+ "columnsFrom": [+ "query_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_query_chunks_chunk_id_chunks_id_fk": {+ "name": "message_query_chunks_chunk_id_chunks_id_fk",+ "tableFrom": "message_query_chunks",+ "tableTo": "chunks",+ "columnsFrom": [+ "chunk_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_query_chunks_user_id_users_id_fk": {+ "name": "message_query_chunks_user_id_users_id_fk",+ "tableFrom": "message_query_chunks",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_query_chunks_workspace_id_workspaces_id_fk": {+ "name": "message_query_chunks_workspace_id_workspaces_id_fk",+ "tableFrom": "message_query_chunks",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "message_query_chunks_chunk_id_id_query_id_pk": {+ "name": "message_query_chunks_chunk_id_id_query_id_pk",+ "columns": [+ "chunk_id",+ "id",+ "query_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.message_tts": {+ "name": "message_tts",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "content_md5": {+ "name": "content_md5",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "file_id": {+ "name": "file_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "voice": {+ "name": "voice",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "message_tts_client_id_user_id_unique": {+ "name": "message_tts_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_tts_user_id_idx": {+ "name": "message_tts_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_tts_workspace_id_idx": {+ "name": "message_tts_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "message_tts_id_messages_id_fk": {+ "name": "message_tts_id_messages_id_fk",+ "tableFrom": "message_tts",+ "tableTo": "messages",+ "columnsFrom": [+ "id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_tts_file_id_files_id_fk": {+ "name": "message_tts_file_id_files_id_fk",+ "tableFrom": "message_tts",+ "tableTo": "files",+ "columnsFrom": [+ "file_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_tts_user_id_users_id_fk": {+ "name": "message_tts_user_id_users_id_fk",+ "tableFrom": "message_tts",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_tts_workspace_id_workspaces_id_fk": {+ "name": "message_tts_workspace_id_workspaces_id_fk",+ "tableFrom": "message_tts",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.message_translates": {+ "name": "message_translates",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "from": {+ "name": "from",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "to": {+ "name": "to",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "message_translates_client_id_user_id_unique": {+ "name": "message_translates_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_translates_user_id_idx": {+ "name": "message_translates_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_translates_workspace_id_idx": {+ "name": "message_translates_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "message_translates_id_messages_id_fk": {+ "name": "message_translates_id_messages_id_fk",+ "tableFrom": "message_translates",+ "tableTo": "messages",+ "columnsFrom": [+ "id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_translates_user_id_users_id_fk": {+ "name": "message_translates_user_id_users_id_fk",+ "tableFrom": "message_translates",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_translates_workspace_id_workspaces_id_fk": {+ "name": "message_translates_workspace_id_workspaces_id_fk",+ "tableFrom": "message_translates",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.messages": {+ "name": "messages",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "summary": {+ "name": "summary",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "reasoning": {+ "name": "reasoning",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "search": {+ "name": "search",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "usage": {+ "name": "usage",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "favorite": {+ "name": "favorite",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "error": {+ "name": "error",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "tools": {+ "name": "tools",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "trace_id": {+ "name": "trace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "observation_id": {+ "name": "observation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "parent_id": {+ "name": "parent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "quota_id": {+ "name": "quota_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "target_id": {+ "name": "target_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "message_group_id": {+ "name": "message_group_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_deleted": {+ "name": "is_deleted",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "messages_created_at_idx": {+ "name": "messages_created_at_idx",+ "columns": [+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_client_id_user_unique": {+ "name": "message_client_id_user_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_topic_id_idx": {+ "name": "messages_topic_id_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_topic_id_updated_at_idx": {+ "name": "messages_topic_id_updated_at_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_parent_id_idx": {+ "name": "messages_parent_id_idx",+ "columns": [+ {+ "expression": "parent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_quota_id_idx": {+ "name": "messages_quota_id_idx",+ "columns": [+ {+ "expression": "quota_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_user_id_idx": {+ "name": "messages_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_session_id_idx": {+ "name": "messages_session_id_idx",+ "columns": [+ {+ "expression": "session_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_thread_id_idx": {+ "name": "messages_thread_id_idx",+ "columns": [+ {+ "expression": "thread_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_agent_id_idx": {+ "name": "messages_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_group_id_idx": {+ "name": "messages_group_id_idx",+ "columns": [+ {+ "expression": "group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_message_group_id_idx": {+ "name": "messages_message_group_id_idx",+ "columns": [+ {+ "expression": "message_group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_usage_cost_idx": {+ "name": "messages_usage_cost_idx",+ "columns": [+ {+ "expression": "((\"usage\"->>'cost')::numeric)",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_usage_total_tokens_idx": {+ "name": "messages_usage_total_tokens_idx",+ "columns": [+ {+ "expression": "((\"usage\"->>'totalTokens')::numeric)",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_workspace_id_idx": {+ "name": "messages_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "messages_user_id_users_id_fk": {+ "name": "messages_user_id_users_id_fk",+ "tableFrom": "messages",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "messages_session_id_sessions_id_fk": {+ "name": "messages_session_id_sessions_id_fk",+ "tableFrom": "messages",+ "tableTo": "sessions",+ "columnsFrom": [+ "session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "messages_topic_id_topics_id_fk": {+ "name": "messages_topic_id_topics_id_fk",+ "tableFrom": "messages",+ "tableTo": "topics",+ "columnsFrom": [+ "topic_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "messages_thread_id_threads_id_fk": {+ "name": "messages_thread_id_threads_id_fk",+ "tableFrom": "messages",+ "tableTo": "threads",+ "columnsFrom": [+ "thread_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "messages_parent_id_messages_id_fk": {+ "name": "messages_parent_id_messages_id_fk",+ "tableFrom": "messages",+ "tableTo": "messages",+ "columnsFrom": [+ "parent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "messages_quota_id_messages_id_fk": {+ "name": "messages_quota_id_messages_id_fk",+ "tableFrom": "messages",+ "tableTo": "messages",+ "columnsFrom": [+ "quota_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "messages_agent_id_agents_id_fk": {+ "name": "messages_agent_id_agents_id_fk",+ "tableFrom": "messages",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "messages_group_id_chat_groups_id_fk": {+ "name": "messages_group_id_chat_groups_id_fk",+ "tableFrom": "messages",+ "tableTo": "chat_groups",+ "columnsFrom": [+ "group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "messages_message_group_id_message_groups_id_fk": {+ "name": "messages_message_group_id_message_groups_id_fk",+ "tableFrom": "messages",+ "tableTo": "message_groups",+ "columnsFrom": [+ "message_group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "messages_workspace_id_workspaces_id_fk": {+ "name": "messages_workspace_id_workspaces_id_fk",+ "tableFrom": "messages",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.messages_files": {+ "name": "messages_files",+ "schema": "",+ "columns": {+ "file_id": {+ "name": "file_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "message_id": {+ "name": "message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "messages_files_user_id_idx": {+ "name": "messages_files_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_files_message_id_idx": {+ "name": "messages_files_message_id_idx",+ "columns": [+ {+ "expression": "message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_files_workspace_id_idx": {+ "name": "messages_files_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "messages_files_file_id_files_id_fk": {+ "name": "messages_files_file_id_files_id_fk",+ "tableFrom": "messages_files",+ "tableTo": "files",+ "columnsFrom": [+ "file_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "messages_files_message_id_messages_id_fk": {+ "name": "messages_files_message_id_messages_id_fk",+ "tableFrom": "messages_files",+ "tableTo": "messages",+ "columnsFrom": [+ "message_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "messages_files_user_id_users_id_fk": {+ "name": "messages_files_user_id_users_id_fk",+ "tableFrom": "messages_files",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "messages_files_workspace_id_workspaces_id_fk": {+ "name": "messages_files_workspace_id_workspaces_id_fk",+ "tableFrom": "messages_files",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "messages_files_file_id_message_id_pk": {+ "name": "messages_files_file_id_message_id_pk",+ "columns": [+ "file_id",+ "message_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.messenger_account_links": {+ "name": "messenger_account_links",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "platform": {+ "name": "platform",+ "type": "varchar(50)",+ "primaryKey": false,+ "notNull": true+ },+ "tenant_id": {+ "name": "tenant_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "platform_user_id": {+ "name": "platform_user_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "platform_username": {+ "name": "platform_username",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "application_id": {+ "name": "application_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "credentials": {+ "name": "credentials",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "active_agent_id": {+ "name": "active_agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "messenger_account_links_platform_tenant_user_unique": {+ "name": "messenger_account_links_platform_tenant_user_unique",+ "columns": [+ {+ "expression": "platform",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "tenant_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "platform_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messenger_account_links_user_platform_tenant_unique": {+ "name": "messenger_account_links_user_platform_tenant_unique",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "platform",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "tenant_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messenger_account_links_platform_tenant_application_unique": {+ "name": "messenger_account_links_platform_tenant_application_unique",+ "columns": [+ {+ "expression": "platform",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "tenant_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "application_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"messenger_account_links\".\"application_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messenger_account_links_active_agent_idx": {+ "name": "messenger_account_links_active_agent_idx",+ "columns": [+ {+ "expression": "active_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messenger_account_links_workspace_id_idx": {+ "name": "messenger_account_links_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "messenger_account_links_user_id_users_id_fk": {+ "name": "messenger_account_links_user_id_users_id_fk",+ "tableFrom": "messenger_account_links",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "messenger_account_links_workspace_id_workspaces_id_fk": {+ "name": "messenger_account_links_workspace_id_workspaces_id_fk",+ "tableFrom": "messenger_account_links",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "messenger_account_links_active_agent_id_agents_id_fk": {+ "name": "messenger_account_links_active_agent_id_agents_id_fk",+ "tableFrom": "messenger_account_links",+ "tableTo": "agents",+ "columnsFrom": [+ "active_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.messenger_installations": {+ "name": "messenger_installations",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "platform": {+ "name": "platform",+ "type": "varchar(50)",+ "primaryKey": false,+ "notNull": true+ },+ "tenant_id": {+ "name": "tenant_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "application_id": {+ "name": "application_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "account_id": {+ "name": "account_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "credentials": {+ "name": "credentials",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "token_expires_at": {+ "name": "token_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "installed_by_user_id": {+ "name": "installed_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "installed_by_platform_user_id": {+ "name": "installed_by_platform_user_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "revoked_at": {+ "name": "revoked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "messenger_installations_platform_app_tenant_unique": {+ "name": "messenger_installations_platform_app_tenant_unique",+ "columns": [+ {+ "expression": "platform",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "application_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "tenant_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messenger_installations_platform_tenant_idx": {+ "name": "messenger_installations_platform_tenant_idx",+ "columns": [+ {+ "expression": "platform",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "tenant_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messenger_installations_token_expires_at_idx": {+ "name": "messenger_installations_token_expires_at_idx",+ "columns": [+ {+ "expression": "token_expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "messenger_installations_installed_by_user_id_users_id_fk": {+ "name": "messenger_installations_installed_by_user_id_users_id_fk",+ "tableFrom": "messenger_installations",+ "tableTo": "users",+ "columnsFrom": [+ "installed_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.nextauth_accounts": {+ "name": "nextauth_accounts",+ "schema": "",+ "columns": {+ "access_token": {+ "name": "access_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "id_token": {+ "name": "id_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "providerAccountId": {+ "name": "providerAccountId",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "refresh_token": {+ "name": "refresh_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "session_state": {+ "name": "session_state",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "token_type": {+ "name": "token_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "nextauth_accounts_user_id_idx": {+ "name": "nextauth_accounts_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "nextauth_accounts_user_id_users_id_fk": {+ "name": "nextauth_accounts_user_id_users_id_fk",+ "tableFrom": "nextauth_accounts",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "nextauth_accounts_provider_providerAccountId_pk": {+ "name": "nextauth_accounts_provider_providerAccountId_pk",+ "columns": [+ "provider",+ "providerAccountId"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.nextauth_authenticators": {+ "name": "nextauth_authenticators",+ "schema": "",+ "columns": {+ "counter": {+ "name": "counter",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "credentialBackedUp": {+ "name": "credentialBackedUp",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true+ },+ "credentialDeviceType": {+ "name": "credentialDeviceType",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "credentialID": {+ "name": "credentialID",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "credentialPublicKey": {+ "name": "credentialPublicKey",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "providerAccountId": {+ "name": "providerAccountId",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "transports": {+ "name": "transports",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "nextauth_authenticators_user_id_users_id_fk": {+ "name": "nextauth_authenticators_user_id_users_id_fk",+ "tableFrom": "nextauth_authenticators",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "nextauth_authenticators_user_id_credentialID_pk": {+ "name": "nextauth_authenticators_user_id_credentialID_pk",+ "columns": [+ "user_id",+ "credentialID"+ ]+ }+ },+ "uniqueConstraints": {+ "nextauth_authenticators_credentialID_unique": {+ "name": "nextauth_authenticators_credentialID_unique",+ "nullsNotDistinct": false,+ "columns": [+ "credentialID"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.nextauth_sessions": {+ "name": "nextauth_sessions",+ "schema": "",+ "columns": {+ "expires": {+ "name": "expires",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "sessionToken": {+ "name": "sessionToken",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "nextauth_sessions_user_id_idx": {+ "name": "nextauth_sessions_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "nextauth_sessions_user_id_users_id_fk": {+ "name": "nextauth_sessions_user_id_users_id_fk",+ "tableFrom": "nextauth_sessions",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.nextauth_verificationtokens": {+ "name": "nextauth_verificationtokens",+ "schema": "",+ "columns": {+ "expires": {+ "name": "expires",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "nextauth_verificationtokens_identifier_token_pk": {+ "name": "nextauth_verificationtokens_identifier_token_pk",+ "columns": [+ "identifier",+ "token"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.notification_deliveries": {+ "name": "notification_deliveries",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "notification_id": {+ "name": "notification_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "channel": {+ "name": "channel",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider_message_id": {+ "name": "provider_message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "failed_reason": {+ "name": "failed_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "sent_at": {+ "name": "sent_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "idx_deliveries_notification": {+ "name": "idx_deliveries_notification",+ "columns": [+ {+ "expression": "notification_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_deliveries_channel": {+ "name": "idx_deliveries_channel",+ "columns": [+ {+ "expression": "channel",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_deliveries_status": {+ "name": "idx_deliveries_status",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "notification_deliveries_notification_id_notifications_id_fk": {+ "name": "notification_deliveries_notification_id_notifications_id_fk",+ "tableFrom": "notification_deliveries",+ "tableTo": "notifications",+ "columnsFrom": [+ "notification_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.notifications": {+ "name": "notifications",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "category": {+ "name": "category",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "context": {+ "name": "context",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "dedupe_key": {+ "name": "dedupe_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "action_url": {+ "name": "action_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "is_read": {+ "name": "is_read",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "is_archived": {+ "name": "is_archived",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "idx_notifications_user": {+ "name": "idx_notifications_user",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_notifications_user_active": {+ "name": "idx_notifications_user_active",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"notifications\".\"is_archived\" = false",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_notifications_user_unread": {+ "name": "idx_notifications_user_unread",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"notifications\".\"is_read\" = false AND \"notifications\".\"is_archived\" = false",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_notifications_dedupe": {+ "name": "idx_notifications_dedupe",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "dedupe_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_notifications_user_workspace": {+ "name": "idx_notifications_user_workspace",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_notifications_workspace_id": {+ "name": "idx_notifications_workspace_id",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_notifications_archived_cleanup": {+ "name": "idx_notifications_archived_cleanup",+ "columns": [+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"notifications\".\"is_archived\" = true",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "notifications_user_id_users_id_fk": {+ "name": "notifications_user_id_users_id_fk",+ "tableFrom": "notifications",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "notifications_workspace_id_workspaces_id_fk": {+ "name": "notifications_workspace_id_workspaces_id_fk",+ "tableFrom": "notifications",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oauth_handoffs": {+ "name": "oauth_handoffs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "client": {+ "name": "client",+ "type": "varchar(50)",+ "primaryKey": false,+ "notNull": true+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oidc_access_tokens": {+ "name": "oidc_access_tokens",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "data": {+ "name": "data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "consumed_at": {+ "name": "consumed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "grant_id": {+ "name": "grant_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "oidc_access_tokens_user_id_idx": {+ "name": "oidc_access_tokens_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oidc_access_tokens_user_id_users_id_fk": {+ "name": "oidc_access_tokens_user_id_users_id_fk",+ "tableFrom": "oidc_access_tokens",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oidc_authorization_codes": {+ "name": "oidc_authorization_codes",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "data": {+ "name": "data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "consumed_at": {+ "name": "consumed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "grant_id": {+ "name": "grant_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "oidc_authorization_codes_user_id_idx": {+ "name": "oidc_authorization_codes_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oidc_authorization_codes_user_id_users_id_fk": {+ "name": "oidc_authorization_codes_user_id_users_id_fk",+ "tableFrom": "oidc_authorization_codes",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oidc_clients": {+ "name": "oidc_clients",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_secret": {+ "name": "client_secret",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "redirect_uris": {+ "name": "redirect_uris",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true+ },+ "grants": {+ "name": "grants",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true+ },+ "response_types": {+ "name": "response_types",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true+ },+ "scopes": {+ "name": "scopes",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true+ },+ "token_endpoint_auth_method": {+ "name": "token_endpoint_auth_method",+ "type": "varchar(20)",+ "primaryKey": false,+ "notNull": false+ },+ "application_type": {+ "name": "application_type",+ "type": "varchar(20)",+ "primaryKey": false,+ "notNull": false+ },+ "client_uri": {+ "name": "client_uri",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "logo_uri": {+ "name": "logo_uri",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "policy_uri": {+ "name": "policy_uri",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "tos_uri": {+ "name": "tos_uri",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "is_first_party": {+ "name": "is_first_party",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "last_used_at": {+ "name": "last_used_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "oidc_clients_user_id_idx": {+ "name": "oidc_clients_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oidc_clients_workspace_id_idx": {+ "name": "oidc_clients_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oidc_clients_user_id_users_id_fk": {+ "name": "oidc_clients_user_id_users_id_fk",+ "tableFrom": "oidc_clients",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "oidc_clients_workspace_id_workspaces_id_fk": {+ "name": "oidc_clients_workspace_id_workspaces_id_fk",+ "tableFrom": "oidc_clients",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oidc_consents": {+ "name": "oidc_consents",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "scopes": {+ "name": "scopes",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "oidc_consents_user_id_users_id_fk": {+ "name": "oidc_consents_user_id_users_id_fk",+ "tableFrom": "oidc_consents",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "oidc_consents_client_id_oidc_clients_id_fk": {+ "name": "oidc_consents_client_id_oidc_clients_id_fk",+ "tableFrom": "oidc_consents",+ "tableTo": "oidc_clients",+ "columnsFrom": [+ "client_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "oidc_consents_user_id_client_id_pk": {+ "name": "oidc_consents_user_id_client_id_pk",+ "columns": [+ "user_id",+ "client_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oidc_device_codes": {+ "name": "oidc_device_codes",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "data": {+ "name": "data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "consumed_at": {+ "name": "consumed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "grant_id": {+ "name": "grant_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "user_code": {+ "name": "user_code",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "oidc_device_codes_user_id_idx": {+ "name": "oidc_device_codes_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oidc_device_codes_user_id_users_id_fk": {+ "name": "oidc_device_codes_user_id_users_id_fk",+ "tableFrom": "oidc_device_codes",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oidc_grants": {+ "name": "oidc_grants",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "data": {+ "name": "data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "consumed_at": {+ "name": "consumed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "oidc_grants_user_id_idx": {+ "name": "oidc_grants_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oidc_grants_user_id_users_id_fk": {+ "name": "oidc_grants_user_id_users_id_fk",+ "tableFrom": "oidc_grants",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oidc_interactions": {+ "name": "oidc_interactions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "data": {+ "name": "data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oidc_refresh_tokens": {+ "name": "oidc_refresh_tokens",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "data": {+ "name": "data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "consumed_at": {+ "name": "consumed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "grant_id": {+ "name": "grant_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "oidc_refresh_tokens_user_id_idx": {+ "name": "oidc_refresh_tokens_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oidc_refresh_tokens_user_id_users_id_fk": {+ "name": "oidc_refresh_tokens_user_id_users_id_fk",+ "tableFrom": "oidc_refresh_tokens",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oidc_sessions": {+ "name": "oidc_sessions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "data": {+ "name": "data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "oidc_sessions_user_id_idx": {+ "name": "oidc_sessions_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oidc_sessions_user_id_users_id_fk": {+ "name": "oidc_sessions_user_id_users_id_fk",+ "tableFrom": "oidc_sessions",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_agents": {+ "name": "project_agents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "added_by_user_id": {+ "name": "added_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "responsibility": {+ "name": "responsibility",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "sort_order": {+ "name": "sort_order",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_agents_project_id_agent_id_unique": {+ "name": "project_agents_project_id_agent_id_unique",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_agents_project_id_sort_order_idx": {+ "name": "project_agents_project_id_sort_order_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "sort_order",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_agents_agent_id_idx": {+ "name": "project_agents_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_agents_workspace_id_idx": {+ "name": "project_agents_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_agents_project_id_projects_id_fk": {+ "name": "project_agents_project_id_projects_id_fk",+ "tableFrom": "project_agents",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_agents_agent_id_agents_id_fk": {+ "name": "project_agents_agent_id_agents_id_fk",+ "tableFrom": "project_agents",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_agents_added_by_user_id_users_id_fk": {+ "name": "project_agents_added_by_user_id_users_id_fk",+ "tableFrom": "project_agents",+ "tableTo": "users",+ "columnsFrom": [+ "added_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_agents_workspace_id_workspaces_id_fk": {+ "name": "project_agents_workspace_id_workspaces_id_fk",+ "tableFrom": "project_agents",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_chat_groups": {+ "name": "project_chat_groups",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "chat_group_id": {+ "name": "chat_group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "added_by_user_id": {+ "name": "added_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "responsibility": {+ "name": "responsibility",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "sort_order": {+ "name": "sort_order",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_chat_groups_project_id_chat_group_id_unique": {+ "name": "project_chat_groups_project_id_chat_group_id_unique",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "chat_group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_chat_groups_project_id_sort_order_idx": {+ "name": "project_chat_groups_project_id_sort_order_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "sort_order",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_chat_groups_chat_group_id_idx": {+ "name": "project_chat_groups_chat_group_id_idx",+ "columns": [+ {+ "expression": "chat_group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_chat_groups_workspace_id_idx": {+ "name": "project_chat_groups_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_chat_groups_project_id_projects_id_fk": {+ "name": "project_chat_groups_project_id_projects_id_fk",+ "tableFrom": "project_chat_groups",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_chat_groups_chat_group_id_chat_groups_id_fk": {+ "name": "project_chat_groups_chat_group_id_chat_groups_id_fk",+ "tableFrom": "project_chat_groups",+ "tableTo": "chat_groups",+ "columnsFrom": [+ "chat_group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_chat_groups_added_by_user_id_users_id_fk": {+ "name": "project_chat_groups_added_by_user_id_users_id_fk",+ "tableFrom": "project_chat_groups",+ "tableTo": "users",+ "columnsFrom": [+ "added_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_chat_groups_workspace_id_workspaces_id_fk": {+ "name": "project_chat_groups_workspace_id_workspaces_id_fk",+ "tableFrom": "project_chat_groups",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_completion_reviews": {+ "name": "project_completion_reviews",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "reviewer_user_id": {+ "name": "reviewer_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "round": {+ "name": "round",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "decision": {+ "name": "decision",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "comment": {+ "name": "comment",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_completion_reviews_project_id_round_unique": {+ "name": "project_completion_reviews_project_id_round_unique",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "round",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_completion_reviews_project_id_created_at_idx": {+ "name": "project_completion_reviews_project_id_created_at_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_completion_reviews_reviewer_user_id_idx": {+ "name": "project_completion_reviews_reviewer_user_id_idx",+ "columns": [+ {+ "expression": "reviewer_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_completion_reviews_workspace_id_idx": {+ "name": "project_completion_reviews_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_completion_reviews_project_id_projects_id_fk": {+ "name": "project_completion_reviews_project_id_projects_id_fk",+ "tableFrom": "project_completion_reviews",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_completion_reviews_reviewer_user_id_users_id_fk": {+ "name": "project_completion_reviews_reviewer_user_id_users_id_fk",+ "tableFrom": "project_completion_reviews",+ "tableTo": "users",+ "columnsFrom": [+ "reviewer_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_completion_reviews_workspace_id_workspaces_id_fk": {+ "name": "project_completion_reviews_workspace_id_workspaces_id_fk",+ "tableFrom": "project_completion_reviews",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "project_completion_reviews_round_positive": {+ "name": "project_completion_reviews_round_positive",+ "value": "\"project_completion_reviews\".\"round\" > 0"+ }+ },+ "isRLSEnabled": false+ },+ "public.project_knowledge_bases": {+ "name": "project_knowledge_bases",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "knowledge_base_id": {+ "name": "knowledge_base_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "added_by_user_id": {+ "name": "added_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "sort_order": {+ "name": "sort_order",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_knowledge_bases_project_id_knowledge_base_id_unique": {+ "name": "project_knowledge_bases_project_id_knowledge_base_id_unique",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "knowledge_base_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_knowledge_bases_project_id_sort_order_idx": {+ "name": "project_knowledge_bases_project_id_sort_order_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "sort_order",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_knowledge_bases_knowledge_base_id_idx": {+ "name": "project_knowledge_bases_knowledge_base_id_idx",+ "columns": [+ {+ "expression": "knowledge_base_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_knowledge_bases_workspace_id_idx": {+ "name": "project_knowledge_bases_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_knowledge_bases_project_id_projects_id_fk": {+ "name": "project_knowledge_bases_project_id_projects_id_fk",+ "tableFrom": "project_knowledge_bases",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_knowledge_bases_knowledge_base_id_knowledge_bases_id_fk": {+ "name": "project_knowledge_bases_knowledge_base_id_knowledge_bases_id_fk",+ "tableFrom": "project_knowledge_bases",+ "tableTo": "knowledge_bases",+ "columnsFrom": [+ "knowledge_base_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_knowledge_bases_added_by_user_id_users_id_fk": {+ "name": "project_knowledge_bases_added_by_user_id_users_id_fk",+ "tableFrom": "project_knowledge_bases",+ "tableTo": "users",+ "columnsFrom": [+ "added_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_knowledge_bases_workspace_id_workspaces_id_fk": {+ "name": "project_knowledge_bases_workspace_id_workspaces_id_fk",+ "tableFrom": "project_knowledge_bases",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_works": {+ "name": "project_works",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "work_id": {+ "name": "work_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "added_by_user_id": {+ "name": "added_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "sort_order": {+ "name": "sort_order",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_works_project_id_work_id_unique": {+ "name": "project_works_project_id_work_id_unique",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "work_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_works_project_id_sort_order_idx": {+ "name": "project_works_project_id_sort_order_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "sort_order",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_works_work_id_idx": {+ "name": "project_works_work_id_idx",+ "columns": [+ {+ "expression": "work_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_works_workspace_id_idx": {+ "name": "project_works_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_works_project_id_projects_id_fk": {+ "name": "project_works_project_id_projects_id_fk",+ "tableFrom": "project_works",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_works_work_id_works_id_fk": {+ "name": "project_works_work_id_works_id_fk",+ "tableFrom": "project_works",+ "tableTo": "works",+ "columnsFrom": [+ "work_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_works_added_by_user_id_users_id_fk": {+ "name": "project_works_added_by_user_id_users_id_fk",+ "tableFrom": "project_works",+ "tableTo": "users",+ "columnsFrom": [+ "added_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_works_workspace_id_workspaces_id_fk": {+ "name": "project_works_workspace_id_workspaces_id_fk",+ "tableFrom": "project_works",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.projects": {+ "name": "projects",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "slug": {+ "name": "slug",+ "type": "varchar(100)",+ "primaryKey": false,+ "notNull": false+ },+ "identifier": {+ "name": "identifier",+ "type": "varchar(6)",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "avatar": {+ "name": "avatar",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "coordinator_agent_id": {+ "name": "coordinator_agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'backlog'"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "completed_review_id": {+ "name": "completed_review_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "archived_at": {+ "name": "archived_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_deleted": {+ "name": "is_deleted",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "projects_slug_user_id_unique": {+ "name": "projects_slug_user_id_unique",+ "columns": [+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"projects\".\"workspace_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "projects_slug_workspace_id_unique": {+ "name": "projects_slug_workspace_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"projects\".\"workspace_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "projects_identifier_user_id_unique": {+ "name": "projects_identifier_user_id_unique",+ "columns": [+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"projects\".\"workspace_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "projects_identifier_workspace_id_unique": {+ "name": "projects_identifier_workspace_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"projects\".\"workspace_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "projects_user_id_idx": {+ "name": "projects_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "projects_workspace_id_idx": {+ "name": "projects_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "projects_workspace_visibility_idx": {+ "name": "projects_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "projects_status_updated_at_idx": {+ "name": "projects_status_updated_at_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "projects_coordinator_agent_id_unique": {+ "name": "projects_coordinator_agent_id_unique",+ "columns": [+ {+ "expression": "coordinator_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "projects_coordinator_agent_id_agents_id_fk": {+ "name": "projects_coordinator_agent_id_agents_id_fk",+ "tableFrom": "projects",+ "tableTo": "agents",+ "columnsFrom": [+ "coordinator_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "restrict",+ "onUpdate": "no action"+ },+ "projects_user_id_users_id_fk": {+ "name": "projects_user_id_users_id_fk",+ "tableFrom": "projects",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "projects_workspace_id_workspaces_id_fk": {+ "name": "projects_workspace_id_workspaces_id_fk",+ "tableFrom": "projects",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "projects_completed_requires_human_review": {+ "name": "projects_completed_requires_human_review",+ "value": "\"projects\".\"status\" <> 'completed' OR (\"projects\".\"completed_review_id\" IS NOT NULL AND \"projects\".\"completed_at\" IS NOT NULL)"+ }+ },+ "isRLSEnabled": false+ },+ "public.push_live_activities": {+ "name": "push_live_activities",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "device_id": {+ "name": "device_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "activity_key": {+ "name": "activity_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "operation_id": {+ "name": "operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "activity_id": {+ "name": "activity_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "push_token": {+ "name": "push_token",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "apns_environment": {+ "name": "apns_environment",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_seen_at": {+ "name": "last_seen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "idx_push_live_activities_user_device_activity": {+ "name": "idx_push_live_activities_user_device_activity",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "device_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "activity_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_push_live_activities_user_activity": {+ "name": "idx_push_live_activities_user_activity",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "activity_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_push_live_activities_user_operation": {+ "name": "idx_push_live_activities_user_operation",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_push_live_activities_last_seen": {+ "name": "idx_push_live_activities_last_seen",+ "columns": [+ {+ "expression": "last_seen_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "push_live_activities_user_id_users_id_fk": {+ "name": "push_live_activities_user_id_users_id_fk",+ "tableFrom": "push_live_activities",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "push_live_activities_apns_environment_check": {+ "name": "push_live_activities_apns_environment_check",+ "value": "\"push_live_activities\".\"apns_environment\" IN ('sandbox', 'production')"+ }+ },+ "isRLSEnabled": false+ },+ "public.push_tokens": {+ "name": "push_tokens",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "expo_token": {+ "name": "expo_token",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "device_id": {+ "name": "device_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "platform": {+ "name": "platform",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "apns_environment": {+ "name": "apns_environment",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "app_version": {+ "name": "app_version",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "locale": {+ "name": "locale",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "live_activity_push_to_start_token": {+ "name": "live_activity_push_to_start_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_seen_at": {+ "name": "last_seen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "idx_push_tokens_user_device": {+ "name": "idx_push_tokens_user_device",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "device_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_push_tokens_user": {+ "name": "idx_push_tokens_user",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_push_tokens_last_seen": {+ "name": "idx_push_tokens_last_seen",+ "columns": [+ {+ "expression": "last_seen_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "push_tokens_user_id_users_id_fk": {+ "name": "push_tokens_user_id_users_id_fk",+ "tableFrom": "push_tokens",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "push_tokens_apns_environment_check": {+ "name": "push_tokens_apns_environment_check",+ "value": "\"push_tokens\".\"apns_environment\" IS NULL OR \"push_tokens\".\"apns_environment\" IN ('sandbox', 'production')"+ }+ },+ "isRLSEnabled": false+ },+ "public.chunks": {+ "name": "chunks",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "text": {+ "name": "text",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "abstract": {+ "name": "abstract",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "index": {+ "name": "index",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "varchar",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "chunks_client_id_user_id_unique": {+ "name": "chunks_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chunks_user_id_idx": {+ "name": "chunks_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chunks_workspace_id_idx": {+ "name": "chunks_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "chunks_user_id_users_id_fk": {+ "name": "chunks_user_id_users_id_fk",+ "tableFrom": "chunks",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chunks_workspace_id_workspaces_id_fk": {+ "name": "chunks_workspace_id_workspaces_id_fk",+ "tableFrom": "chunks",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.document_chunks": {+ "name": "document_chunks",+ "schema": "",+ "columns": {+ "document_id": {+ "name": "document_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true+ },+ "chunk_id": {+ "name": "chunk_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "page_index": {+ "name": "page_index",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "document_chunks_document_id_idx": {+ "name": "document_chunks_document_id_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_chunks_chunk_id_idx": {+ "name": "document_chunks_chunk_id_idx",+ "columns": [+ {+ "expression": "chunk_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_chunks_user_id_idx": {+ "name": "document_chunks_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_chunks_workspace_id_idx": {+ "name": "document_chunks_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "document_chunks_document_id_documents_id_fk": {+ "name": "document_chunks_document_id_documents_id_fk",+ "tableFrom": "document_chunks",+ "tableTo": "documents",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_chunks_chunk_id_chunks_id_fk": {+ "name": "document_chunks_chunk_id_chunks_id_fk",+ "tableFrom": "document_chunks",+ "tableTo": "chunks",+ "columnsFrom": [+ "chunk_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_chunks_user_id_users_id_fk": {+ "name": "document_chunks_user_id_users_id_fk",+ "tableFrom": "document_chunks",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_chunks_workspace_id_workspaces_id_fk": {+ "name": "document_chunks_workspace_id_workspaces_id_fk",+ "tableFrom": "document_chunks",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "document_chunks_document_id_chunk_id_pk": {+ "name": "document_chunks_document_id_chunk_id_pk",+ "columns": [+ "document_id",+ "chunk_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.embeddings": {+ "name": "embeddings",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "chunk_id": {+ "name": "chunk_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "embeddings": {+ "name": "embeddings",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "embeddings_client_id_user_id_unique": {+ "name": "embeddings_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "embeddings_chunk_id_idx": {+ "name": "embeddings_chunk_id_idx",+ "columns": [+ {+ "expression": "chunk_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "embeddings_user_id_idx": {+ "name": "embeddings_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "embeddings_workspace_id_idx": {+ "name": "embeddings_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "embeddings_chunk_id_chunks_id_fk": {+ "name": "embeddings_chunk_id_chunks_id_fk",+ "tableFrom": "embeddings",+ "tableTo": "chunks",+ "columnsFrom": [+ "chunk_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "embeddings_user_id_users_id_fk": {+ "name": "embeddings_user_id_users_id_fk",+ "tableFrom": "embeddings",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "embeddings_workspace_id_workspaces_id_fk": {+ "name": "embeddings_workspace_id_workspaces_id_fk",+ "tableFrom": "embeddings",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "embeddings_chunk_id_unique": {+ "name": "embeddings_chunk_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "chunk_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.unstructured_chunks": {+ "name": "unstructured_chunks",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "text": {+ "name": "text",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "index": {+ "name": "index",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "varchar",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "parent_id": {+ "name": "parent_id",+ "type": "varchar",+ "primaryKey": false,+ "notNull": false+ },+ "composite_id": {+ "name": "composite_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "file_id": {+ "name": "file_id",+ "type": "varchar",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "unstructured_chunks_client_id_user_id_unique": {+ "name": "unstructured_chunks_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "unstructured_chunks_user_id_idx": {+ "name": "unstructured_chunks_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "unstructured_chunks_composite_id_idx": {+ "name": "unstructured_chunks_composite_id_idx",+ "columns": [+ {+ "expression": "composite_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "unstructured_chunks_file_id_idx": {+ "name": "unstructured_chunks_file_id_idx",+ "columns": [+ {+ "expression": "file_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "unstructured_chunks_workspace_id_idx": {+ "name": "unstructured_chunks_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "unstructured_chunks_composite_id_chunks_id_fk": {+ "name": "unstructured_chunks_composite_id_chunks_id_fk",+ "tableFrom": "unstructured_chunks",+ "tableTo": "chunks",+ "columnsFrom": [+ "composite_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "unstructured_chunks_user_id_users_id_fk": {+ "name": "unstructured_chunks_user_id_users_id_fk",+ "tableFrom": "unstructured_chunks",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "unstructured_chunks_workspace_id_workspaces_id_fk": {+ "name": "unstructured_chunks_workspace_id_workspaces_id_fk",+ "tableFrom": "unstructured_chunks",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "unstructured_chunks_file_id_files_id_fk": {+ "name": "unstructured_chunks_file_id_files_id_fk",+ "tableFrom": "unstructured_chunks",+ "tableTo": "files",+ "columnsFrom": [+ "file_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.rag_eval_dataset_records": {+ "name": "rag_eval_dataset_records",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "dataset_id": {+ "name": "dataset_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "ideal": {+ "name": "ideal",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "question": {+ "name": "question",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "reference_files": {+ "name": "reference_files",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "rag_eval_dataset_records_user_id_idx": {+ "name": "rag_eval_dataset_records_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "rag_eval_dataset_records_workspace_id_idx": {+ "name": "rag_eval_dataset_records_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "rag_eval_dataset_records_dataset_id_rag_eval_datasets_id_fk": {+ "name": "rag_eval_dataset_records_dataset_id_rag_eval_datasets_id_fk",+ "tableFrom": "rag_eval_dataset_records",+ "tableTo": "rag_eval_datasets",+ "columnsFrom": [+ "dataset_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rag_eval_dataset_records_user_id_users_id_fk": {+ "name": "rag_eval_dataset_records_user_id_users_id_fk",+ "tableFrom": "rag_eval_dataset_records",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rag_eval_dataset_records_workspace_id_workspaces_id_fk": {+ "name": "rag_eval_dataset_records_workspace_id_workspaces_id_fk",+ "tableFrom": "rag_eval_dataset_records",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.rag_eval_datasets": {+ "name": "rag_eval_datasets",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "knowledge_base_id": {+ "name": "knowledge_base_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "rag_eval_datasets_user_id_idx": {+ "name": "rag_eval_datasets_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "rag_eval_datasets_workspace_id_idx": {+ "name": "rag_eval_datasets_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "rag_eval_datasets_knowledge_base_id_knowledge_bases_id_fk": {+ "name": "rag_eval_datasets_knowledge_base_id_knowledge_bases_id_fk",+ "tableFrom": "rag_eval_datasets",+ "tableTo": "knowledge_bases",+ "columnsFrom": [+ "knowledge_base_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rag_eval_datasets_user_id_users_id_fk": {+ "name": "rag_eval_datasets_user_id_users_id_fk",+ "tableFrom": "rag_eval_datasets",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rag_eval_datasets_workspace_id_workspaces_id_fk": {+ "name": "rag_eval_datasets_workspace_id_workspaces_id_fk",+ "tableFrom": "rag_eval_datasets",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.rag_eval_evaluations": {+ "name": "rag_eval_evaluations",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "eval_records_url": {+ "name": "eval_records_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "error": {+ "name": "error",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "dataset_id": {+ "name": "dataset_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "knowledge_base_id": {+ "name": "knowledge_base_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "language_model": {+ "name": "language_model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "embedding_model": {+ "name": "embedding_model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "rag_eval_evaluations_user_id_idx": {+ "name": "rag_eval_evaluations_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "rag_eval_evaluations_workspace_id_idx": {+ "name": "rag_eval_evaluations_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "rag_eval_evaluations_dataset_id_rag_eval_datasets_id_fk": {+ "name": "rag_eval_evaluations_dataset_id_rag_eval_datasets_id_fk",+ "tableFrom": "rag_eval_evaluations",+ "tableTo": "rag_eval_datasets",+ "columnsFrom": [+ "dataset_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rag_eval_evaluations_knowledge_base_id_knowledge_bases_id_fk": {+ "name": "rag_eval_evaluations_knowledge_base_id_knowledge_bases_id_fk",+ "tableFrom": "rag_eval_evaluations",+ "tableTo": "knowledge_bases",+ "columnsFrom": [+ "knowledge_base_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rag_eval_evaluations_user_id_users_id_fk": {+ "name": "rag_eval_evaluations_user_id_users_id_fk",+ "tableFrom": "rag_eval_evaluations",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rag_eval_evaluations_workspace_id_workspaces_id_fk": {+ "name": "rag_eval_evaluations_workspace_id_workspaces_id_fk",+ "tableFrom": "rag_eval_evaluations",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.rag_eval_evaluation_records": {+ "name": "rag_eval_evaluation_records",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "question": {+ "name": "question",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "answer": {+ "name": "answer",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "context": {+ "name": "context",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "ideal": {+ "name": "ideal",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "error": {+ "name": "error",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "language_model": {+ "name": "language_model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "embedding_model": {+ "name": "embedding_model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "question_embedding_id": {+ "name": "question_embedding_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "duration": {+ "name": "duration",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "dataset_record_id": {+ "name": "dataset_record_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "evaluation_id": {+ "name": "evaluation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "rag_eval_evaluation_records_user_id_idx": {+ "name": "rag_eval_evaluation_records_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "rag_eval_evaluation_records_workspace_id_idx": {+ "name": "rag_eval_evaluation_records_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "rag_eval_evaluation_records_question_embedding_id_embeddings_id_fk": {+ "name": "rag_eval_evaluation_records_question_embedding_id_embeddings_id_fk",+ "tableFrom": "rag_eval_evaluation_records",+ "tableTo": "embeddings",+ "columnsFrom": [+ "question_embedding_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "rag_eval_evaluation_records_dataset_record_id_rag_eval_dataset_records_id_fk": {+ "name": "rag_eval_evaluation_records_dataset_record_id_rag_eval_dataset_records_id_fk",+ "tableFrom": "rag_eval_evaluation_records",+ "tableTo": "rag_eval_dataset_records",+ "columnsFrom": [+ "dataset_record_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rag_eval_evaluation_records_evaluation_id_rag_eval_evaluations_id_fk": {+ "name": "rag_eval_evaluation_records_evaluation_id_rag_eval_evaluations_id_fk",+ "tableFrom": "rag_eval_evaluation_records",+ "tableTo": "rag_eval_evaluations",+ "columnsFrom": [+ "evaluation_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rag_eval_evaluation_records_user_id_users_id_fk": {+ "name": "rag_eval_evaluation_records_user_id_users_id_fk",+ "tableFrom": "rag_eval_evaluation_records",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rag_eval_evaluation_records_workspace_id_workspaces_id_fk": {+ "name": "rag_eval_evaluation_records_workspace_id_workspaces_id_fk",+ "tableFrom": "rag_eval_evaluation_records",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.rbac_permissions": {+ "name": "rbac_permissions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "code": {+ "name": "code",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "category": {+ "name": "category",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "is_active": {+ "name": "is_active",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "rbac_permissions_code_unique": {+ "name": "rbac_permissions_code_unique",+ "nullsNotDistinct": false,+ "columns": [+ "code"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.rbac_role_permissions": {+ "name": "rbac_role_permissions",+ "schema": "",+ "columns": {+ "role_id": {+ "name": "role_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "permission_id": {+ "name": "permission_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "rbac_role_permissions_role_id_idx": {+ "name": "rbac_role_permissions_role_id_idx",+ "columns": [+ {+ "expression": "role_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "rbac_role_permissions_permission_id_idx": {+ "name": "rbac_role_permissions_permission_id_idx",+ "columns": [+ {+ "expression": "permission_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "rbac_role_permissions_role_id_rbac_roles_id_fk": {+ "name": "rbac_role_permissions_role_id_rbac_roles_id_fk",+ "tableFrom": "rbac_role_permissions",+ "tableTo": "rbac_roles",+ "columnsFrom": [+ "role_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rbac_role_permissions_permission_id_rbac_permissions_id_fk": {+ "name": "rbac_role_permissions_permission_id_rbac_permissions_id_fk",+ "tableFrom": "rbac_role_permissions",+ "tableTo": "rbac_permissions",+ "columnsFrom": [+ "permission_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "rbac_role_permissions_role_id_permission_id_pk": {+ "name": "rbac_role_permissions_role_id_permission_id_pk",+ "columns": [+ "role_id",+ "permission_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.rbac_roles": {+ "name": "rbac_roles",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "display_name": {+ "name": "display_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "is_system": {+ "name": "is_system",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "is_active": {+ "name": "is_active",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "rbac_roles_workspace_id_idx": {+ "name": "rbac_roles_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "rbac_roles_name_workspace_unique": {+ "name": "rbac_roles_name_workspace_unique",+ "columns": [+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "COALESCE(\"workspace_id\", '')",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "rbac_roles_workspace_id_workspaces_id_fk": {+ "name": "rbac_roles_workspace_id_workspaces_id_fk",+ "tableFrom": "rbac_roles",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.rbac_user_roles": {+ "name": "rbac_user_roles",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "role_id": {+ "name": "role_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "rbac_user_roles_user_role_scope_unique": {+ "name": "rbac_user_roles_user_role_scope_unique",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "role_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "COALESCE(\"workspace_id\", '')",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "rbac_user_roles_user_id_idx": {+ "name": "rbac_user_roles_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "rbac_user_roles_role_id_idx": {+ "name": "rbac_user_roles_role_id_idx",+ "columns": [+ {+ "expression": "role_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "rbac_user_roles_workspace_id_idx": {+ "name": "rbac_user_roles_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "rbac_user_roles_user_id_users_id_fk": {+ "name": "rbac_user_roles_user_id_users_id_fk",+ "tableFrom": "rbac_user_roles",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rbac_user_roles_role_id_rbac_roles_id_fk": {+ "name": "rbac_user_roles_role_id_rbac_roles_id_fk",+ "tableFrom": "rbac_user_roles",+ "tableTo": "rbac_roles",+ "columnsFrom": [+ "role_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rbac_user_roles_workspace_id_workspaces_id_fk": {+ "name": "rbac_user_roles_workspace_id_workspaces_id_fk",+ "tableFrom": "rbac_user_roles",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agents_to_sessions": {+ "name": "agents_to_sessions",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "agents_to_sessions_session_id_idx": {+ "name": "agents_to_sessions_session_id_idx",+ "columns": [+ {+ "expression": "session_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_to_sessions_agent_id_idx": {+ "name": "agents_to_sessions_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_to_sessions_user_id_idx": {+ "name": "agents_to_sessions_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_to_sessions_workspace_id_idx": {+ "name": "agents_to_sessions_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agents_to_sessions_agent_id_agents_id_fk": {+ "name": "agents_to_sessions_agent_id_agents_id_fk",+ "tableFrom": "agents_to_sessions",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agents_to_sessions_session_id_sessions_id_fk": {+ "name": "agents_to_sessions_session_id_sessions_id_fk",+ "tableFrom": "agents_to_sessions",+ "tableTo": "sessions",+ "columnsFrom": [+ "session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agents_to_sessions_user_id_users_id_fk": {+ "name": "agents_to_sessions_user_id_users_id_fk",+ "tableFrom": "agents_to_sessions",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agents_to_sessions_workspace_id_workspaces_id_fk": {+ "name": "agents_to_sessions_workspace_id_workspaces_id_fk",+ "tableFrom": "agents_to_sessions",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agents_to_sessions_agent_id_session_id_pk": {+ "name": "agents_to_sessions_agent_id_session_id_pk",+ "columns": [+ "agent_id",+ "session_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.file_chunks": {+ "name": "file_chunks",+ "schema": "",+ "columns": {+ "file_id": {+ "name": "file_id",+ "type": "varchar",+ "primaryKey": false,+ "notNull": false+ },+ "chunk_id": {+ "name": "chunk_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "file_chunks_user_id_idx": {+ "name": "file_chunks_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "file_chunks_workspace_id_idx": {+ "name": "file_chunks_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "file_chunks_file_id_idx": {+ "name": "file_chunks_file_id_idx",+ "columns": [+ {+ "expression": "file_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "file_chunks_chunk_id_idx": {+ "name": "file_chunks_chunk_id_idx",+ "columns": [+ {+ "expression": "chunk_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "file_chunks_file_id_files_id_fk": {+ "name": "file_chunks_file_id_files_id_fk",+ "tableFrom": "file_chunks",+ "tableTo": "files",+ "columnsFrom": [+ "file_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "file_chunks_chunk_id_chunks_id_fk": {+ "name": "file_chunks_chunk_id_chunks_id_fk",+ "tableFrom": "file_chunks",+ "tableTo": "chunks",+ "columnsFrom": [+ "chunk_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "file_chunks_user_id_users_id_fk": {+ "name": "file_chunks_user_id_users_id_fk",+ "tableFrom": "file_chunks",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "file_chunks_workspace_id_workspaces_id_fk": {+ "name": "file_chunks_workspace_id_workspaces_id_fk",+ "tableFrom": "file_chunks",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "file_chunks_file_id_chunk_id_pk": {+ "name": "file_chunks_file_id_chunk_id_pk",+ "columns": [+ "file_id",+ "chunk_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.files_to_sessions": {+ "name": "files_to_sessions",+ "schema": "",+ "columns": {+ "file_id": {+ "name": "file_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "files_to_sessions_user_id_idx": {+ "name": "files_to_sessions_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "files_to_sessions_workspace_id_idx": {+ "name": "files_to_sessions_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "files_to_sessions_file_id_idx": {+ "name": "files_to_sessions_file_id_idx",+ "columns": [+ {+ "expression": "file_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "files_to_sessions_session_id_idx": {+ "name": "files_to_sessions_session_id_idx",+ "columns": [+ {+ "expression": "session_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "files_to_sessions_file_id_files_id_fk": {+ "name": "files_to_sessions_file_id_files_id_fk",+ "tableFrom": "files_to_sessions",+ "tableTo": "files",+ "columnsFrom": [+ "file_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "files_to_sessions_session_id_sessions_id_fk": {+ "name": "files_to_sessions_session_id_sessions_id_fk",+ "tableFrom": "files_to_sessions",+ "tableTo": "sessions",+ "columnsFrom": [+ "session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "files_to_sessions_user_id_users_id_fk": {+ "name": "files_to_sessions_user_id_users_id_fk",+ "tableFrom": "files_to_sessions",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "files_to_sessions_workspace_id_workspaces_id_fk": {+ "name": "files_to_sessions_workspace_id_workspaces_id_fk",+ "tableFrom": "files_to_sessions",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "files_to_sessions_file_id_session_id_pk": {+ "name": "files_to_sessions_file_id_session_id_pk",+ "columns": [+ "file_id",+ "session_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.resource_permissions": {+ "name": "resource_permissions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "resource_type": {+ "name": "resource_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "resource_id": {+ "name": "resource_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "access_level": {+ "name": "access_level",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_by": {+ "name": "created_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "resource_permissions_workspace_resource_unique": {+ "name": "resource_permissions_workspace_resource_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"resource_permissions\".\"user_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "resource_permissions_workspace_resource_user_id_unique": {+ "name": "resource_permissions_workspace_resource_user_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"resource_permissions\".\"user_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "resource_permissions_resource_idx": {+ "name": "resource_permissions_resource_idx",+ "columns": [+ {+ "expression": "resource_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "resource_permissions_workspace_idx": {+ "name": "resource_permissions_workspace_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "resource_permissions_workspace_user_idx": {+ "name": "resource_permissions_workspace_user_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "resource_permissions_workspace_id_workspaces_id_fk": {+ "name": "resource_permissions_workspace_id_workspaces_id_fk",+ "tableFrom": "resource_permissions",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "resource_permissions_user_id_users_id_fk": {+ "name": "resource_permissions_user_id_users_id_fk",+ "tableFrom": "resource_permissions",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "resource_permissions_created_by_users_id_fk": {+ "name": "resource_permissions_created_by_users_id_fk",+ "tableFrom": "resource_permissions",+ "tableTo": "users",+ "columnsFrom": [+ "created_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.resource_transfer_requests": {+ "name": "resource_transfer_requests",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "resource_type": {+ "name": "resource_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "resource_id": {+ "name": "resource_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "initiator_id": {+ "name": "initiator_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "recipient_id": {+ "name": "recipient_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "previous_owner_id": {+ "name": "previous_owner_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "options": {+ "name": "options",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "resolved_at": {+ "name": "resolved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "resource_transfer_requests_pending_resource_unique": {+ "name": "resource_transfer_requests_pending_resource_unique",+ "columns": [+ {+ "expression": "resource_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"resource_transfer_requests\".\"status\" = 'pending' AND \"resource_transfer_requests\".\"recipient_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "resource_transfer_requests_recipient_idx": {+ "name": "resource_transfer_requests_recipient_idx",+ "columns": [+ {+ "expression": "recipient_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "resource_transfer_requests_workspace_idx": {+ "name": "resource_transfer_requests_workspace_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "resource_transfer_requests_workspace_id_workspaces_id_fk": {+ "name": "resource_transfer_requests_workspace_id_workspaces_id_fk",+ "tableFrom": "resource_transfer_requests",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "resource_transfer_requests_initiator_id_users_id_fk": {+ "name": "resource_transfer_requests_initiator_id_users_id_fk",+ "tableFrom": "resource_transfer_requests",+ "tableTo": "users",+ "columnsFrom": [+ "initiator_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "resource_transfer_requests_recipient_id_users_id_fk": {+ "name": "resource_transfer_requests_recipient_id_users_id_fk",+ "tableFrom": "resource_transfer_requests",+ "tableTo": "users",+ "columnsFrom": [+ "recipient_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "resource_transfer_requests_previous_owner_id_users_id_fk": {+ "name": "resource_transfer_requests_previous_owner_id_users_id_fk",+ "tableFrom": "resource_transfer_requests",+ "tableTo": "users",+ "columnsFrom": [+ "previous_owner_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.session_groups": {+ "name": "session_groups",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "sort": {+ "name": "sort",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_deleted": {+ "name": "is_deleted",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "session_groups_client_id_user_id_unique": {+ "name": "session_groups_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "session_groups_user_id_idx": {+ "name": "session_groups_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "session_groups_workspace_id_idx": {+ "name": "session_groups_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "session_groups_workspace_visibility_idx": {+ "name": "session_groups_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "session_groups_user_id_users_id_fk": {+ "name": "session_groups_user_id_users_id_fk",+ "tableFrom": "session_groups",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "session_groups_workspace_id_workspaces_id_fk": {+ "name": "session_groups_workspace_id_workspaces_id_fk",+ "tableFrom": "session_groups",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.sessions": {+ "name": "sessions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "slug": {+ "name": "slug",+ "type": "varchar(100)",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "avatar": {+ "name": "avatar",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "background_color": {+ "name": "background_color",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "default": "'agent'"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "pinned": {+ "name": "pinned",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "slug_user_id_unique": {+ "name": "slug_user_id_unique",+ "columns": [+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"sessions\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "sessions_client_id_user_id_unique": {+ "name": "sessions_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "sessions_user_id_idx": {+ "name": "sessions_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "sessions_id_user_id_idx": {+ "name": "sessions_id_user_id_idx",+ "columns": [+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "sessions_user_id_updated_at_idx": {+ "name": "sessions_user_id_updated_at_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "sessions_group_id_idx": {+ "name": "sessions_group_id_idx",+ "columns": [+ {+ "expression": "group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "sessions_workspace_id_idx": {+ "name": "sessions_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "sessions_slug_workspace_id_unique": {+ "name": "sessions_slug_workspace_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"sessions\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "sessions_user_id_users_id_fk": {+ "name": "sessions_user_id_users_id_fk",+ "tableFrom": "sessions",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "sessions_group_id_session_groups_id_fk": {+ "name": "sessions_group_id_session_groups_id_fk",+ "tableFrom": "sessions",+ "tableTo": "session_groups",+ "columnsFrom": [+ "group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "sessions_workspace_id_workspaces_id_fk": {+ "name": "sessions_workspace_id_workspaces_id_fk",+ "tableFrom": "sessions",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.system_bot_providers": {+ "name": "system_bot_providers",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "platform": {+ "name": "platform",+ "type": "varchar(50)",+ "primaryKey": false,+ "notNull": true+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "credentials": {+ "name": "credentials",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "application_id": {+ "name": "application_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "settings": {+ "name": "settings",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "connection_mode": {+ "name": "connection_mode",+ "type": "varchar(20)",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "system_bot_providers_platform_unique": {+ "name": "system_bot_providers_platform_unique",+ "columns": [+ {+ "expression": "platform",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.briefs": {+ "name": "briefs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "task_id": {+ "name": "task_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "cron_job_id": {+ "name": "cron_job_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "priority": {+ "name": "priority",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "default": "'info'"+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "summary": {+ "name": "summary",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "artifacts": {+ "name": "artifacts",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "actions": {+ "name": "actions",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_action": {+ "name": "resolved_action",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_comment": {+ "name": "resolved_comment",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "read_at": {+ "name": "read_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_at": {+ "name": "resolved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "trigger": {+ "name": "trigger",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "briefs_user_id_idx": {+ "name": "briefs_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "briefs_task_id_idx": {+ "name": "briefs_task_id_idx",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "briefs_cron_job_id_idx": {+ "name": "briefs_cron_job_id_idx",+ "columns": [+ {+ "expression": "cron_job_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "briefs_agent_id_idx": {+ "name": "briefs_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "briefs_type_idx": {+ "name": "briefs_type_idx",+ "columns": [+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "briefs_priority_idx": {+ "name": "briefs_priority_idx",+ "columns": [+ {+ "expression": "priority",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "briefs_unresolved_idx": {+ "name": "briefs_unresolved_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resolved_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "briefs_trigger_idx": {+ "name": "briefs_trigger_idx",+ "columns": [+ {+ "expression": "trigger",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "briefs_workspace_id_idx": {+ "name": "briefs_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "briefs_user_id_users_id_fk": {+ "name": "briefs_user_id_users_id_fk",+ "tableFrom": "briefs",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "briefs_workspace_id_workspaces_id_fk": {+ "name": "briefs_workspace_id_workspaces_id_fk",+ "tableFrom": "briefs",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "briefs_task_id_tasks_id_fk": {+ "name": "briefs_task_id_tasks_id_fk",+ "tableFrom": "briefs",+ "tableTo": "tasks",+ "columnsFrom": [+ "task_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "briefs_cron_job_id_agent_cron_jobs_id_fk": {+ "name": "briefs_cron_job_id_agent_cron_jobs_id_fk",+ "tableFrom": "briefs",+ "tableTo": "agent_cron_jobs",+ "columnsFrom": [+ "cron_job_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.task_comments": {+ "name": "task_comments",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "task_id": {+ "name": "task_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "author_user_id": {+ "name": "author_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "author_agent_id": {+ "name": "author_agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "brief_id": {+ "name": "brief_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "task_comments_task_id_idx": {+ "name": "task_comments_task_id_idx",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_comments_user_id_idx": {+ "name": "task_comments_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_comments_author_user_id_idx": {+ "name": "task_comments_author_user_id_idx",+ "columns": [+ {+ "expression": "author_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_comments_agent_id_idx": {+ "name": "task_comments_agent_id_idx",+ "columns": [+ {+ "expression": "author_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_comments_brief_id_idx": {+ "name": "task_comments_brief_id_idx",+ "columns": [+ {+ "expression": "brief_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_comments_topic_id_idx": {+ "name": "task_comments_topic_id_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_comments_workspace_id_idx": {+ "name": "task_comments_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_comments_workspace_visibility_idx": {+ "name": "task_comments_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "task_comments_task_id_tasks_id_fk": {+ "name": "task_comments_task_id_tasks_id_fk",+ "tableFrom": "task_comments",+ "tableTo": "tasks",+ "columnsFrom": [+ "task_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_comments_user_id_users_id_fk": {+ "name": "task_comments_user_id_users_id_fk",+ "tableFrom": "task_comments",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_comments_workspace_id_workspaces_id_fk": {+ "name": "task_comments_workspace_id_workspaces_id_fk",+ "tableFrom": "task_comments",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_comments_author_user_id_users_id_fk": {+ "name": "task_comments_author_user_id_users_id_fk",+ "tableFrom": "task_comments",+ "tableTo": "users",+ "columnsFrom": [+ "author_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "task_comments_author_agent_id_agents_id_fk": {+ "name": "task_comments_author_agent_id_agents_id_fk",+ "tableFrom": "task_comments",+ "tableTo": "agents",+ "columnsFrom": [+ "author_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "task_comments_brief_id_briefs_id_fk": {+ "name": "task_comments_brief_id_briefs_id_fk",+ "tableFrom": "task_comments",+ "tableTo": "briefs",+ "columnsFrom": [+ "brief_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "task_comments_topic_id_topics_id_fk": {+ "name": "task_comments_topic_id_topics_id_fk",+ "tableFrom": "task_comments",+ "tableTo": "topics",+ "columnsFrom": [+ "topic_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.task_dependencies": {+ "name": "task_dependencies",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "task_id": {+ "name": "task_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "depends_on_id": {+ "name": "depends_on_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'blocks'"+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "condition": {+ "name": "condition",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "task_deps_unique_idx": {+ "name": "task_deps_unique_idx",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "depends_on_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_deps_task_id_idx": {+ "name": "task_deps_task_id_idx",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_deps_depends_on_id_idx": {+ "name": "task_deps_depends_on_id_idx",+ "columns": [+ {+ "expression": "depends_on_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_deps_user_id_idx": {+ "name": "task_deps_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_dependencies_workspace_id_idx": {+ "name": "task_dependencies_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_deps_workspace_visibility_idx": {+ "name": "task_deps_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "task_dependencies_task_id_tasks_id_fk": {+ "name": "task_dependencies_task_id_tasks_id_fk",+ "tableFrom": "task_dependencies",+ "tableTo": "tasks",+ "columnsFrom": [+ "task_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_dependencies_depends_on_id_tasks_id_fk": {+ "name": "task_dependencies_depends_on_id_tasks_id_fk",+ "tableFrom": "task_dependencies",+ "tableTo": "tasks",+ "columnsFrom": [+ "depends_on_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_dependencies_user_id_users_id_fk": {+ "name": "task_dependencies_user_id_users_id_fk",+ "tableFrom": "task_dependencies",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_dependencies_workspace_id_workspaces_id_fk": {+ "name": "task_dependencies_workspace_id_workspaces_id_fk",+ "tableFrom": "task_dependencies",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.task_documents": {+ "name": "task_documents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "task_id": {+ "name": "task_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "document_id": {+ "name": "document_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "pinned_by": {+ "name": "pinned_by",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'agent'"+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "task_docs_unique_idx": {+ "name": "task_docs_unique_idx",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_docs_task_id_idx": {+ "name": "task_docs_task_id_idx",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_docs_document_id_idx": {+ "name": "task_docs_document_id_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_docs_user_id_idx": {+ "name": "task_docs_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_documents_workspace_id_idx": {+ "name": "task_documents_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_docs_workspace_visibility_idx": {+ "name": "task_docs_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "task_documents_task_id_tasks_id_fk": {+ "name": "task_documents_task_id_tasks_id_fk",+ "tableFrom": "task_documents",+ "tableTo": "tasks",+ "columnsFrom": [+ "task_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_documents_document_id_documents_id_fk": {+ "name": "task_documents_document_id_documents_id_fk",+ "tableFrom": "task_documents",+ "tableTo": "documents",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_documents_user_id_users_id_fk": {+ "name": "task_documents_user_id_users_id_fk",+ "tableFrom": "task_documents",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_documents_workspace_id_workspaces_id_fk": {+ "name": "task_documents_workspace_id_workspaces_id_fk",+ "tableFrom": "task_documents",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.task_topics": {+ "name": "task_topics",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "task_id": {+ "name": "task_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "seq": {+ "name": "seq",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "operation_id": {+ "name": "operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'running'"+ },+ "trigger": {+ "name": "trigger",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "handoff": {+ "name": "handoff",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "review_passed": {+ "name": "review_passed",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "review_score": {+ "name": "review_score",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "review_scores": {+ "name": "review_scores",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "review_iteration": {+ "name": "review_iteration",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "reviewed_at": {+ "name": "reviewed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "task_topics_unique_idx": {+ "name": "task_topics_unique_idx",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_topics_task_id_idx": {+ "name": "task_topics_task_id_idx",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_topics_topic_id_idx": {+ "name": "task_topics_topic_id_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_topics_user_id_idx": {+ "name": "task_topics_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_topics_status_idx": {+ "name": "task_topics_status_idx",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_topics_workspace_id_idx": {+ "name": "task_topics_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_topics_workspace_visibility_idx": {+ "name": "task_topics_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "task_topics_task_id_tasks_id_fk": {+ "name": "task_topics_task_id_tasks_id_fk",+ "tableFrom": "task_topics",+ "tableTo": "tasks",+ "columnsFrom": [+ "task_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_topics_topic_id_topics_id_fk": {+ "name": "task_topics_topic_id_topics_id_fk",+ "tableFrom": "task_topics",+ "tableTo": "topics",+ "columnsFrom": [+ "topic_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_topics_user_id_users_id_fk": {+ "name": "task_topics_user_id_users_id_fk",+ "tableFrom": "task_topics",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_topics_workspace_id_workspaces_id_fk": {+ "name": "task_topics_workspace_id_workspaces_id_fk",+ "tableFrom": "task_topics",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.tasks": {+ "name": "tasks",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "seq": {+ "name": "seq",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "assignee_user_id": {+ "name": "assignee_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "assignee_agent_id": {+ "name": "assignee_agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "parent_task_id": {+ "name": "parent_task_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "instruction": {+ "name": "instruction",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'backlog'"+ },+ "priority": {+ "name": "priority",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "sort_order": {+ "name": "sort_order",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "automation_mode": {+ "name": "automation_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "heartbeat_interval": {+ "name": "heartbeat_interval",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "heartbeat_timeout": {+ "name": "heartbeat_timeout",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "last_heartbeat_at": {+ "name": "last_heartbeat_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "schedule_pattern": {+ "name": "schedule_pattern",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "schedule_timezone": {+ "name": "schedule_timezone",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "default": "'UTC'"+ },+ "total_topics": {+ "name": "total_topics",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "max_topics": {+ "name": "max_topics",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "current_topic_id": {+ "name": "current_topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "context": {+ "name": "context",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "error": {+ "name": "error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_deleted": {+ "name": "is_deleted",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "tasks_identifier_idx": {+ "name": "tasks_identifier_idx",+ "columns": [+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_by_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"tasks\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_created_by_user_id_idx": {+ "name": "tasks_created_by_user_id_idx",+ "columns": [+ {+ "expression": "created_by_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_created_by_agent_id_idx": {+ "name": "tasks_created_by_agent_id_idx",+ "columns": [+ {+ "expression": "created_by_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_assignee_user_id_idx": {+ "name": "tasks_assignee_user_id_idx",+ "columns": [+ {+ "expression": "assignee_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_assignee_agent_id_idx": {+ "name": "tasks_assignee_agent_id_idx",+ "columns": [+ {+ "expression": "assignee_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_parent_task_id_idx": {+ "name": "tasks_parent_task_id_idx",+ "columns": [+ {+ "expression": "parent_task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_status_idx": {+ "name": "tasks_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_priority_idx": {+ "name": "tasks_priority_idx",+ "columns": [+ {+ "expression": "priority",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_automation_mode_idx": {+ "name": "tasks_automation_mode_idx",+ "columns": [+ {+ "expression": "automation_mode",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_heartbeat_idx": {+ "name": "tasks_heartbeat_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "last_heartbeat_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_workspace_id_idx": {+ "name": "tasks_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_project_id_status_idx": {+ "name": "tasks_project_id_status_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_workspace_visibility_idx": {+ "name": "tasks_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_by_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_identifier_workspace_id_unique": {+ "name": "tasks_identifier_workspace_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"tasks\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tasks_created_by_user_id_users_id_fk": {+ "name": "tasks_created_by_user_id_users_id_fk",+ "tableFrom": "tasks",+ "tableTo": "users",+ "columnsFrom": [+ "created_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tasks_workspace_id_workspaces_id_fk": {+ "name": "tasks_workspace_id_workspaces_id_fk",+ "tableFrom": "tasks",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tasks_project_id_projects_id_fk": {+ "name": "tasks_project_id_projects_id_fk",+ "tableFrom": "tasks",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tasks_created_by_agent_id_agents_id_fk": {+ "name": "tasks_created_by_agent_id_agents_id_fk",+ "tableFrom": "tasks",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tasks_assignee_user_id_users_id_fk": {+ "name": "tasks_assignee_user_id_users_id_fk",+ "tableFrom": "tasks",+ "tableTo": "users",+ "columnsFrom": [+ "assignee_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tasks_assignee_agent_id_agents_id_fk": {+ "name": "tasks_assignee_agent_id_agents_id_fk",+ "tableFrom": "tasks",+ "tableTo": "agents",+ "columnsFrom": [+ "assignee_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tasks_current_topic_id_topics_id_fk": {+ "name": "tasks_current_topic_id_topics_id_fk",+ "tableFrom": "tasks",+ "tableTo": "topics",+ "columnsFrom": [+ "current_topic_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tasks_parent_task_id_tasks_id_fk": {+ "name": "tasks_parent_task_id_tasks_id_fk",+ "tableFrom": "tasks",+ "tableTo": "tasks",+ "columnsFrom": [+ "parent_task_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.threads": {+ "name": "threads",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_message_id": {+ "name": "source_message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "parent_thread_id": {+ "name": "parent_thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "last_active_at": {+ "name": "last_active_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false,+ "default": "now()"+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_deleted": {+ "name": "is_deleted",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "threads_client_id_user_id_unique": {+ "name": "threads_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "threads_user_id_idx": {+ "name": "threads_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "threads_topic_id_idx": {+ "name": "threads_topic_id_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "threads_type_idx": {+ "name": "threads_type_idx",+ "columns": [+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "threads_agent_id_idx": {+ "name": "threads_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "threads_group_id_idx": {+ "name": "threads_group_id_idx",+ "columns": [+ {+ "expression": "group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "threads_parent_thread_id_idx": {+ "name": "threads_parent_thread_id_idx",+ "columns": [+ {+ "expression": "parent_thread_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "threads_workspace_id_idx": {+ "name": "threads_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "threads_topic_id_topics_id_fk": {+ "name": "threads_topic_id_topics_id_fk",+ "tableFrom": "threads",+ "tableTo": "topics",+ "columnsFrom": [+ "topic_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "threads_parent_thread_id_threads_id_fk": {+ "name": "threads_parent_thread_id_threads_id_fk",+ "tableFrom": "threads",+ "tableTo": "threads",+ "columnsFrom": [+ "parent_thread_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "threads_agent_id_agents_id_fk": {+ "name": "threads_agent_id_agents_id_fk",+ "tableFrom": "threads",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "threads_group_id_chat_groups_id_fk": {+ "name": "threads_group_id_chat_groups_id_fk",+ "tableFrom": "threads",+ "tableTo": "chat_groups",+ "columnsFrom": [+ "group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "threads_user_id_users_id_fk": {+ "name": "threads_user_id_users_id_fk",+ "tableFrom": "threads",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "threads_workspace_id_workspaces_id_fk": {+ "name": "threads_workspace_id_workspaces_id_fk",+ "tableFrom": "threads",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.topic_documents": {+ "name": "topic_documents",+ "schema": "",+ "columns": {+ "document_id": {+ "name": "document_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "topic_documents_user_id_idx": {+ "name": "topic_documents_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_documents_topic_id_idx": {+ "name": "topic_documents_topic_id_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_documents_document_id_idx": {+ "name": "topic_documents_document_id_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_documents_workspace_id_idx": {+ "name": "topic_documents_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "topic_documents_document_id_documents_id_fk": {+ "name": "topic_documents_document_id_documents_id_fk",+ "tableFrom": "topic_documents",+ "tableTo": "documents",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topic_documents_topic_id_topics_id_fk": {+ "name": "topic_documents_topic_id_topics_id_fk",+ "tableFrom": "topic_documents",+ "tableTo": "topics",+ "columnsFrom": [+ "topic_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topic_documents_user_id_users_id_fk": {+ "name": "topic_documents_user_id_users_id_fk",+ "tableFrom": "topic_documents",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topic_documents_workspace_id_workspaces_id_fk": {+ "name": "topic_documents_workspace_id_workspaces_id_fk",+ "tableFrom": "topic_documents",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "topic_documents_document_id_topic_id_pk": {+ "name": "topic_documents_document_id_topic_id_pk",+ "columns": [+ "document_id",+ "topic_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.topic_shares": {+ "name": "topic_shares",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'private'"+ },+ "page_view_count": {+ "name": "page_view_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "topic_shares_topic_id_unique": {+ "name": "topic_shares_topic_id_unique",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_shares_user_id_idx": {+ "name": "topic_shares_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_shares_workspace_id_idx": {+ "name": "topic_shares_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "topic_shares_topic_id_topics_id_fk": {+ "name": "topic_shares_topic_id_topics_id_fk",+ "tableFrom": "topic_shares",+ "tableTo": "topics",+ "columnsFrom": [+ "topic_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topic_shares_user_id_users_id_fk": {+ "name": "topic_shares_user_id_users_id_fk",+ "tableFrom": "topic_shares",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topic_shares_workspace_id_workspaces_id_fk": {+ "name": "topic_shares_workspace_id_workspaces_id_fk",+ "tableFrom": "topic_shares",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.topics": {+ "name": "topics",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "favorite": {+ "name": "favorite",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "history_summary": {+ "name": "history_summary",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "trigger": {+ "name": "trigger",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "mode": {+ "name": "mode",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "total_cost": {+ "name": "total_cost",+ "type": "numeric(20, 6)",+ "primaryKey": false,+ "notNull": false+ },+ "total_input_tokens": {+ "name": "total_input_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "total_output_tokens": {+ "name": "total_output_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "total_tokens": {+ "name": "total_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "cost": {+ "name": "cost",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "usage": {+ "name": "usage",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "sender_id": {+ "name": "sender_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_deleted": {+ "name": "is_deleted",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "topics_client_id_user_id_unique": {+ "name": "topics_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_created_at_idx": {+ "name": "topics_created_at_idx",+ "columns": [+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_user_id_idx": {+ "name": "topics_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_id_user_id_idx": {+ "name": "topics_id_user_id_idx",+ "columns": [+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_session_id_idx": {+ "name": "topics_session_id_idx",+ "columns": [+ {+ "expression": "session_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_group_id_idx": {+ "name": "topics_group_id_idx",+ "columns": [+ {+ "expression": "group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_agent_id_idx": {+ "name": "topics_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_trigger_idx": {+ "name": "topics_trigger_idx",+ "columns": [+ {+ "expression": "trigger",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_status_idx": {+ "name": "topics_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_model_idx": {+ "name": "topics_model_idx",+ "columns": [+ {+ "expression": "model",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_provider_idx": {+ "name": "topics_provider_idx",+ "columns": [+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_user_id_completed_at_idx": {+ "name": "topics_user_id_completed_at_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "completed_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_sender_id_idx": {+ "name": "topics_sender_id_idx",+ "columns": [+ {+ "expression": "sender_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_workspace_id_idx": {+ "name": "topics_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_extract_status_gin_idx": {+ "name": "topics_extract_status_gin_idx",+ "columns": [+ {+ "expression": "(metadata->'userMemoryExtractStatus') jsonb_path_ops",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "gin",+ "with": {}+ }+ },+ "foreignKeys": {+ "topics_session_id_sessions_id_fk": {+ "name": "topics_session_id_sessions_id_fk",+ "tableFrom": "topics",+ "tableTo": "sessions",+ "columnsFrom": [+ "session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topics_agent_id_agents_id_fk": {+ "name": "topics_agent_id_agents_id_fk",+ "tableFrom": "topics",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topics_group_id_chat_groups_id_fk": {+ "name": "topics_group_id_chat_groups_id_fk",+ "tableFrom": "topics",+ "tableTo": "chat_groups",+ "columnsFrom": [+ "group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topics_user_id_users_id_fk": {+ "name": "topics_user_id_users_id_fk",+ "tableFrom": "topics",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topics_workspace_id_workspaces_id_fk": {+ "name": "topics_workspace_id_workspaces_id_fk",+ "tableFrom": "topics",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.topic_comment_mentions": {+ "name": "topic_comment_mentions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "comment_id": {+ "name": "comment_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "mentioned_user_id": {+ "name": "mentioned_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "topic_comment_mentions_comment_id_mentioned_user_id_unique": {+ "name": "topic_comment_mentions_comment_id_mentioned_user_id_unique",+ "columns": [+ {+ "expression": "comment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "mentioned_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_comment_mentions_mentioned_user_id_created_at_idx": {+ "name": "topic_comment_mentions_mentioned_user_id_created_at_idx",+ "columns": [+ {+ "expression": "mentioned_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_comment_mentions_workspace_id_idx": {+ "name": "topic_comment_mentions_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "topic_comment_mentions_comment_id_topic_comments_id_fk": {+ "name": "topic_comment_mentions_comment_id_topic_comments_id_fk",+ "tableFrom": "topic_comment_mentions",+ "tableTo": "topic_comments",+ "columnsFrom": [+ "comment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topic_comment_mentions_mentioned_user_id_users_id_fk": {+ "name": "topic_comment_mentions_mentioned_user_id_users_id_fk",+ "tableFrom": "topic_comment_mentions",+ "tableTo": "users",+ "columnsFrom": [+ "mentioned_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topic_comment_mentions_workspace_id_workspaces_id_fk": {+ "name": "topic_comment_mentions_workspace_id_workspaces_id_fk",+ "tableFrom": "topic_comment_mentions",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.topic_comments": {+ "name": "topic_comments",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "message_id": {+ "name": "message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "parent_comment_id": {+ "name": "parent_comment_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "author_user_id": {+ "name": "author_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "anchor_preview": {+ "name": "anchor_preview",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "moderated_at": {+ "name": "moderated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "moderated_by_user_id": {+ "name": "moderated_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "moderation_expires_at": {+ "name": "moderation_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "topic_comments_topic_id_author_user_id_client_id_unique": {+ "name": "topic_comments_topic_id_author_user_id_client_id_unique",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "author_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_comments_parent_comment_id_created_at_id_idx": {+ "name": "topic_comments_parent_comment_id_created_at_id_idx",+ "columns": [+ {+ "expression": "parent_comment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_comments_topic_id_created_at_id_idx": {+ "name": "topic_comments_topic_id_created_at_id_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_comments_topic_id_message_id_idx": {+ "name": "topic_comments_topic_id_message_id_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_comments_message_id_idx": {+ "name": "topic_comments_message_id_idx",+ "columns": [+ {+ "expression": "message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_comments_author_user_id_idx": {+ "name": "topic_comments_author_user_id_idx",+ "columns": [+ {+ "expression": "author_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_comments_moderation_expires_at_idx": {+ "name": "topic_comments_moderation_expires_at_idx",+ "columns": [+ {+ "expression": "moderation_expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_comments_moderated_by_user_id_idx": {+ "name": "topic_comments_moderated_by_user_id_idx",+ "columns": [+ {+ "expression": "moderated_by_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_comments_workspace_id_idx": {+ "name": "topic_comments_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "topic_comments_topic_id_topics_id_fk": {+ "name": "topic_comments_topic_id_topics_id_fk",+ "tableFrom": "topic_comments",+ "tableTo": "topics",+ "columnsFrom": [+ "topic_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topic_comments_message_id_messages_id_fk": {+ "name": "topic_comments_message_id_messages_id_fk",+ "tableFrom": "topic_comments",+ "tableTo": "messages",+ "columnsFrom": [+ "message_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "topic_comments_parent_comment_id_topic_comments_id_fk": {+ "name": "topic_comments_parent_comment_id_topic_comments_id_fk",+ "tableFrom": "topic_comments",+ "tableTo": "topic_comments",+ "columnsFrom": [+ "parent_comment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "topic_comments_author_user_id_users_id_fk": {+ "name": "topic_comments_author_user_id_users_id_fk",+ "tableFrom": "topic_comments",+ "tableTo": "users",+ "columnsFrom": [+ "author_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "topic_comments_workspace_id_workspaces_id_fk": {+ "name": "topic_comments_workspace_id_workspaces_id_fk",+ "tableFrom": "topic_comments",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topic_comments_moderated_by_user_id_users_id_fk": {+ "name": "topic_comments_moderated_by_user_id_users_id_fk",+ "tableFrom": "topic_comments",+ "tableTo": "users",+ "columnsFrom": [+ "moderated_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "topic_comments_anchored_requires_preview": {+ "name": "topic_comments_anchored_requires_preview",+ "value": "\"topic_comments\".\"message_id\" IS NULL OR \"topic_comments\".\"anchor_preview\" IS NOT NULL"+ },+ "topic_comments_reply_has_no_anchor": {+ "name": "topic_comments_reply_has_no_anchor",+ "value": "\"topic_comments\".\"parent_comment_id\" IS NULL OR (\"topic_comments\".\"message_id\" IS NULL AND \"topic_comments\".\"anchor_preview\" IS NULL)"+ },+ "topic_comments_moderation_window_consistent": {+ "name": "topic_comments_moderation_window_consistent",+ "value": "(\"topic_comments\".\"moderated_at\" IS NULL) = (\"topic_comments\".\"moderation_expires_at\" IS NULL)"+ },+ "topic_comments_deleted_not_recoverable": {+ "name": "topic_comments_deleted_not_recoverable",+ "value": "\"topic_comments\".\"deleted_at\" IS NULL OR \"topic_comments\".\"moderated_at\" IS NULL"+ }+ },+ "isRLSEnabled": false+ },+ "public.trash_items": {+ "name": "trash_items",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "resource_type": {+ "name": "resource_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "resource_id": {+ "name": "resource_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "meta": {+ "name": "meta",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "root_id": {+ "name": "root_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_by_user_id": {+ "name": "deleted_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "trash_items_resource_unique": {+ "name": "trash_items_resource_unique",+ "columns": [+ {+ "expression": "resource_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "trash_items_personal_listing_idx": {+ "name": "trash_items_personal_listing_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "deleted_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"trash_items\".\"root_id\" IS NULL AND \"trash_items\".\"workspace_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "trash_items_workspace_listing_idx": {+ "name": "trash_items_workspace_listing_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "deleted_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"trash_items\".\"root_id\" IS NULL AND \"trash_items\".\"workspace_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "trash_items_expires_at_idx": {+ "name": "trash_items_expires_at_idx",+ "columns": [+ {+ "expression": "expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"trash_items\".\"root_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "trash_items_root_id_idx": {+ "name": "trash_items_root_id_idx",+ "columns": [+ {+ "expression": "root_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "trash_items_root_id_trash_items_id_fk": {+ "name": "trash_items_root_id_trash_items_id_fk",+ "tableFrom": "trash_items",+ "tableTo": "trash_items",+ "columnsFrom": [+ "root_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "trash_items_user_id_users_id_fk": {+ "name": "trash_items_user_id_users_id_fk",+ "tableFrom": "trash_items",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "trash_items_workspace_id_workspaces_id_fk": {+ "name": "trash_items_workspace_id_workspaces_id_fk",+ "tableFrom": "trash_items",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "trash_items_deleted_by_user_id_users_id_fk": {+ "name": "trash_items_deleted_by_user_id_users_id_fk",+ "tableFrom": "trash_items",+ "tableTo": "users",+ "columnsFrom": [+ "deleted_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_settings": {+ "name": "user_settings",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "tts": {+ "name": "tts",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "hotkey": {+ "name": "hotkey",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "key_vaults": {+ "name": "key_vaults",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "general": {+ "name": "general",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "language_model": {+ "name": "language_model",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "system_agent": {+ "name": "system_agent",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "default_agent": {+ "name": "default_agent",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "market": {+ "name": "market",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "memory": {+ "name": "memory",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "tool": {+ "name": "tool",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "image": {+ "name": "image",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "notification": {+ "name": "notification",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "user_settings_id_users_id_fk": {+ "name": "user_settings_id_users_id_fk",+ "tableFrom": "user_settings",+ "tableTo": "users",+ "columnsFrom": [+ "id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.users": {+ "name": "users",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "username": {+ "name": "username",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "normalized_email": {+ "name": "normalized_email",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "avatar": {+ "name": "avatar",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "phone": {+ "name": "phone",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "first_name": {+ "name": "first_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "last_name": {+ "name": "last_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "full_name": {+ "name": "full_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "interests": {+ "name": "interests",+ "type": "varchar(64)[]",+ "primaryKey": false,+ "notNull": false+ },+ "is_onboarded": {+ "name": "is_onboarded",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "agent_onboarding": {+ "name": "agent_onboarding",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "onboarding": {+ "name": "onboarding",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "clerk_created_at": {+ "name": "clerk_created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "email_verified": {+ "name": "email_verified",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "email_verified_at": {+ "name": "email_verified_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "preference": {+ "name": "preference",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "banned": {+ "name": "banned",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "ban_reason": {+ "name": "ban_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "ban_expires": {+ "name": "ban_expires",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "two_factor_enabled": {+ "name": "two_factor_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "phone_number_verified": {+ "name": "phone_number_verified",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "last_active_at": {+ "name": "last_active_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "users_email_idx": {+ "name": "users_email_idx",+ "columns": [+ {+ "expression": "email",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "users_username_idx": {+ "name": "users_username_idx",+ "columns": [+ {+ "expression": "username",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "users_created_at_idx": {+ "name": "users_created_at_idx",+ "columns": [+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "users_banned_true_created_at_idx": {+ "name": "users_banned_true_created_at_idx",+ "columns": [+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"users\".\"banned\" = true",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "users_username_unique": {+ "name": "users_username_unique",+ "nullsNotDistinct": false,+ "columns": [+ "username"+ ]+ },+ "users_email_unique": {+ "name": "users_email_unique",+ "nullsNotDistinct": false,+ "columns": [+ "email"+ ]+ },+ "users_normalized_email_unique": {+ "name": "users_normalized_email_unique",+ "nullsNotDistinct": false,+ "columns": [+ "normalized_email"+ ]+ },+ "users_phone_unique": {+ "name": "users_phone_unique",+ "nullsNotDistinct": false,+ "columns": [+ "phone"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_memories": {+ "name": "user_memories",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "memory_category": {+ "name": "memory_category",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "memory_layer": {+ "name": "memory_layer",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "memory_type": {+ "name": "memory_type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "tags": {+ "name": "tags",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "summary": {+ "name": "summary",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "summary_vector_1024": {+ "name": "summary_vector_1024",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "details": {+ "name": "details",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "details_vector_1024": {+ "name": "details_vector_1024",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_count": {+ "name": "accessed_count",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "last_accessed_at": {+ "name": "last_accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_deleted": {+ "name": "is_deleted",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_memories_summary_vector_1024_index": {+ "name": "user_memories_summary_vector_1024_index",+ "columns": [+ {+ "expression": "summary_vector_1024",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "vector_cosine_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "hnsw",+ "with": {}+ },+ "user_memories_details_vector_1024_index": {+ "name": "user_memories_details_vector_1024_index",+ "columns": [+ {+ "expression": "details_vector_1024",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "vector_cosine_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "hnsw",+ "with": {}+ },+ "user_memories_user_id_index": {+ "name": "user_memories_user_id_index",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_memories_user_id_users_id_fk": {+ "name": "user_memories_user_id_users_id_fk",+ "tableFrom": "user_memories",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_memories_activities": {+ "name": "user_memories_activities",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_memory_id": {+ "name": "user_memory_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "tags": {+ "name": "tags",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "timezone": {+ "name": "timezone",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "starts_at": {+ "name": "starts_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "ends_at": {+ "name": "ends_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "associated_objects": {+ "name": "associated_objects",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "associated_subjects": {+ "name": "associated_subjects",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "associated_locations": {+ "name": "associated_locations",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "notes": {+ "name": "notes",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "narrative": {+ "name": "narrative",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "narrative_vector": {+ "name": "narrative_vector",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "feedback": {+ "name": "feedback",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "feedback_vector": {+ "name": "feedback_vector",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_memories_activities_narrative_vector_index": {+ "name": "user_memories_activities_narrative_vector_index",+ "columns": [+ {+ "expression": "narrative_vector",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "vector_cosine_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "hnsw",+ "with": {}+ },+ "user_memories_activities_feedback_vector_index": {+ "name": "user_memories_activities_feedback_vector_index",+ "columns": [+ {+ "expression": "feedback_vector",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "vector_cosine_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "hnsw",+ "with": {}+ },+ "user_memories_activities_type_index": {+ "name": "user_memories_activities_type_index",+ "columns": [+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_activities_user_id_index": {+ "name": "user_memories_activities_user_id_index",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_activities_user_memory_id_index": {+ "name": "user_memories_activities_user_memory_id_index",+ "columns": [+ {+ "expression": "user_memory_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_activities_status_index": {+ "name": "user_memories_activities_status_index",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_memories_activities_user_id_users_id_fk": {+ "name": "user_memories_activities_user_id_users_id_fk",+ "tableFrom": "user_memories_activities",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_activities_user_memory_id_user_memories_id_fk": {+ "name": "user_memories_activities_user_memory_id_user_memories_id_fk",+ "tableFrom": "user_memories_activities",+ "tableTo": "user_memories",+ "columnsFrom": [+ "user_memory_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_memories_contexts": {+ "name": "user_memories_contexts",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_memory_ids": {+ "name": "user_memory_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "tags": {+ "name": "tags",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "associated_objects": {+ "name": "associated_objects",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "associated_subjects": {+ "name": "associated_subjects",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description_vector": {+ "name": "description_vector",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "current_status": {+ "name": "current_status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "score_impact": {+ "name": "score_impact",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "score_urgency": {+ "name": "score_urgency",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_memories_contexts_description_vector_index": {+ "name": "user_memories_contexts_description_vector_index",+ "columns": [+ {+ "expression": "description_vector",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "vector_cosine_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "hnsw",+ "with": {}+ },+ "user_memories_contexts_type_index": {+ "name": "user_memories_contexts_type_index",+ "columns": [+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_contexts_user_id_index": {+ "name": "user_memories_contexts_user_id_index",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_contexts_user_memory_ids_gin_idx": {+ "name": "user_memories_contexts_user_memory_ids_gin_idx",+ "columns": [+ {+ "expression": "user_memory_ids",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "gin",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_memories_contexts_user_id_users_id_fk": {+ "name": "user_memories_contexts_user_id_users_id_fk",+ "tableFrom": "user_memories_contexts",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_memories_experiences": {+ "name": "user_memories_experiences",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_memory_id": {+ "name": "user_memory_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "tags": {+ "name": "tags",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "situation": {+ "name": "situation",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "situation_vector": {+ "name": "situation_vector",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "reasoning": {+ "name": "reasoning",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "possible_outcome": {+ "name": "possible_outcome",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "action": {+ "name": "action",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "action_vector": {+ "name": "action_vector",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "key_learning": {+ "name": "key_learning",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "key_learning_vector": {+ "name": "key_learning_vector",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "score_confidence": {+ "name": "score_confidence",+ "type": "real",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_memories_experiences_situation_vector_index": {+ "name": "user_memories_experiences_situation_vector_index",+ "columns": [+ {+ "expression": "situation_vector",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "vector_cosine_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "hnsw",+ "with": {}+ },+ "user_memories_experiences_action_vector_index": {+ "name": "user_memories_experiences_action_vector_index",+ "columns": [+ {+ "expression": "action_vector",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "vector_cosine_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "hnsw",+ "with": {}+ },+ "user_memories_experiences_key_learning_vector_index": {+ "name": "user_memories_experiences_key_learning_vector_index",+ "columns": [+ {+ "expression": "key_learning_vector",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "vector_cosine_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "hnsw",+ "with": {}+ },+ "user_memories_experiences_type_index": {+ "name": "user_memories_experiences_type_index",+ "columns": [+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_experiences_user_id_index": {+ "name": "user_memories_experiences_user_id_index",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_experiences_user_memory_id_index": {+ "name": "user_memories_experiences_user_memory_id_index",+ "columns": [+ {+ "expression": "user_memory_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_memories_experiences_user_id_users_id_fk": {+ "name": "user_memories_experiences_user_id_users_id_fk",+ "tableFrom": "user_memories_experiences",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_experiences_user_memory_id_user_memories_id_fk": {+ "name": "user_memories_experiences_user_memory_id_user_memories_id_fk",+ "tableFrom": "user_memories_experiences",+ "tableTo": "user_memories",+ "columnsFrom": [+ "user_memory_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_memories_identities": {+ "name": "user_memories_identities",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_memory_id": {+ "name": "user_memory_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "tags": {+ "name": "tags",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description_vector": {+ "name": "description_vector",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "episodic_date": {+ "name": "episodic_date",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "relationship": {+ "name": "relationship",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_memories_identities_description_vector_index": {+ "name": "user_memories_identities_description_vector_index",+ "columns": [+ {+ "expression": "description_vector",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "vector_cosine_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "hnsw",+ "with": {}+ },+ "user_memories_identities_type_index": {+ "name": "user_memories_identities_type_index",+ "columns": [+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_identities_user_id_index": {+ "name": "user_memories_identities_user_id_index",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_identities_user_memory_id_index": {+ "name": "user_memories_identities_user_memory_id_index",+ "columns": [+ {+ "expression": "user_memory_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_memories_identities_user_id_users_id_fk": {+ "name": "user_memories_identities_user_id_users_id_fk",+ "tableFrom": "user_memories_identities",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_identities_user_memory_id_user_memories_id_fk": {+ "name": "user_memories_identities_user_memory_id_user_memories_id_fk",+ "tableFrom": "user_memories_identities",+ "tableTo": "user_memories",+ "columnsFrom": [+ "user_memory_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_memories_preferences": {+ "name": "user_memories_preferences",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_memory_id": {+ "name": "user_memory_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "tags": {+ "name": "tags",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "conclusion_directives": {+ "name": "conclusion_directives",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "conclusion_directives_vector": {+ "name": "conclusion_directives_vector",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "suggestions": {+ "name": "suggestions",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "score_priority": {+ "name": "score_priority",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_memories_preferences_conclusion_directives_vector_index": {+ "name": "user_memories_preferences_conclusion_directives_vector_index",+ "columns": [+ {+ "expression": "conclusion_directives_vector",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "vector_cosine_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "hnsw",+ "with": {}+ },+ "user_memories_preferences_user_id_index": {+ "name": "user_memories_preferences_user_id_index",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_preferences_user_memory_id_index": {+ "name": "user_memories_preferences_user_memory_id_index",+ "columns": [+ {+ "expression": "user_memory_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_memories_preferences_user_id_users_id_fk": {+ "name": "user_memories_preferences_user_id_users_id_fk",+ "tableFrom": "user_memories_preferences",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_preferences_user_memory_id_user_memories_id_fk": {+ "name": "user_memories_preferences_user_memory_id_user_memories_id_fk",+ "tableFrom": "user_memories_preferences",+ "tableTo": "user_memories",+ "columnsFrom": [+ "user_memory_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_memory_persona_document_histories": {+ "name": "user_memory_persona_document_histories",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "persona_id": {+ "name": "persona_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "profile": {+ "name": "profile",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "default": "'default'"+ },+ "snapshot_persona": {+ "name": "snapshot_persona",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "snapshot_tagline": {+ "name": "snapshot_tagline",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "reasoning": {+ "name": "reasoning",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "diff_persona": {+ "name": "diff_persona",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "diff_tagline": {+ "name": "diff_tagline",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "snapshot": {+ "name": "snapshot",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "summary": {+ "name": "summary",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "edited_by": {+ "name": "edited_by",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "default": "'agent'"+ },+ "memory_ids": {+ "name": "memory_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "source_ids": {+ "name": "source_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "previous_version": {+ "name": "previous_version",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "next_version": {+ "name": "next_version",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_persona_document_histories_persona_id_index": {+ "name": "user_persona_document_histories_persona_id_index",+ "columns": [+ {+ "expression": "persona_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_persona_document_histories_user_id_index": {+ "name": "user_persona_document_histories_user_id_index",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_persona_document_histories_profile_index": {+ "name": "user_persona_document_histories_profile_index",+ "columns": [+ {+ "expression": "profile",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_memory_persona_document_histories_user_id_users_id_fk": {+ "name": "user_memory_persona_document_histories_user_id_users_id_fk",+ "tableFrom": "user_memory_persona_document_histories",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memory_persona_document_histories_persona_id_user_memory_persona_documents_id_fk": {+ "name": "user_memory_persona_document_histories_persona_id_user_memory_persona_documents_id_fk",+ "tableFrom": "user_memory_persona_document_histories",+ "tableTo": "user_memory_persona_documents",+ "columnsFrom": [+ "persona_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_memory_persona_documents": {+ "name": "user_memory_persona_documents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "profile": {+ "name": "profile",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "default": "'default'"+ },+ "tagline": {+ "name": "tagline",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "persona": {+ "name": "persona",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "memory_ids": {+ "name": "memory_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "source_ids": {+ "name": "source_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_persona_documents_user_id_profile_unique": {+ "name": "user_persona_documents_user_id_profile_unique",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "profile",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_persona_documents_user_id_index": {+ "name": "user_persona_documents_user_id_index",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_memory_persona_documents_user_id_users_id_fk": {+ "name": "user_memory_persona_documents_user_id_users_id_fk",+ "tableFrom": "user_memory_persona_documents",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.acceptances": {+ "name": "acceptances",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "subject_type": {+ "name": "subject_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "subject_id": {+ "name": "subject_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "requirement": {+ "name": "requirement",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "visual_render": {+ "name": "visual_render",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "acceptances_user_id_idx": {+ "name": "acceptances_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "acceptances_workspace_id_idx": {+ "name": "acceptances_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "acceptances_project_id_idx": {+ "name": "acceptances_project_id_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "acceptances_subject_idx": {+ "name": "acceptances_subject_idx",+ "columns": [+ {+ "expression": "subject_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "acceptances_status_idx": {+ "name": "acceptances_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "acceptances_workspace_visibility_idx": {+ "name": "acceptances_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "acceptances_personal_subject_unique": {+ "name": "acceptances_personal_subject_unique",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"acceptances\".\"workspace_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "acceptances_workspace_subject_unique": {+ "name": "acceptances_workspace_subject_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"acceptances\".\"workspace_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "acceptances_user_id_users_id_fk": {+ "name": "acceptances_user_id_users_id_fk",+ "tableFrom": "acceptances",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "acceptances_workspace_id_workspaces_id_fk": {+ "name": "acceptances_workspace_id_workspaces_id_fk",+ "tableFrom": "acceptances",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "acceptances_project_id_projects_id_fk": {+ "name": "acceptances_project_id_projects_id_fk",+ "tableFrom": "acceptances",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.verify_check_results": {+ "name": "verify_check_results",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "verify_run_id": {+ "name": "verify_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "operation_id": {+ "name": "operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "check_item_id": {+ "name": "check_item_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "check_item_title": {+ "name": "check_item_title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "required": {+ "name": "required",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "check_item_index": {+ "name": "check_item_index",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "verifier_type": {+ "name": "verifier_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "verifier_config_hash": {+ "name": "verifier_config_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "verifier_operation_id": {+ "name": "verifier_operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "verifier_tracing_id": {+ "name": "verifier_tracing_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "verdict": {+ "name": "verdict",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "confidence": {+ "name": "confidence",+ "type": "numeric(3, 2)",+ "primaryKey": false,+ "notNull": false+ },+ "toulmin": {+ "name": "toulmin",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "suggestion": {+ "name": "suggestion",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_decision": {+ "name": "user_decision",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_decision_detail": {+ "name": "user_decision_detail",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "is_false_positive": {+ "name": "is_false_positive",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "is_false_negative": {+ "name": "is_false_negative",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "repair_operation_id": {+ "name": "repair_operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "verify_check_results_verify_run_id_idx": {+ "name": "verify_check_results_verify_run_id_idx",+ "columns": [+ {+ "expression": "verify_run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_check_results_operation_id_idx": {+ "name": "verify_check_results_operation_id_idx",+ "columns": [+ {+ "expression": "operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_check_results_user_id_idx": {+ "name": "verify_check_results_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_check_results_verify_run_id_check_item_id_unique": {+ "name": "verify_check_results_verify_run_id_check_item_id_unique",+ "columns": [+ {+ "expression": "verify_run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "check_item_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_check_results_verifier_type_idx": {+ "name": "verify_check_results_verifier_type_idx",+ "columns": [+ {+ "expression": "verifier_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_check_results_verifier_operation_id_idx": {+ "name": "verify_check_results_verifier_operation_id_idx",+ "columns": [+ {+ "expression": "verifier_operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_check_results_verifier_tracing_id_idx": {+ "name": "verify_check_results_verifier_tracing_id_idx",+ "columns": [+ {+ "expression": "verifier_tracing_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_check_results_status_idx": {+ "name": "verify_check_results_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_check_results_verdict_idx": {+ "name": "verify_check_results_verdict_idx",+ "columns": [+ {+ "expression": "verdict",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_check_results_repair_operation_id_idx": {+ "name": "verify_check_results_repair_operation_id_idx",+ "columns": [+ {+ "expression": "repair_operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_check_results_workspace_id_idx": {+ "name": "verify_check_results_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "verify_check_results_verify_run_id_verify_runs_id_fk": {+ "name": "verify_check_results_verify_run_id_verify_runs_id_fk",+ "tableFrom": "verify_check_results",+ "tableTo": "verify_runs",+ "columnsFrom": [+ "verify_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_check_results_operation_id_agent_operations_id_fk": {+ "name": "verify_check_results_operation_id_agent_operations_id_fk",+ "tableFrom": "verify_check_results",+ "tableTo": "agent_operations",+ "columnsFrom": [+ "operation_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "verify_check_results_user_id_users_id_fk": {+ "name": "verify_check_results_user_id_users_id_fk",+ "tableFrom": "verify_check_results",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_check_results_workspace_id_workspaces_id_fk": {+ "name": "verify_check_results_workspace_id_workspaces_id_fk",+ "tableFrom": "verify_check_results",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_check_results_verifier_operation_id_agent_operations_id_fk": {+ "name": "verify_check_results_verifier_operation_id_agent_operations_id_fk",+ "tableFrom": "verify_check_results",+ "tableTo": "agent_operations",+ "columnsFrom": [+ "verifier_operation_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "verify_check_results_verifier_tracing_id_llm_generation_tracing_id_fk": {+ "name": "verify_check_results_verifier_tracing_id_llm_generation_tracing_id_fk",+ "tableFrom": "verify_check_results",+ "tableTo": "llm_generation_tracing",+ "columnsFrom": [+ "verifier_tracing_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "verify_check_results_repair_operation_id_agent_operations_id_fk": {+ "name": "verify_check_results_repair_operation_id_agent_operations_id_fk",+ "tableFrom": "verify_check_results",+ "tableTo": "agent_operations",+ "columnsFrom": [+ "repair_operation_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.verify_criteria": {+ "name": "verify_criteria",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "required": {+ "name": "required",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "verifier_type": {+ "name": "verifier_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "verifier_config": {+ "name": "verifier_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "on_fail": {+ "name": "on_fail",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'manual'"+ },+ "document_id": {+ "name": "document_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "verify_criteria_user_id_idx": {+ "name": "verify_criteria_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_criteria_verifier_type_idx": {+ "name": "verify_criteria_verifier_type_idx",+ "columns": [+ {+ "expression": "verifier_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_criteria_document_id_idx": {+ "name": "verify_criteria_document_id_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_criteria_workspace_id_idx": {+ "name": "verify_criteria_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "verify_criteria_user_id_users_id_fk": {+ "name": "verify_criteria_user_id_users_id_fk",+ "tableFrom": "verify_criteria",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_criteria_document_id_documents_id_fk": {+ "name": "verify_criteria_document_id_documents_id_fk",+ "tableFrom": "verify_criteria",+ "tableTo": "documents",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "verify_criteria_workspace_id_workspaces_id_fk": {+ "name": "verify_criteria_workspace_id_workspaces_id_fk",+ "tableFrom": "verify_criteria",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.verify_evidence": {+ "name": "verify_evidence",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "check_result_id": {+ "name": "check_result_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "document_id": {+ "name": "document_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "file_id": {+ "name": "file_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "captured_by": {+ "name": "captured_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "verify_evidence_check_result_id_idx": {+ "name": "verify_evidence_check_result_id_idx",+ "columns": [+ {+ "expression": "check_result_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_evidence_document_id_idx": {+ "name": "verify_evidence_document_id_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_evidence_file_id_idx": {+ "name": "verify_evidence_file_id_idx",+ "columns": [+ {+ "expression": "file_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_evidence_user_id_idx": {+ "name": "verify_evidence_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_evidence_workspace_id_idx": {+ "name": "verify_evidence_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "verify_evidence_check_result_id_verify_check_results_id_fk": {+ "name": "verify_evidence_check_result_id_verify_check_results_id_fk",+ "tableFrom": "verify_evidence",+ "tableTo": "verify_check_results",+ "columnsFrom": [+ "check_result_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_evidence_document_id_documents_id_fk": {+ "name": "verify_evidence_document_id_documents_id_fk",+ "tableFrom": "verify_evidence",+ "tableTo": "documents",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "verify_evidence_file_id_files_id_fk": {+ "name": "verify_evidence_file_id_files_id_fk",+ "tableFrom": "verify_evidence",+ "tableTo": "files",+ "columnsFrom": [+ "file_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "verify_evidence_user_id_users_id_fk": {+ "name": "verify_evidence_user_id_users_id_fk",+ "tableFrom": "verify_evidence",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_evidence_workspace_id_workspaces_id_fk": {+ "name": "verify_evidence_workspace_id_workspaces_id_fk",+ "tableFrom": "verify_evidence",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.verify_reports": {+ "name": "verify_reports",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "verify_run_id": {+ "name": "verify_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "operation_id": {+ "name": "operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "verdict": {+ "name": "verdict",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "overall_confidence": {+ "name": "overall_confidence",+ "type": "numeric(3, 2)",+ "primaryKey": false,+ "notNull": false+ },+ "total_checks": {+ "name": "total_checks",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "passed_checks": {+ "name": "passed_checks",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "failed_checks": {+ "name": "failed_checks",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "uncertain_checks": {+ "name": "uncertain_checks",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "summary": {+ "name": "summary",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "reviewed_by_user": {+ "name": "reviewed_by_user",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "generated_by": {+ "name": "generated_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "default": "'system'"+ },+ "generated_at": {+ "name": "generated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "verify_reports_verify_run_id_unique": {+ "name": "verify_reports_verify_run_id_unique",+ "columns": [+ {+ "expression": "verify_run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_reports_operation_id_idx": {+ "name": "verify_reports_operation_id_idx",+ "columns": [+ {+ "expression": "operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_reports_user_id_idx": {+ "name": "verify_reports_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_reports_workspace_id_idx": {+ "name": "verify_reports_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "verify_reports_verify_run_id_verify_runs_id_fk": {+ "name": "verify_reports_verify_run_id_verify_runs_id_fk",+ "tableFrom": "verify_reports",+ "tableTo": "verify_runs",+ "columnsFrom": [+ "verify_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_reports_operation_id_agent_operations_id_fk": {+ "name": "verify_reports_operation_id_agent_operations_id_fk",+ "tableFrom": "verify_reports",+ "tableTo": "agent_operations",+ "columnsFrom": [+ "operation_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "verify_reports_user_id_users_id_fk": {+ "name": "verify_reports_user_id_users_id_fk",+ "tableFrom": "verify_reports",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_reports_workspace_id_workspaces_id_fk": {+ "name": "verify_reports_workspace_id_workspaces_id_fk",+ "tableFrom": "verify_reports",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.verify_review_predictions": {+ "name": "verify_review_predictions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "check_result_id": {+ "name": "check_result_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "prompt_version": {+ "name": "prompt_version",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "action": {+ "name": "action",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status_reason": {+ "name": "status_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "confidence": {+ "name": "confidence",+ "type": "numeric(3, 2)",+ "primaryKey": false,+ "notNull": false+ },+ "comment": {+ "name": "comment",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "rationale": {+ "name": "rationale",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "annotations": {+ "name": "annotations",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "adjudication": {+ "name": "adjudication",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "adjudication_edit": {+ "name": "adjudication_edit",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "adjudicated_at": {+ "name": "adjudicated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "latency_ms": {+ "name": "latency_ms",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "prompt_tokens": {+ "name": "prompt_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "completion_tokens": {+ "name": "completion_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "verify_review_predictions_check_result_id_idx": {+ "name": "verify_review_predictions_check_result_id_idx",+ "columns": [+ {+ "expression": "check_result_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_review_predictions_user_id_idx": {+ "name": "verify_review_predictions_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_review_predictions_workspace_id_idx": {+ "name": "verify_review_predictions_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_review_predictions_model_idx": {+ "name": "verify_review_predictions_model_idx",+ "columns": [+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "model",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_review_predictions_result_model_prompt_unique": {+ "name": "verify_review_predictions_result_model_prompt_unique",+ "columns": [+ {+ "expression": "check_result_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "model",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "prompt_version",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "verify_review_predictions_check_result_id_verify_check_results_id_fk": {+ "name": "verify_review_predictions_check_result_id_verify_check_results_id_fk",+ "tableFrom": "verify_review_predictions",+ "tableTo": "verify_check_results",+ "columnsFrom": [+ "check_result_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_review_predictions_user_id_users_id_fk": {+ "name": "verify_review_predictions_user_id_users_id_fk",+ "tableFrom": "verify_review_predictions",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_review_predictions_workspace_id_workspaces_id_fk": {+ "name": "verify_review_predictions_workspace_id_workspaces_id_fk",+ "tableFrom": "verify_review_predictions",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "verify_review_predictions_action_matches_status": {+ "name": "verify_review_predictions_action_matches_status",+ "value": "(\"verify_review_predictions\".\"status\" = 'judged') = (\"verify_review_predictions\".\"action\" IS NOT NULL)"+ }+ },+ "isRLSEnabled": false+ },+ "public.verify_rubric_criteria": {+ "name": "verify_rubric_criteria",+ "schema": "",+ "columns": {+ "rubric_id": {+ "name": "rubric_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "criterion_id": {+ "name": "criterion_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "sort_order": {+ "name": "sort_order",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "verify_rubric_criteria_criterion_id_idx": {+ "name": "verify_rubric_criteria_criterion_id_idx",+ "columns": [+ {+ "expression": "criterion_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_rubric_criteria_user_id_idx": {+ "name": "verify_rubric_criteria_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_rubric_criteria_workspace_id_idx": {+ "name": "verify_rubric_criteria_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "verify_rubric_criteria_rubric_id_verify_rubrics_id_fk": {+ "name": "verify_rubric_criteria_rubric_id_verify_rubrics_id_fk",+ "tableFrom": "verify_rubric_criteria",+ "tableTo": "verify_rubrics",+ "columnsFrom": [+ "rubric_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_rubric_criteria_criterion_id_verify_criteria_id_fk": {+ "name": "verify_rubric_criteria_criterion_id_verify_criteria_id_fk",+ "tableFrom": "verify_rubric_criteria",+ "tableTo": "verify_criteria",+ "columnsFrom": [+ "criterion_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_rubric_criteria_user_id_users_id_fk": {+ "name": "verify_rubric_criteria_user_id_users_id_fk",+ "tableFrom": "verify_rubric_criteria",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_rubric_criteria_workspace_id_workspaces_id_fk": {+ "name": "verify_rubric_criteria_workspace_id_workspaces_id_fk",+ "tableFrom": "verify_rubric_criteria",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "verify_rubric_criteria_rubric_id_criterion_id_pk": {+ "name": "verify_rubric_criteria_rubric_id_criterion_id_pk",+ "columns": [+ "rubric_id",+ "criterion_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.verify_rubrics": {+ "name": "verify_rubrics",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "verify_rubrics_user_id_idx": {+ "name": "verify_rubrics_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_rubrics_workspace_id_idx": {+ "name": "verify_rubrics_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "verify_rubrics_user_id_users_id_fk": {+ "name": "verify_rubrics_user_id_users_id_fk",+ "tableFrom": "verify_rubrics",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_rubrics_workspace_id_workspaces_id_fk": {+ "name": "verify_rubrics_workspace_id_workspaces_id_fk",+ "tableFrom": "verify_rubrics",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.verify_runs": {+ "name": "verify_runs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "acceptance_id": {+ "name": "acceptance_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "round_index": {+ "name": "round_index",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "operation_id": {+ "name": "operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'agent'"+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "scenario": {+ "name": "scenario",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "goal": {+ "name": "goal",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "context": {+ "name": "context",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "plan": {+ "name": "plan",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "plan_confirmed_at": {+ "name": "plan_confirmed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_decision": {+ "name": "user_decision",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "decision_detail": {+ "name": "decision_detail",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "verify_runs_user_id_idx": {+ "name": "verify_runs_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_runs_workspace_id_idx": {+ "name": "verify_runs_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_runs_acceptance_id_idx": {+ "name": "verify_runs_acceptance_id_idx",+ "columns": [+ {+ "expression": "acceptance_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_runs_acceptance_round_unique": {+ "name": "verify_runs_acceptance_round_unique",+ "columns": [+ {+ "expression": "acceptance_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "round_index",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_runs_operation_id_unique": {+ "name": "verify_runs_operation_id_unique",+ "columns": [+ {+ "expression": "operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_runs_source_idx": {+ "name": "verify_runs_source_idx",+ "columns": [+ {+ "expression": "source",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_runs_user_decision_idx": {+ "name": "verify_runs_user_decision_idx",+ "columns": [+ {+ "expression": "user_decision",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "verify_runs_user_id_users_id_fk": {+ "name": "verify_runs_user_id_users_id_fk",+ "tableFrom": "verify_runs",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_runs_workspace_id_workspaces_id_fk": {+ "name": "verify_runs_workspace_id_workspaces_id_fk",+ "tableFrom": "verify_runs",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_runs_acceptance_id_acceptances_id_fk": {+ "name": "verify_runs_acceptance_id_acceptances_id_fk",+ "tableFrom": "verify_runs",+ "tableTo": "acceptances",+ "columnsFrom": [+ "acceptance_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "verify_runs_operation_id_agent_operations_id_fk": {+ "name": "verify_runs_operation_id_agent_operations_id_fk",+ "tableFrom": "verify_runs",+ "tableTo": "agent_operations",+ "columnsFrom": [+ "operation_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "verify_runs_acceptance_requires_round": {+ "name": "verify_runs_acceptance_requires_round",+ "value": "\"verify_runs\".\"acceptance_id\" IS NULL OR \"verify_runs\".\"round_index\" IS NOT NULL"+ }+ },+ "isRLSEnabled": false+ },+ "public.work_versions": {+ "name": "work_versions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "work_id": {+ "name": "work_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "change_type": {+ "name": "change_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "tool_name": {+ "name": "tool_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "tool_identifier": {+ "name": "tool_identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "message_id": {+ "name": "message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "root_operation_id": {+ "name": "root_operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "tool_call_id": {+ "name": "tool_call_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "cumulative_cost": {+ "name": "cumulative_cost",+ "type": "numeric(20, 6)",+ "primaryKey": false,+ "notNull": false+ },+ "cumulative_usage": {+ "name": "cumulative_usage",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "work_versions_work_id_version_unique": {+ "name": "work_versions_work_id_version_unique",+ "columns": [+ {+ "expression": "work_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "version",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "work_versions_work_id_tool_call_id_unique": {+ "name": "work_versions_work_id_tool_call_id_unique",+ "columns": [+ {+ "expression": "work_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "tool_call_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"work_versions\".\"tool_call_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "work_versions_thread_id_idx": {+ "name": "work_versions_thread_id_idx",+ "columns": [+ {+ "expression": "thread_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "work_versions_message_id_idx": {+ "name": "work_versions_message_id_idx",+ "columns": [+ {+ "expression": "message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "work_versions_agent_id_idx": {+ "name": "work_versions_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "work_versions_root_operation_created_at_idx": {+ "name": "work_versions_root_operation_created_at_idx",+ "columns": [+ {+ "expression": "root_operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "work_versions_topic_created_at_idx": {+ "name": "work_versions_topic_created_at_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "work_versions_topic_thread_created_at_idx": {+ "name": "work_versions_topic_thread_created_at_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "thread_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "work_versions_work_id_works_id_fk": {+ "name": "work_versions_work_id_works_id_fk",+ "tableFrom": "work_versions",+ "tableTo": "works",+ "columnsFrom": [+ "work_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "work_versions_topic_id_topics_id_fk": {+ "name": "work_versions_topic_id_topics_id_fk",+ "tableFrom": "work_versions",+ "tableTo": "topics",+ "columnsFrom": [+ "topic_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "work_versions_thread_id_threads_id_fk": {+ "name": "work_versions_thread_id_threads_id_fk",+ "tableFrom": "work_versions",+ "tableTo": "threads",+ "columnsFrom": [+ "thread_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "work_versions_message_id_messages_id_fk": {+ "name": "work_versions_message_id_messages_id_fk",+ "tableFrom": "work_versions",+ "tableTo": "messages",+ "columnsFrom": [+ "message_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "work_versions_agent_id_agents_id_fk": {+ "name": "work_versions_agent_id_agents_id_fk",+ "tableFrom": "work_versions",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.works": {+ "name": "works",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "current_version_id": {+ "name": "current_version_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "resource_type": {+ "name": "resource_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "resource_id": {+ "name": "resource_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "tool_name": {+ "name": "tool_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "tool_identifier": {+ "name": "tool_identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "origin_topic_id": {+ "name": "origin_topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "origin_thread_id": {+ "name": "origin_thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "origin_agent_id": {+ "name": "origin_agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_deleted": {+ "name": "is_deleted",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "works_resource_user_unique": {+ "name": "works_resource_user_unique",+ "columns": [+ {+ "expression": "resource_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"works\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "works_resource_workspace_unique": {+ "name": "works_resource_workspace_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"works\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "works_user_id_idx": {+ "name": "works_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "works_workspace_id_idx": {+ "name": "works_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "works_workspace_visibility_idx": {+ "name": "works_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "works_user_updated_at_id_idx": {+ "name": "works_user_updated_at_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"works\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "works_workspace_updated_at_id_idx": {+ "name": "works_workspace_updated_at_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"works\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "works_origin_topic_id_idx": {+ "name": "works_origin_topic_id_idx",+ "columns": [+ {+ "expression": "origin_topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "works_origin_thread_id_idx": {+ "name": "works_origin_thread_id_idx",+ "columns": [+ {+ "expression": "origin_thread_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "works_origin_agent_id_idx": {+ "name": "works_origin_agent_id_idx",+ "columns": [+ {+ "expression": "origin_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "works_origin_topic_id_topics_id_fk": {+ "name": "works_origin_topic_id_topics_id_fk",+ "tableFrom": "works",+ "tableTo": "topics",+ "columnsFrom": [+ "origin_topic_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "works_origin_thread_id_threads_id_fk": {+ "name": "works_origin_thread_id_threads_id_fk",+ "tableFrom": "works",+ "tableTo": "threads",+ "columnsFrom": [+ "origin_thread_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "works_origin_agent_id_agents_id_fk": {+ "name": "works_origin_agent_id_agents_id_fk",+ "tableFrom": "works",+ "tableTo": "agents",+ "columnsFrom": [+ "origin_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "works_user_id_users_id_fk": {+ "name": "works_user_id_users_id_fk",+ "tableFrom": "works",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "works_workspace_id_workspaces_id_fk": {+ "name": "works_workspace_id_workspaces_id_fk",+ "tableFrom": "works",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.workspace_audit_logs": {+ "name": "workspace_audit_logs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "action": {+ "name": "action",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "resource_type": {+ "name": "resource_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resource_id": {+ "name": "resource_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "ip_address": {+ "name": "ip_address",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "workspace_audit_logs_workspace_id_idx": {+ "name": "workspace_audit_logs_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspace_audit_logs_action_idx": {+ "name": "workspace_audit_logs_action_idx",+ "columns": [+ {+ "expression": "action",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspace_audit_logs_created_at_idx": {+ "name": "workspace_audit_logs_created_at_idx",+ "columns": [+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "workspace_audit_logs_workspace_id_workspaces_id_fk": {+ "name": "workspace_audit_logs_workspace_id_workspaces_id_fk",+ "tableFrom": "workspace_audit_logs",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.workspace_invitations": {+ "name": "workspace_invitations",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "inviter_id": {+ "name": "inviter_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'member'"+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "workspace_invitations_workspace_id_idx": {+ "name": "workspace_invitations_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspace_invitations_email_idx": {+ "name": "workspace_invitations_email_idx",+ "columns": [+ {+ "expression": "email",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspace_invitations_token_idx": {+ "name": "workspace_invitations_token_idx",+ "columns": [+ {+ "expression": "token",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "workspace_invitations_workspace_id_workspaces_id_fk": {+ "name": "workspace_invitations_workspace_id_workspaces_id_fk",+ "tableFrom": "workspace_invitations",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "workspace_invitations_inviter_id_users_id_fk": {+ "name": "workspace_invitations_inviter_id_users_id_fk",+ "tableFrom": "workspace_invitations",+ "tableTo": "users",+ "columnsFrom": [+ "inviter_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "workspace_invitations_token_unique": {+ "name": "workspace_invitations_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "token"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.workspace_members": {+ "name": "workspace_members",+ "schema": "",+ "columns": {+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'member'"+ },+ "joined_at": {+ "name": "joined_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "workspace_members_user_id_idx": {+ "name": "workspace_members_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspace_members_unique_active_owner_idx": {+ "name": "workspace_members_unique_active_owner_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"workspace_members\".\"role\" = 'owner' AND \"workspace_members\".\"deleted_at\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "workspace_members_workspace_id_workspaces_id_fk": {+ "name": "workspace_members_workspace_id_workspaces_id_fk",+ "tableFrom": "workspace_members",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "workspace_members_user_id_users_id_fk": {+ "name": "workspace_members_user_id_users_id_fk",+ "tableFrom": "workspace_members",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "workspace_members_workspace_id_user_id_pk": {+ "name": "workspace_members_workspace_id_user_id_pk",+ "columns": [+ "workspace_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.workspace_user_settings": {+ "name": "workspace_user_settings",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "preference": {+ "name": "preference",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "workspace_user_settings_workspace_id_user_id_unique": {+ "name": "workspace_user_settings_workspace_id_user_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspace_user_settings_user_id_idx": {+ "name": "workspace_user_settings_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "workspace_user_settings_workspace_id_workspaces_id_fk": {+ "name": "workspace_user_settings_workspace_id_workspaces_id_fk",+ "tableFrom": "workspace_user_settings",+ "tableTo": "workspaces",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "workspace_user_settings_user_id_users_id_fk": {+ "name": "workspace_user_settings_user_id_users_id_fk",+ "tableFrom": "workspace_user_settings",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.workspaces": {+ "name": "workspaces",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "slug": {+ "name": "slug",+ "type": "varchar(100)",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "varchar(1000)",+ "primaryKey": false,+ "notNull": false+ },+ "avatar": {+ "name": "avatar",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "primary_owner_id": {+ "name": "primary_owner_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "settings": {+ "name": "settings",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "frozen": {+ "name": "frozen",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "frozen_reason": {+ "name": "frozen_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "frozen_at": {+ "name": "frozen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "workspaces_slug_idx": {+ "name": "workspaces_slug_idx",+ "columns": [+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspaces_primary_owner_id_idx": {+ "name": "workspaces_primary_owner_id_idx",+ "columns": [+ {+ "expression": "primary_owner_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "workspaces_primary_owner_id_users_id_fk": {+ "name": "workspaces_primary_owner_id_users_id_fk",+ "tableFrom": "workspaces",+ "tableTo": "users",+ "columnsFrom": [+ "primary_owner_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ }+ },+ "enums": {},+ "schemas": {},+ "sequences": {+ "public.fts_search_sync_revision_seq": {+ "name": "fts_search_sync_revision_seq",+ "schema": "public",+ "increment": "1",+ "startWith": "1",+ "minValue": "1",+ "maxValue": "9223372036854775807",+ "cache": "1",+ "cycle": false+ }+ },+ "roles": {},+ "policies": {},+ "views": {},+ "_meta": {+ "columns": {},+ "schemas": {},+ "tables": {}+ }+}\ No newline at end of filediff --git a/packages/database/migrations/meta/_journal.json b/packages/database/migrations/meta/_journal.jsonindex 53fff648c42..7facf68fea1 100644--- a/packages/database/migrations/meta/_journal.json+++ b/packages/database/migrations/meta/_journal.json@@ -1078,7 +1078,14 @@"when": 1788108760793,"tag": "0153_fts_search_sync_outbox","breakpoints": true+ },+ {+ "idx": 154,+ "version": "7",+ "when": 1788141397076,+ "tag": "0154_goal_node_task_kind",+ "breakpoints": true}],"version": "6"-}+}\ No newline at end of filediff --git a/packages/database/src/models/__tests__/goal.test.ts b/packages/database/src/models/__tests__/goal.test.tsindex fad0966129d..4d987a91916 100644--- a/packages/database/src/models/__tests__/goal.test.ts+++ b/packages/database/src/models/__tests__/goal.test.ts@@ -61,7 +61,7 @@ describe('GoalModel', () => {it('finds the goal whose graph owns a Work Task', async () => {const task = await new TaskModel(serverDB, userId).create({ instruction: 'do the work' });const goal = await goalModel.create({ subjectType: 'standalone', title: 'Owner' });- const node = await graphModel.createNode(goal.id, { kind: 'work', title: 'W1' });+ const node = await graphModel.createNode(goal.id, { kind: 'task', title: 'W1' });await serverDB.update(goalNodes).set({ taskId: task.id }).where(eq(goalNodes.id, node!.id));expect((await goalModel.findByWorkTask(task.id))?.id).toBe(goal.id);@@ -72,7 +72,7 @@ describe('GoalModel', () => {const otherGraph = new GoalGraphModel(serverDB, otherUserId);const task = await new TaskModel(serverDB, otherUserId).create({ instruction: 'theirs' });const goal = await otherGoals.create({ subjectType: 'standalone', title: 'Theirs' });- const node = await otherGraph.createNode(goal.id, { kind: 'work', title: 'W1' });+ const node = await otherGraph.createNode(goal.id, { kind: 'task', title: 'W1' });await serverDB.update(goalNodes).set({ taskId: task.id }).where(eq(goalNodes.id, node!.id));expect(await goalModel.findByWorkTask(task.id)).toBeUndefined();@@ -83,8 +83,8 @@ describe('GoalModel', () => {it('lists goals the caller owns, newest first, with the graph roll-up', async () => {const goal = await goalModel.create({ subjectType: 'standalone', title: 'Reproduce it' });const problem = await graphModel.createNode(goal.id, { kind: 'problem', title: 'P1' });- const done = await graphModel.createNode(goal.id, { kind: 'work', title: 'W1' });- await graphModel.createNode(goal.id, { kind: 'work', title: 'W2' });+ const done = await graphModel.createNode(goal.id, { kind: 'task', title: 'W1' });+ await graphModel.createNode(goal.id, { kind: 'task', title: 'W2' });await graphModel.createNode(goal.id, { kind: 'finding', title: 'F1' });await graphModel.createEdge(goal.id, problem!.id, done!.id, 'decomposes');await graphModel.updateNodeStatus(goal.id, done!.id, 'resolved');@@ -147,8 +147,8 @@ describe('GoalModel', () => {subjectType: 'standalone',title: 'Theirs',});- await graphModel.createNode(ours.id, { kind: 'work', title: 'W1' });- await graphModel.createNode(others.id, { kind: 'work', title: 'W1' });+ await graphModel.createNode(ours.id, { kind: 'task', title: 'W1' });+ await graphModel.createNode(others.id, { kind: 'task', title: 'W1' });const scoped = await goalModel.list({ agentId: mine });expect(scoped.total).toBe(1);@@ -160,7 +160,7 @@ describe('GoalModel', () => {// them renders a goal page with no work, no frontier and no way forward.const legacy = await goalModel.create({ subjectType: 'task', title: 'Carrier-bound' });const graphed = await goalModel.create({ subjectType: 'standalone', title: 'Has a graph' });- await graphModel.createNode(graphed.id, { kind: 'work', title: 'W1' });+ await graphModel.createNode(graphed.id, { kind: 'task', title: 'W1' });const { goals, total } = await goalModel.list();@@ -172,8 +172,8 @@ describe('GoalModel', () => {it('filters by lifecycle status', async () => {const running = await goalModel.create({ subjectType: 'standalone', title: 'Running' });const achieved = await goalModel.create({ subjectType: 'standalone', title: 'Achieved' });- await graphModel.createNode(running.id, { kind: 'work', title: 'W1' });- await graphModel.createNode(achieved.id, { kind: 'work', title: 'W1' });+ await graphModel.createNode(running.id, { kind: 'task', title: 'W1' });+ await graphModel.createNode(achieved.id, { kind: 'task', title: 'W1' });await goalModel.updateStatus(running.id, 'running');await goalModel.updateStatus(achieved.id, 'achieved');@@ -188,7 +188,7 @@ describe('GoalModel', () => {it('picks up an open goal with nothing running', async () => {const goal = await goalModel.create({ subjectType: 'standalone', title: 'Never started' });await goalModel.updateStatus(goal.id, 'running');- await graphModel.createNode(goal.id, { kind: 'work', title: 'W1' });+ await graphModel.createNode(goal.id, { kind: 'task', title: 'W1' });const stalled = await GoalModel.listStalled(serverDB, { staleBefore: staleBefore() });expect(stalled.map(({ id }) => id)).toContain(goal.id);@@ -207,7 +207,7 @@ describe('GoalModel', () => {it('leaves a goal alone while one of its Work Tasks is freshly active', async () => {const goal = await goalModel.create({ subjectType: 'standalone', title: 'Working' });await goalModel.updateStatus(goal.id, 'running');- const node = await graphModel.createNode(goal.id, { kind: 'work', title: 'W1' });+ const node = await graphModel.createNode(goal.id, { kind: 'task', title: 'W1' });await graphModel.updateNodeStatus(goal.id, node!.id, 'active');const stalled = await GoalModel.listStalled(serverDB, { staleBefore: staleBefore() });@@ -217,7 +217,7 @@ describe('GoalModel', () => {it('reclaims a Work that outlived its operation lease', async () => {const goal = await goalModel.create({ subjectType: 'standalone', title: 'Lost' });await goalModel.updateStatus(goal.id, 'running');- const node = await graphModel.createNode(goal.id, { kind: 'work', title: 'W1' });+ const node = await graphModel.createNode(goal.id, { kind: 'task', title: 'W1' });await graphModel.updateNodeStatus(goal.id, node!.id, 'active');await serverDB.update(goalNodes)@@ -248,7 +248,7 @@ describe('GoalModel', () => {async (status) => {const goal = await goalModel.create({ subjectType: 'standalone', title: status });await goalModel.updateStatus(goal.id, status);- await graphModel.createNode(goal.id, { kind: 'work', title: 'W1' });+ await graphModel.createNode(goal.id, { kind: 'task', title: 'W1' });const stalled = await GoalModel.listStalled(serverDB, { staleBefore: staleBefore() });expect(stalled.map(({ id }) => id)).not.toContain(goal.id);@@ -297,7 +297,7 @@ describe('GoalModel', () => {it('cascades the whole graph away with the goal', async () => {const goal = await goalModel.create({ subjectType: 'standalone', title: 'Doomed' });const problem = await graphModel.createNode(goal.id, { kind: 'problem', title: 'P1' });- const work = await graphModel.createNode(goal.id, { kind: 'work', title: 'W1' });+ const work = await graphModel.createNode(goal.id, { kind: 'task', title: 'W1' });await graphModel.createEdge(goal.id, problem!.id, work!.id, 'decomposes');await goalModel.delete(goal.id);diff --git a/packages/database/src/models/__tests__/goalGraph.test.ts b/packages/database/src/models/__tests__/goalGraph.test.tsindex 8dcdf5aa485..616eb9b8423 100644--- a/packages/database/src/models/__tests__/goalGraph.test.ts+++ b/packages/database/src/models/__tests__/goalGraph.test.ts@@ -35,7 +35,7 @@ describe('GoalGraphModel', () => {title: 'Can the published specification reproduce the system?',});const work = await graphModel.createNode(goal.id, {- kind: 'work',+ kind: 'task',title: 'Implement the minimal training loop',});@@ -58,7 +58,7 @@ describe('GoalGraphModel', () => {type: 'system',});- const byUser = await graphModel.createNode(goal.id, { kind: 'work', title: 'Asked for' });+ const byUser = await graphModel.createNode(goal.id, { kind: 'task', title: 'Asked for' });const bySystem = await coordinator.createNode(goal.id, { kind: 'finding', title: 'Concluded' });await serverDB.insert(agents).values({ id: 'agt_author', slug: 'agt-author', userId });const byAgent = await coordinator.createNode(goal.id, {@@ -87,7 +87,7 @@ describe('GoalGraphModel', () => {subjectType: 'standalone',title: 'Concurrent synthesis',});- const input = { kind: 'work' as const, title: 'Complete full Goal acceptance' };+ const input = { kind: 'task' as const, title: 'Complete full Goal acceptance' };const results = await Promise.all([graphModel.createNodeOnce(goal.id, input),@@ -158,14 +158,14 @@ describe('GoalGraphModel', () => {it('allows only one task binding for a work node', async () => {const goal = await goalModel.create({ subjectType: 'standalone', title: 'Task binding race' });- const node = await graphModel.createNode(goal.id, { kind: 'work', title: 'Run once' });+ const node = await graphModel.createNode(goal.id, { kind: 'task', title: 'Run once' });const taskModel = new TaskModel(serverDB, userId);const [firstTask, secondTask] = await Promise.all([taskModel.create({ instruction: 'First candidate' }),taskModel.create({ instruction: 'Second candidate' }),]);- expect(await graphModel.claimWorkNode(goal.id, node!.id, new Date(0))).toBeDefined();+ expect(await graphModel.claimTaskNode(goal.id, node!.id, new Date(0))).toBeDefined();const bindings = await Promise.all([graphModel.bindTask(goal.id, node!.id, firstTask.id),graphModel.bindTask(goal.id, node!.id, secondTask.id),@@ -177,24 +177,35 @@ describe('GoalGraphModel', () => {expect(graph?.events.filter((event) => event.entityType === 'task')).toHaveLength(1);});+ it('refuses to bind a task to a node that is not a task node', async () => {+ // This used to be a CHECK constraint. It lives in `bindTask`'s WHERE now,+ // so the rule needs a test on the write path or nothing enforces it.+ const goal = await goalModel.create({ subjectType: 'standalone', title: 'Wrong kind' });+ const finding = await graphModel.createNode(goal.id, { kind: 'finding', title: 'A finding' });+ const task = await new TaskModel(serverDB, userId).create({ instruction: 'Should not bind' });++ expect(await graphModel.bindTask(goal.id, finding!.id, task.id)).toBeUndefined();+ expect((await graphModel.getGraph(goal.id))?.nodes[0].taskId).toBeNull();+ });+it('allows an abandoned work claim to be recovered after its lease expires', async () => {const goal = await goalModel.create({ subjectType: 'standalone', title: 'Recover claim' });- const node = await graphModel.createNode(goal.id, { kind: 'work', title: 'Recoverable work' });+ const node = await graphModel.createNode(goal.id, { kind: 'task', title: 'Recoverable work' });- expect(await graphModel.claimWorkNode(goal.id, node!.id, new Date(0))).toBeDefined();- expect(await graphModel.claimWorkNode(goal.id, node!.id, new Date(0))).toBeUndefined();+ expect(await graphModel.claimTaskNode(goal.id, node!.id, new Date(0))).toBeDefined();+ expect(await graphModel.claimTaskNode(goal.id, node!.id, new Date(0))).toBeUndefined();await serverDB.update(goalNodes).set({ updatedAt: new Date('2020-01-01') }).where(eq(goalNodes.id, node!.id));- expect(await graphModel.claimWorkNode(goal.id, node!.id, new Date('2021-01-01'))).toBeDefined();+ expect(await graphModel.claimTaskNode(goal.id, node!.id, new Date('2021-01-01'))).toBeDefined();});it('pins an immutable Work version to an owned graph node', async () => {const goal = await goalModel.create({ subjectType: 'standalone', title: 'Evidence goal' });- const node = await graphModel.createNode(goal.id, { kind: 'work', title: 'Produce evidence' });+ const node = await graphModel.createNode(goal.id, { kind: 'task', title: 'Produce evidence' });const task = await new TaskModel(serverDB, userId).create({ instruction: 'Produce evidence' });const work = await new WorkModel(serverDB, userId).registerTask({changeType: 'created',@@ -218,7 +229,7 @@ describe('GoalGraphModel', () => {const otherGoalModel = new GoalModel(serverDB, otherUserId);const otherGraphModel = new GoalGraphModel(serverDB, otherUserId);const goal = await otherGoalModel.create({ subjectType: 'standalone', title: 'Private graph' });- const node = await otherGraphModel.createNode(goal.id, { kind: 'work', title: 'Private work' });+ const node = await otherGraphModel.createNode(goal.id, { kind: 'task', title: 'Private work' });expect(await graphModel.getGraph(goal.id)).toBeUndefined();expect(await graphModel.updateNodeStatus(goal.id, node!.id, 'resolved')).toBeUndefined();diff --git a/packages/database/src/models/goal.ts b/packages/database/src/models/goal.tsindex bda0c1e3330..4eba347d847 100644--- a/packages/database/src/models/goal.ts+++ b/packages/database/src/models/goal.ts@@ -74,7 +74,7 @@ export class GoalModel {.select({ goal: goals }).from(goalNodes).innerJoin(goals, eq(goalNodes.goalId, goals.id))- .where(and(eq(goalNodes.taskId, taskId), eq(goalNodes.kind, 'work'), this.ownership()))+ .where(and(eq(goalNodes.taskId, taskId), eq(goalNodes.kind, 'task'), this.ownership())).limit(1);return row?.goal;};@@ -139,7 +139,7 @@ export class GoalModel {sql`NOT EXISTS (SELECT 1 FROM ${goalNodes}WHERE ${goalNodes.goalId} = ${goals.id}- AND ${goalNodes.kind} = 'work'+ AND ${goalNodes.kind} = 'task'AND ${goalNodes.status} = 'active'AND ${goalNodes.updatedAt} > ${staleBefore})`,@@ -227,7 +227,7 @@ export class GoalModel {const current = stats.get(row.goalId) ?? { findingCount: 0, workDone: 0, workTotal: 0 };const count = Number(row.count);if (row.kind === 'finding') current.findingCount += count;- if (row.kind === 'work') {+ if (row.kind === 'task') {current.workTotal += count;if (TERMINAL_NODE_STATUSES.has(row.status)) current.workDone += count;}@@ -271,7 +271,7 @@ export class GoalModel {FROM ${goalNodes}JOIN ${tasks} ON ${tasks.id} = ${goalNodes.taskId}WHERE ${inArray(goalNodes.goalId, goalIds)}- AND ${goalNodes.kind} = 'work'+ AND ${goalNodes.kind} = 'task'AND ${this.taskOwnershipSql('tasks')}UNION ALLSELECT work_tree.goal_id, child.iddiff --git a/packages/database/src/models/goalGraph.ts b/packages/database/src/models/goalGraph.tsindex 9d2c7701e18..9a32f26bd5b 100644--- a/packages/database/src/models/goalGraph.ts+++ b/packages/database/src/models/goalGraph.ts@@ -277,7 +277,7 @@ export class GoalGraphModel {and(eq(goalNodes.goalId, goalId),eq(goalNodes.id, nodeId),- eq(goalNodes.kind, 'work'),+ eq(goalNodes.kind, 'task'),isNull(goalNodes.taskId),),)@@ -292,7 +292,7 @@ export class GoalGraphModel {return node;});- claimWorkNode = async (goalId: string, nodeId: string, staleBefore: Date) =>+ claimTaskNode = async (goalId: string, nodeId: string, staleBefore: Date) =>this.db.transaction(async (tx) => {if (!(await this.ownedGoal(goalId, tx))) return undefined;const [node] = await tx@@ -302,7 +302,7 @@ export class GoalGraphModel {and(eq(goalNodes.goalId, goalId),eq(goalNodes.id, nodeId),- eq(goalNodes.kind, 'work'),+ eq(goalNodes.kind, 'task'),or(eq(goalNodes.status, 'proposed'),and(eq(goalNodes.status, 'active'), lt(goalNodes.updatedAt, staleBefore)),diff --git a/packages/database/src/models/goalTrace.ts b/packages/database/src/models/goalTrace.tsnew file mode 100644index 00000000000..6e115a35b67--- /dev/null+++ b/packages/database/src/models/goalTrace.ts@@ -0,0 +1,65 @@+import { and, desc, eq } from 'drizzle-orm';++import { goals, goalTraces, type NewGoalTrace } from '../schemas';+import type { LobeChatDatabase } from '../type';+import { buildWorkspaceWhere } from '../utils/workspace';++/**+ * The observation row for a goal.+ *+ * Written from the trajectory rather than accumulated as the goal runs: every+ * value here is derived from the recorded advances, so re-deriving it is exact+ * however many times it runs — the same reason `recordCompletion` re-sums child+ * operations instead of adding to a counter.+ *+ * Reads join `goals` for ownership. The row has no `user_id` of its own on+ * purpose: it is 1:1 with a goal, so a copy would be a second place for the+ * answer to drift.+ */+export class GoalTraceModel {+ constructor(+ private readonly db: LobeChatDatabase,+ private readonly userId?: string,+ private readonly workspaceId?: string,+ ) {}++ private ownership = () =>+ buildWorkspaceWhere({ userId: this.userId!, workspaceId: this.workspaceId }, goals);++ /** Upsert; an advance rewrites the whole row from the trajectory it just extended. */+ upsert = async (value: NewGoalTrace) => {+ const [row] = await this.db+ .insert(goalTraces)+ .values(value)+ .onConflictDoUpdate({+ set: { ...value, updatedAt: new Date() },+ target: goalTraces.goalId,+ })+ .returning();+ return row;+ };++ /** Ownership-scoped: another user's goal reads as absent, never as forbidden. */+ findById = async (goalId: string) => {+ const [row] = await this.db+ .select({ goal: goals, trace: goalTraces })+ .from(goalTraces)+ .innerJoin(goals, eq(goalTraces.goalId, goals.id))+ .where(and(eq(goalTraces.goalId, goalId), this.ownership()))+ .limit(1);+ return row ? { ...row.trace, title: row.goal.title } : undefined;+ };++ /** Goals that recorded a trajectory, newest run first. */+ list = async (limit = 20) => {+ const rows = await this.db+ .select({ goal: goals, trace: goalTraces })+ .from(goalTraces)+ .innerJoin(goals, eq(goalTraces.goalId, goals.id))+ .where(this.ownership())+ .orderBy(desc(goalTraces.startedAt))+ .limit(limit);++ return rows.map(({ goal, trace }) => ({ ...trace, title: goal.title }));+ };+}diff --git a/packages/database/src/schemas/__tests__/goalGraph.test.ts b/packages/database/src/schemas/__tests__/goalGraph.test.tsindex 2b062ebc95a..b71dca1fe94 100644--- a/packages/database/src/schemas/__tests__/goalGraph.test.ts+++ b/packages/database/src/schemas/__tests__/goalGraph.test.ts@@ -48,7 +48,7 @@ describe('Goal Graph schema', () => {seq: 1,}).returning();- const [problemNode, workNode, findingNode, decisionNode] = await serverDB+ const [problemNode, taskNode, findingNode, decisionNode] = await serverDB.insert(goalNodes).values([{@@ -59,7 +59,7 @@ describe('Goal Graph schema', () => {},{goalId: goal.id,- kind: 'work',+ kind: 'task',status: 'active',taskId: task.id,title: 'Implement the minimal training loop',@@ -78,13 +78,13 @@ describe('Goal Graph schema', () => {{goalId: goal.id,kind: 'investigates',- sourceNodeId: workNode.id,+ sourceNodeId: taskNode.id,targetNodeId: problemNode.id,},{goalId: goal.id,kind: 'produces',- sourceNodeId: workNode.id,+ sourceNodeId: taskNode.id,targetNodeId: findingNode.id,},{@@ -168,7 +168,7 @@ describe('Goal Graph schema', () => {).resolves.toHaveLength(1);});- it('enforces the Work node to responsible Task one-to-one invariant', async () => {+ it('enforces that one task belongs to at most one node', async () => {const goal = await createGoal();const [task] = await serverDB.insert(tasks)@@ -180,18 +180,12 @@ describe('Goal Graph schema', () => {}).returning();- await expect(- serverDB.insert(goalNodes).values({- goalId: goal.id,- kind: 'problem',- taskId: task.id,- title: 'Invalid task binding',- }),- ).rejects.toThrow();-+ // Which kinds may own a task is `bindTask`'s job, not the database's — see+ // the model test. The uniqueness below is the part no single write can+ // check for itself, so it stays here.await serverDB.insert(goalNodes).values({goalId: goal.id,- kind: 'work',+ kind: 'task',taskId: task.id,title: 'Evaluate task generation strategy',});@@ -199,7 +193,7 @@ describe('Goal Graph schema', () => {await expect(serverDB.insert(goalNodes).values({goalId: goal.id,- kind: 'work',+ kind: 'task',taskId: task.id,title: 'Duplicate responsible task',}),diff --git a/packages/database/src/schemas/goalGraph.ts b/packages/database/src/schemas/goalGraph.tsindex dc13606ada6..bb73df66fab 100644--- a/packages/database/src/schemas/goalGraph.ts+++ b/packages/database/src/schemas/goalGraph.ts@@ -66,8 +66,16 @@ export const goalNodes = pgTable(index('goal_nodes_goal_id_status_idx').on(t.goalId, t.status),index('goal_nodes_goal_id_kind_idx').on(t.goalId, t.kind),unique('goal_nodes_goal_id_id_unique').on(t.goalId, t.id),+ /**+ * One task, one node. This stays in the database because it is a real+ * invariant no single write can check for itself.+ *+ * *Which* kinds may own a task deliberately does not: `bindTask` is the+ * only writer of `task_id` and its WHERE already requires the kind, and a+ * CHECK would pin the kind vocabulary into DDL — an ALTER every time that+ * vocabulary moves, which is exactly what renaming `work` to `task` cost.+ */uniqueIndex('goal_nodes_task_id_unique').on(t.taskId).where(isNotNull(t.taskId)),- check('goal_nodes_task_requires_work_kind', sql`${t.taskId} IS NULL OR ${t.kind} = 'work'`),check('goal_nodes_confidence_range',sql`${t.confidence} IS NULL OR (${t.confidence} >= 0 AND ${t.confidence} <= 1)`,diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.tsindex 95bbe22f1fb..9cb12936013 100644--- a/packages/locales/src/default/chat.ts+++ b/packages/locales/src/default/chat.ts@@ -1838,7 +1838,7 @@ export default {'goalProcess.edge.contradicts': 'contradicts','goalProcess.edge.leadsTo': 'leads to','goalProcess.kind.problem': 'Question',- 'goalProcess.kind.work': 'Task',+ 'goalProcess.kind.task': 'Task','goalProcess.kind.finding': 'Finding','goalProcess.kind.decision': 'Decision','goalProcess.node.running': 'Running',diff --git a/packages/types/src/goal.ts b/packages/types/src/goal.tsindex 59a565d32a4..06e92e67a31 100644--- a/packages/types/src/goal.ts+++ b/packages/types/src/goal.ts@@ -24,7 +24,7 @@ export type GoalSubjectType = 'task' | 'topic' | 'standalone';/** Automatic recovery policy for Goal Graph Work. */export interface GoalRecoveryPolicy {/** Maximum execution attempts for one Work before escalating to a decision gate. */- maxAttemptsPerWork?: number;+ maxAttemptsPerTask?: number;/** Per-operation agent step limit. Null/undefined leaves the runtime uncapped. */maxStepsPerRun?: number | null;/** Time without a durable runtime lease refresh before a running Work is reclaimed. */@@ -68,7 +68,7 @@ export interface GoalItem {// ============================================/** Coarse-grained semantic role of a node in a Goal Graph. */-export type GoalNodeKind = 'problem' | 'work' | 'finding' | 'decision';+export type GoalNodeKind = 'problem' | 'task' | 'finding' | 'decision';/** Semantic lifecycle of a node; independent from the execution status of its Task. */export type GoalNodeStatus =diff --git a/src/features/AgentGoals/CreateGoalModal/CreateGoalContent.tsx b/src/features/AgentGoals/CreateGoalModal/CreateGoalContent.tsxindex a084335c2c3..53ad8ecffa0 100644--- a/src/features/AgentGoals/CreateGoalModal/CreateGoalContent.tsx+++ b/src/features/AgentGoals/CreateGoalModal/CreateGoalContent.tsx@@ -436,7 +436,7 @@ const CreateGoalContent = memo<CreateGoalContentProps>((props) => {const graph = await goalService.create({agentId,config: {- recovery: { maxAttemptsPerWork: resolveGoalAttemptBudget(plan.maxIterations) },+ recovery: { maxAttemptsPerTask: resolveGoalAttemptBudget(plan.maxIterations) },},// `maxIterations` is the per-Work attempt budget above; it is not the// graph-wide round cap, which counts runs across every Work and woulddiff --git a/src/features/AgentGoals/GoalDetailPage.tsx b/src/features/AgentGoals/GoalDetailPage.tsxindex 5e00cabd7d2..b7a74a50865 100644--- a/src/features/AgentGoals/GoalDetailPage.tsx+++ b/src/features/AgentGoals/GoalDetailPage.tsx@@ -60,7 +60,7 @@ const GoalDetailPage = memo<GoalDetailPageProps>(({ agentId, goalId }) => {);const { goal, nodes } = snapshot;- const tasks = nodes.filter((node) => node.kind === 'work').length;+ const tasks = nodes.filter((node) => node.kind === 'task').length;const findings = nodes.filter((node) => node.kind === 'finding').length;return (diff --git a/src/features/AgentGoals/ProcessControl/Activity.tsx b/src/features/AgentGoals/ProcessControl/Activity.tsxindex ca1790377b9..b432cb2ea42 100644--- a/src/features/AgentGoals/ProcessControl/Activity.tsx+++ b/src/features/AgentGoals/ProcessControl/Activity.tsx@@ -221,7 +221,7 @@ const Activity = memo<{ graph: GoalGraphView; onSelect: (nodeId: string) => voidconst rows = graph.nodes.filter((view) =>- (view.node.kind === 'work' &&+ (view.node.kind === 'task' &&(view.attempts.length > 0 || view.node.status !== 'proposed')) ||(view.node.kind === 'decision' && view.node.status !== 'proposed'),)diff --git a/src/features/AgentGoals/ProcessControl/Findings.tsx b/src/features/AgentGoals/ProcessControl/Findings.tsxindex c7255f8e58d..eb338b1c278 100644--- a/src/features/AgentGoals/ProcessControl/Findings.tsx+++ b/src/features/AgentGoals/ProcessControl/Findings.tsx@@ -114,7 +114,7 @@ const FindingRow = memo<{ onSelect: (nodeId: string) => void; view: GoalNodeViewstyle={{ cursor: 'pointer' }}onClick={() => onSelect(view.producedBy!.id)}>- <KindDot kind={'work'} />+ <KindDot kind={'task'} /><Text fontSize={12} type={'secondary'}>{t('goalProcess.findings.from', { title: view.producedBy.title })}</Text>diff --git a/src/features/AgentGoals/ProcessControl/Graph/GraphNode.tsx b/src/features/AgentGoals/ProcessControl/Graph/GraphNode.tsxindex 7b8b60a367c..8f8c5ba3d13 100644--- a/src/features/AgentGoals/ProcessControl/Graph/GraphNode.tsx+++ b/src/features/AgentGoals/ProcessControl/Graph/GraphNode.tsx@@ -153,9 +153,9 @@ const useStateChip = (data: GraphNodeData): { color: string; text: string } | nuif (isGate) return { color: cssVar.colorWarning, text: t('goalProcess.tag.needsDecision') };if (stale) return { color: cssVar.colorError, text: t('goalProcess.tag.lost') };if (running) return { color: cssVar.colorInfo, text: t('goalProcess.node.running') };- if (node.kind === 'work' && node.status === 'resolved')+ if (node.kind === 'task' && node.status === 'resolved')return { color: cssVar.colorSuccess, text: t('goalProcess.node.done') };- if (node.kind === 'work' && (node.status === 'retired' || node.status === 'rejected'))+ if (node.kind === 'task' && (node.status === 'retired' || node.status === 'rejected'))return { color: cssVar.colorTextTertiary, text: t('goalProcess.tag.retired') };if (node.kind === 'decision' && node.status === 'resolved')return {@@ -182,7 +182,7 @@ const GraphNodeView = memo<NodeProps>(({ data }) => {const { node } = view;const chip = useStateChip(nodeData);const palette = KIND_COLOR[node.kind];- const isWork = node.kind === 'work';+ const isTask = node.kind === 'task';const attempts = view.attempts.length;return (@@ -229,7 +229,7 @@ const GraphNodeView = memo<NodeProps>(({ data }) => {)}</Flexbox></div>- {isWork && (+ {isTask && (<div className={styles.metrics}>{node.taskId ? (<Tooltip title={t('goalProcess.node.verifierTooltip')}>diff --git a/src/features/AgentGoals/ProcessControl/Graph/index.tsx b/src/features/AgentGoals/ProcessControl/Graph/index.tsxindex db6ccd23c03..ec2725d84fc 100644--- a/src/features/AgentGoals/ProcessControl/Graph/index.tsx+++ b/src/features/AgentGoals/ProcessControl/Graph/index.tsx@@ -330,7 +330,7 @@ const Graph = memo<GraphProps>((props) => {</Flexbox><Flexbox horizontal align={'center'} gap={12}><Flexbox horizontal align={'center'} className={styles.legend} gap={10}>- {(['problem', 'work', 'finding', 'decision'] as const).map((kind) => (+ {(['problem', 'task', 'finding', 'decision'] as const).map((kind) => (<Flexbox horizontal align={'center'} gap={4} key={kind}><KindDot kind={kind} /><span>{t(`goalProcess.kind.${kind}` as const)}</span>diff --git a/src/features/AgentGoals/ProcessControl/Graph/layout.test.ts b/src/features/AgentGoals/ProcessControl/Graph/layout.test.tsindex 03e7e49f9e6..80994f09a63 100644--- a/src/features/AgentGoals/ProcessControl/Graph/layout.test.ts+++ b/src/features/AgentGoals/ProcessControl/Graph/layout.test.ts@@ -3,7 +3,7 @@ import { describe, expect, it } from 'vitest';import { layoutGraph } from './layout';-const node = (id: string, kind: GoalGraphNode['kind'] = 'work'): GoalGraphNode => ({+const node = (id: string, kind: GoalGraphNode['kind'] = 'task'): GoalGraphNode => ({confidence: null,createdAt: new Date('2026-08-01T00:00:00Z'),createdByAgentId: null,diff --git a/src/features/AgentGoals/ProcessControl/Graph/layout.ts b/src/features/AgentGoals/ProcessControl/Graph/layout.tsindex 8ec95fe236b..93e433a44b5 100644--- a/src/features/AgentGoals/ProcessControl/Graph/layout.ts+++ b/src/features/AgentGoals/ProcessControl/Graph/layout.ts@@ -9,8 +9,8 @@ import type { GoalGraphEdge, GoalGraphNode } from '@lobechat/types';* dependency for a layout that fits in a screen of code.*/-export const NODE_WIDTH = { decision: 250, finding: 240, problem: 230, work: 260 } as const;-export const NODE_HEIGHT = { decision: 76, finding: 76, problem: 76, work: 112 } as const;+export const NODE_WIDTH = { decision: 250, finding: 240, problem: 230, task: 260 } as const;+export const NODE_HEIGHT = { decision: 76, finding: 76, problem: 76, task: 112 } as const;const RANK_GAP = 56;const COLUMN_GAP = 32;diff --git a/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.ts b/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.tsindex fbfc52999eb..e3d15270ee7 100644--- a/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.ts+++ b/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.ts@@ -43,7 +43,7 @@ const node = (id: string, overrides: Partial<GoalGraphNode> = {}): GoalGraphNodedescription: null,goalId: 'goal-1',id,- kind: 'work',+ kind: 'task',priority: 0,resolvedAt: null,status: 'proposed',diff --git a/src/features/AgentGoals/ProcessControl/goalGraphViewModel.ts b/src/features/AgentGoals/ProcessControl/goalGraphViewModel.tsindex c564e759dcd..a20c2019ab6 100644--- a/src/features/AgentGoals/ProcessControl/goalGraphViewModel.ts+++ b/src/features/AgentGoals/ProcessControl/goalGraphViewModel.ts@@ -235,10 +235,10 @@ export const buildGoalGraphView = (gateSubjectId: gateSubject.get(node.id),humanTouches: nodeDecisions.filter((d) => d.status === 'resolved' && !!d.resolvedByUserId),isStale:- node.kind === 'work' && node.status === 'active' && now - node.updatedAt.getTime() > lease,+ node.kind === 'task' && node.status === 'active' && now - node.updatedAt.getTime() > lease,node,producedBy: producedByFinding.get(node.id),- seq: node.kind === 'work' ? ++seq : undefined,+ seq: node.kind === 'task' ? ++seq : undefined,startedAt: isRunningAttempt ? open.startedAt : undefined,};});@@ -254,7 +254,7 @@ export const buildGoalGraphView = (frontier.push({ key: node.id, kind: 'gate', rank: 0, view });continue;}- if (node.kind !== 'work') continue;+ if (node.kind !== 'task') continue;if (node.status === 'active') {frontier.push({key: node.id,@@ -270,7 +270,7 @@ export const buildGoalGraphView = (}const done = views- .filter((view) => view.node.kind === 'work' && TERMINAL_NODE_STATUSES.has(view.node.status))+ .filter((view) => view.node.kind === 'task' && TERMINAL_NODE_STATUSES.has(view.node.status)).sort((a, b) => resolvedTime(b.node) - resolvedTime(a.node)).slice(0, RECENT_DONE).map((view) => ({ key: `done:${view.node.id}`, kind: 'done' as const, rank: -1, view }));diff --git a/src/features/AgentGoals/ProcessControl/index.tsx b/src/features/AgentGoals/ProcessControl/index.tsxindex c7e2b2e08d0..9955badf93d 100644--- a/src/features/AgentGoals/ProcessControl/index.tsx+++ b/src/features/AgentGoals/ProcessControl/index.tsx@@ -73,7 +73,7 @@ const ProcessControl = memo<ProcessControlProps>(({ goalId }) => {const actions: FrontierActions = useMemo(() => ({addTask: async (title: string) => {- await goalService.addNode({ id: goalId, kind: 'work', title });+ await goalService.addNode({ id: goalId, kind: 'task', title });await refreshGoalGraph(goalId);},advance: () => void advance(),diff --git a/src/features/AgentGoals/ProcessControl/shared.tsx b/src/features/AgentGoals/ProcessControl/shared.tsxindex 5c41ff394db..fe60689c47b 100644--- a/src/features/AgentGoals/ProcessControl/shared.tsx+++ b/src/features/AgentGoals/ProcessControl/shared.tsx@@ -15,14 +15,14 @@ export const KIND_COLOR: Record<GoalNodeKind, { line: string; soft: string }> =decision: { line: cssVar.orange6, soft: cssVar.orange1 },finding: { line: cssVar.green6, soft: cssVar.green1 },problem: { line: cssVar.purple6, soft: cssVar.purple1 },- work: { line: cssVar.blue6, soft: cssVar.blue1 },+ task: { line: cssVar.blue6, soft: cssVar.blue1 },};export const KIND_ICON: Record<GoalNodeKind, LucideIcon> = {decision: GitBranch,finding: Lightbulb,problem: CircleHelp,- work: ListChecks,+ task: ListChecks,};const styles = createStaticStyles(({ css }) => ({diff --git a/src/features/Conversation/Messages/GoalWorkCard/useGoalWorkStatus.test.ts b/src/features/Conversation/Messages/GoalWorkCard/useGoalWorkStatus.test.tsindex 6a051b6e17c..da67cb5edca 100644--- a/src/features/Conversation/Messages/GoalWorkCard/useGoalWorkStatus.test.ts+++ b/src/features/Conversation/Messages/GoalWorkCard/useGoalWorkStatus.test.ts@@ -57,9 +57,9 @@ describe('useGoalWorkStatus', () => {it('counts every terminal Work node as closed', () => {mocks.goalGraphById['goal-1'] = snapshot({nodes: [- node('w1', 'work', 'resolved'),- node('w2', 'work', 'retired'),- node('w3', 'work', 'active'),+ node('w1', 'task', 'resolved'),+ node('w2', 'task', 'retired'),+ node('w3', 'task', 'active'),node('f1', 'finding', 'resolved'),] as never,});@@ -74,7 +74,7 @@ describe('useGoalWorkStatus', () => {it('reads a pending gate as waiting on the user', () => {mocks.goalGraphById['goal-1'] = snapshot({decisions: [{ status: 'pending' }] as never,- nodes: [node('w1', 'work', 'active')] as never,+ nodes: [node('w1', 'task', 'active')] as never,});const { result } = renderHook(() => useGoalWorkStatus({ goalId: 'goal-1' }));diff --git a/src/features/Conversation/Messages/GoalWorkCard/useGoalWorkStatus.ts b/src/features/Conversation/Messages/GoalWorkCard/useGoalWorkStatus.tsindex daae926d372..4b1da83f836 100644--- a/src/features/Conversation/Messages/GoalWorkCard/useGoalWorkStatus.ts+++ b/src/features/Conversation/Messages/GoalWorkCard/useGoalWorkStatus.ts@@ -18,7 +18,7 @@ export const useGoalWorkStatus = ({useFetchGoalGraph(goalId);const snapshot = useGoalStore(goalSelectors.goalGraph(goalId));- const workNodes = snapshot?.nodes.filter((node) => node.kind === 'work') ?? [];+ const taskNodes = snapshot?.nodes.filter((node) => node.kind === 'task') ?? [];return {agentId: snapshot?.goal.agentId ?? undefined,@@ -27,10 +27,10 @@ export const useGoalWorkStatus = ({pendingDecisions:snapshot?.decisions.filter((decision) => decision.status === 'pending').length ?? 0,status: snapshot?.goal.status,- workDone: workNodes.filter((node) =>+ workDone: taskNodes.filter((node) =>['rejected', 'resolved', 'retired'].includes(node.status),).length,- workTotal: workNodes.length,+ workTotal: taskNodes.length,}),startedAt: snapshot?.goal.startedAt ?? undefined,title: snapshot?.goal.title,