🤯 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(agent-share): share an Agent by card without opening its link (#23524)
Arvin Xuc4895b461c6f
diff --git a/apps/server/src/routers/lambda/__tests__/agentShare.test.ts b/apps/server/src/routers/lambda/__tests__/agentShare.test.tsindex 91e3654faa9..cadbde4df9c 100644--- a/apps/server/src/routers/lambda/__tests__/agentShare.test.ts+++ b/apps/server/src/routers/lambda/__tests__/agentShare.test.ts@@ -219,6 +219,33 @@ describe('agentShareRouter', () => {expect(mockCreate).toHaveBeenCalledWith('agent-1', 'link');});+ describe('enableCardShare', () => {+ it.each([+ ['creates a missing share as card-only', { ...share, visibility: 'card' }, 0],+ ['resumes a paused share as card-only', { ...share, visibility: 'private' }, 1],+ ])('%s', async (_label, existing, updates) => {+ mockCreate.mockResolvedValue(existing);+ const caller = agentShareRouter.createCaller(await createContextInner({ userId: 'user-1' }));++ await caller.enableCardShare({ agentId: 'agent-1' });++ expect(mockAssertShareModelAllowed).toHaveBeenCalled();+ expect(mockCreate).toHaveBeenCalledWith('agent-1', 'card');+ expect(mockUpdateVisibility).toHaveBeenCalledTimes(updates);+ if (updates) expect(mockUpdateVisibility).toHaveBeenCalledWith('agent-1', 'card');+ });++ it('leaves a live link share as it is', async () => {+ mockCreate.mockResolvedValue({ ...share, visibility: 'link' });+ const caller = agentShareRouter.createCaller(await createContextInner({ userId: 'user-1' }));++ await expect(caller.enableCardShare({ agentId: 'agent-1' })).resolves.toMatchObject({+ visibility: 'link',+ });+ expect(mockUpdateVisibility).not.toHaveBeenCalled();+ });+ });+it.each(['enableShare', 'updateVisibility'] as const)('rejects unsupported providers through %s before publishing',async (method) => {diff --git a/apps/server/src/routers/lambda/agentShare.ts b/apps/server/src/routers/lambda/agentShare.tsindex dc24e85c314..227075f2b31 100644--- a/apps/server/src/routers/lambda/agentShare.ts+++ b/apps/server/src/routers/lambda/agentShare.ts@@ -30,6 +30,8 @@ import { assertAgentShareCreationEnabled } from './_helpers/agentShareFeatureGatconst agentIdInput = z.object({ agentId: z.string().trim().min(1) }).strict();+const shareVisibilitySchema = z.enum(['private', 'card', 'link']);+/*** One `toolGrants` entry: a tool identifier, optionally narrowed to specific* API names. `apis` omitted grants every API the tool offers (still subject to@@ -230,20 +232,53 @@ export const agentShareRouter = router({return requireShare(await ctx.agentShareModel.updateVisibility(input.agentId, 'private'));}),+ /**+ * Let the Agent be shared by card, in one step from a card's send: a missing share is created+ * as `card`, a paused one resumes as `card`, a live one is left as it is. A `card` share admits+ * only the people who add the Agent from its owner's card; its link page stays closed. Same+ * preconditions as publishing a link.+ */+ enableCardShare: agentShareProcedure.input(agentIdInput).mutation(async ({ input, ctx }) => {+ await assertCanManageAgentShare(ctx, input.agentId);+ await assertAgentShareCreationEnabled(ctx.userId);++ return ctx.agentService.withShareModelLock(input.agentId, async (service, shares) => {+ await service.prepareShareModel(input.agentId);+ const share = await shares.create(input.agentId, 'card');+ if (share.visibility !== 'private') return share;+ return requireShare(await shares.updateVisibility(input.agentId, 'card'));+ });+ }),+enableShare: agentShareProcedure- .input(agentIdInput.extend({ visibility: z.enum(['private', 'link']).optional() }).strict())+ .input(agentIdInput.extend({ visibility: shareVisibilitySchema.optional() }).strict()).mutation(async ({ input, ctx }) => {await assertCanManageAgentShare(ctx, input.agentId);await assertAgentShareCreationEnabled(ctx.userId);- if (input.visibility === 'link') {+ const visibility = input.visibility;+ if (visibility === 'link' || visibility === 'card') {return ctx.agentService.withShareModelLock(input.agentId, async (service, shares) => {await service.prepareShareModel(input.agentId);- return shares.create(input.agentId, 'link');+ return shares.create(input.agentId, visibility);});}- return ctx.agentShareModel.create(input.agentId, input.visibility);+ return ctx.agentShareModel.create(input.agentId, visibility);+ }),++ /** The people this Agent's share admits by card, for its owner's share settings. */+ listCardGrants: agentShareProcedure.input(agentIdInput).query(async ({ input, ctx }) => {+ await assertCanManageAgentShare(ctx, input.agentId);+ return ctx.agentShareModel.listGrants(input.agentId);+ }),++ /** Withdraw one person's card grant; a run of theirs stops at its next step. */+ revokeCardGrant: agentShareProcedure+ .input(agentIdInput.extend({ userId: z.string().trim().min(1) }).strict())+ .mutation(async ({ input, ctx }) => {+ await assertCanManageAgentShare(ctx, input.agentId);+ return { revoked: await ctx.agentShareModel.revokeGrant(input.agentId, input.userId) };}),/**@@ -495,19 +530,20 @@ export const agentShareRouter = router({z.object({agentId: z.string().trim().min(1),- visibility: z.enum(['private', 'link']),+ visibility: shareVisibilitySchema,}).strict(),).mutation(async ({ input, ctx }) => {await assertCanManageAgentShare(ctx, input.agentId);- // Flipping to `link` publishes the share, so it is the same capability+ // Flipping to `link` or `card` admits others, so it is the same capability// as `enableShare`; going back to `private` unpublishes and stays open.- if (input.visibility === 'link') {+ const visibility = input.visibility;+ if (visibility === 'link' || visibility === 'card') {await assertAgentShareCreationEnabled(ctx.userId);return ctx.agentService.withShareModelLock(input.agentId, async (service, shares) => {await service.prepareShareModel(input.agentId);- return requireShare(await shares.updateVisibility(input.agentId, 'link'));+ return requireShare(await shares.updateVisibility(input.agentId, visibility));});}diff --git a/apps/server/src/routers/lambda/contact.ts b/apps/server/src/routers/lambda/contact.tsindex e2abef18934..d11b57cb636 100644--- a/apps/server/src/routers/lambda/contact.ts+++ b/apps/server/src/routers/lambda/contact.ts@@ -187,6 +187,12 @@ export const contactRouter = router({.input(z.object({ share: handle })).mutation(async ({ ctx, input }) => ctx.contactModel.addAgent(input.share)),+ /** Add an Agent from its card message; the owner's card admits the caller to a `card` share. */+ addAgentFromCard: contactProcedure+ .use(requireWorkspaceRoleWhenScoped('member'))+ .input(z.object({ messageId: z.uuid() }))+ .mutation(async ({ ctx, input }) => ctx.contactModel.addAgentFromCard(input.messageId)),+removeAgent: contactProcedure.use(requireWorkspaceRoleWhenScoped('member')).input(z.object({ agentId: z.string().min(1).max(64) }))diff --git a/apps/server/src/services/agent/index.ts b/apps/server/src/services/agent/index.tsindex da8bddff38c..d32eb960905 100644--- a/apps/server/src/services/agent/index.ts+++ b/apps/server/src/services/agent/index.ts@@ -6,6 +6,7 @@ import { type LobeChatDatabase } from '@lobechat/database';import {type AgentItem,type CreateAgentConfig,+ isLiveAgentShareVisibility,type LobeAgentChatConfig,type LobeAgentConfig,} from '@lobechat/types';@@ -432,7 +433,7 @@ export class AgentService {const share = await new AgentShareModel(this.db, this.userId, this.workspaceId).getByAgentId(agentId,);- if (share?.visibility === 'link') {+ if (isLiveAgentShareVisibility(share?.visibility)) {const selection = await this.assertShareModelAllowed(agentId, value);value = { ...value, ...selection };}diff --git a/apps/server/src/services/agentRuntime/AgentRuntimeService/shareRunGate.ts b/apps/server/src/services/agentRuntime/AgentRuntimeService/shareRunGate.tsindex 6d489619e11..3029248c38f 100644--- a/apps/server/src/services/agentRuntime/AgentRuntimeService/shareRunGate.ts+++ b/apps/server/src/services/agentRuntime/AgentRuntimeService/shareRunGate.ts@@ -24,10 +24,14 @@ export async function isShareRunRevoked(): Promise<boolean> {if (!verify) return false;const shareMarker = agentState.principal?.actor?.shareVisitor as- { agentId?: string; shareId?: string } | undefined;+ { agentId?: string; shareId?: string; visitorUserId?: string } | undefined;if (!shareMarker?.agentId || !shareMarker.shareId) return false;try {- return !(await verify({ agentId: shareMarker.agentId, shareId: shareMarker.shareId }));+ return !(await verify({+ agentId: shareMarker.agentId,+ shareId: shareMarker.shareId,+ visitorUserId: shareMarker.visitorUserId,+ }));} catch (error) {log('[%s][%d] Share run authorization re-check failed: %O', operationId, stepIndex, error);return true;diff --git a/apps/server/src/services/agentRuntime/AgentRuntimeService/types.ts b/apps/server/src/services/agentRuntime/AgentRuntimeService/types.tsindex 01e65a1d0a1..e0847ebb1f7 100644--- a/apps/server/src/services/agentRuntime/AgentRuntimeService/types.ts+++ b/apps/server/src/services/agentRuntime/AgentRuntimeService/types.ts@@ -211,6 +211,8 @@ export interface AgentRuntimeDelegate {verifyShareRunStillAuthorized?: (params: {agentId: string;shareId: string;+ /** The visitor the run serves: a `card` share admits only its grantees. */+ visitorUserId?: string;}) => Promise<boolean>;}diff --git a/apps/server/src/services/aiAgent/__tests__/execAgent.deferredInit.test.ts b/apps/server/src/services/aiAgent/__tests__/execAgent.deferredInit.test.tsindex eadb7278156..9f6bf0bab04 100644--- a/apps/server/src/services/aiAgent/__tests__/execAgent.deferredInit.test.ts+++ b/apps/server/src/services/aiAgent/__tests__/execAgent.deferredInit.test.ts@@ -51,6 +51,12 @@ vi.mock('@/server/featureFlags', () => ({vi.mock('@/database/models/agentShare', () => ({AgentShareModel: {+ // A `card` share admits only `card-grantee`; the grant lookup itself is the model's test.+ admitsVisitor: vi.fn(+ async (_db: unknown, share: { visibility: string }, visitorUserId: string) =>+ share.visibility === 'link' ||+ (share.visibility === 'card' && visitorUserId === 'card-grantee'),+ ),findByShareId: mockFindShareById,isRunStillAuthorized: vi.fn().mockResolvedValue(true),},@@ -468,6 +474,7 @@ describe('AiAgentService.runDeferredInit - parity with the send path', () => {it.each([['gone', null],['no longer public', { ...liveShare, visibility: 'private' }],+ ['card-only, without the visitor’s grant', { ...liveShare, visibility: 'card' }],['moved to another agent', { ...liveShare, agentId: 'agent-2' }],])('refuses to initialize when the share is %s', async (_label, share) => {mockFindShareById.mockResolvedValue(liveShare);diff --git a/apps/server/src/services/aiAgent/index.ts b/apps/server/src/services/aiAgent/index.tsindex 93bf3d5f7b6..c9bbea70fa4 100644--- a/apps/server/src/services/aiAgent/index.ts+++ b/apps/server/src/services/aiAgent/index.ts@@ -776,6 +776,7 @@ export class AiAgentService {verifyShareRunStillAuthorized = async (params: {agentId: string;shareId: string;+ visitorUserId?: string;}): Promise<boolean> => AgentShareModel.isRunStillAuthorized(this.db, params);/**diff --git a/apps/server/src/services/aiAgent/pipeline/deferredInit.ts b/apps/server/src/services/aiAgent/pipeline/deferredInit.tsindex 324b78663bf..f2bdd086158 100644--- a/apps/server/src/services/aiAgent/pipeline/deferredInit.ts+++ b/apps/server/src/services/aiAgent/pipeline/deferredInit.ts@@ -32,7 +32,7 @@ export type DeferredOperationInitDeps = Omit<* The share a visitor run was created under, re-read from its live row: the* init works under the share's CURRENT grants, never a snapshot of them — the* same rule `createShareRunScope` follows for every visitor turn. Fails closed:- * a share that is gone, no longer public or no longer this agent's ends the run.+ * a share that is gone, no longer admits the visitor or no longer this agent's ends the run.*/const resolveShareGate = async (deps: Pick<DeferredOperationInitDeps, 'db' | 'userId' | 'workspaceId'>,@@ -47,7 +47,7 @@ const resolveShareGate = async (!share ||share.agentId !== shareVisitor.agentId ||share.ownerId !== deps.userId ||- share.visibility !== 'link'+ !(await AgentShareModel.admitsVisitor(deps.db, share, shareVisitor.visitorUserId))) {throw new Error(`Share ${shareVisitor.shareId} no longer authorizes this run`);}diff --git a/apps/server/src/services/aiAgent/pipeline/turnSetup.ts b/apps/server/src/services/aiAgent/pipeline/turnSetup.tsindex b8093b098c3..9e626df926f 100644--- a/apps/server/src/services/aiAgent/pipeline/turnSetup.ts+++ b/apps/server/src/services/aiAgent/pipeline/turnSetup.ts@@ -708,6 +708,7 @@ export const setupTurn = async (db: deps.db,expectedShareId: shareGate.shareId,ownerId: deps.userId,+ visitorUserId: shareGate.visitorUserId,workspaceId: deps.workspaceId,},newTopicParams,diff --git a/apps/server/src/services/aiAgent/shareVisitorAbuseGuards.ts b/apps/server/src/services/aiAgent/shareVisitorAbuseGuards.tsindex ffded89db35..011aa5adee8 100644--- a/apps/server/src/services/aiAgent/shareVisitorAbuseGuards.ts+++ b/apps/server/src/services/aiAgent/shareVisitorAbuseGuards.ts@@ -32,10 +32,11 @@ const assertShareStillAuthorized = async (tx: LobeChatDatabase,agentId: string,expectedShareId: string,+ visitorUserId: string,workspaceId?: string,): Promise<void> => {const [share] = await tx- .select({ id: agentShares.id, visibility: agentShares.visibility })+ .select({ id: agentShares.id }).from(agentShares).innerJoin(agents, eq(agentShares.agentId, agents.id)).where(@@ -43,10 +44,11 @@ const assertShareStillAuthorized = async (eq(agentShares.agentId, agentId),eq(agentShares.id, expectedShareId),workspaceId ? eq(agents.workspaceId, workspaceId) : isNull(agents.workspaceId),+ AgentShareModel.admits(visitorUserId),),);- if (!share || share.visibility !== 'link' || share.id !== expectedShareId) {+ if (!share || share.id !== expectedShareId) {throw new TRPCError({ code: 'FORBIDDEN', message: 'This share is private' });}};@@ -74,9 +76,11 @@ export const reserveShareVisitorTopicOrThrow = async (params: {*/expectedShareId: string;ownerId: string;+ /** The visitor the topic is for: a `card` share admits only its grantees. */+ visitorUserId: string;workspaceId?: string;}): Promise<TopicItem> => {- const { agentId, create, db, expectedShareId, ownerId, workspaceId } = params;+ const { agentId, create, db, expectedShareId, ownerId, visitorUserId, workspaceId } = params;return db.transaction(async (trx) => {const tx = trx as unknown as LobeChatDatabase;@@ -93,7 +97,7 @@ export const reserveShareVisitorTopicOrThrow = async (params: {}// Fail closed BEFORE any row is written.- await assertShareStillAuthorized(tx, agentId, expectedShareId, workspaceId);+ await assertShareStillAuthorized(tx, agentId, expectedShareId, visitorUserId, workspaceId);return create(new TopicModel(tx, ownerId, workspaceId, undefined, { includeShareVisitor: true }),@@ -108,6 +112,7 @@ export const reserveShareVisitorTopic = (db: LobeChatDatabase;expectedShareId: string;ownerId: string;+ visitorUserId: string;workspaceId?: string;},createParams: CreateTopicParams,@@ -163,7 +168,7 @@ export const reserveShareVisitorTurnOrThrow = async (params: {}// Fail closed BEFORE any row is written.- await assertShareStillAuthorized(tx, agentId, expectedShareId, workspaceId);+ await assertShareStillAuthorized(tx, agentId, expectedShareId, visitorUserId, workspaceId);// Fresh read under the lock, not a caller-supplied value.const { maxMessagesPerVisitor } = await AgentShareModel.readCurrentVisitorCaps(tx, agentId);diff --git a/apps/server/src/services/channel/ChannelCoordinator.share.test.ts b/apps/server/src/services/channel/ChannelCoordinator.share.test.tsindex 54e99d9a6cb..0ebbfe50b06 100644--- a/apps/server/src/services/channel/ChannelCoordinator.share.test.ts+++ b/apps/server/src/services/channel/ChannelCoordinator.share.test.ts@@ -6,6 +6,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';import { ChannelCoordinator } from './ChannelCoordinator';const {+ admitsVisitor,checkSpend,countMessagesBySender,execAgent,@@ -34,6 +35,10 @@ const {recentContext: vi.fn(),retireReservation: vi.fn(),},+ // The grant lookup itself is the model's test; here a live share admits the requester.+ admitsVisitor: vi.fn(async (_db: unknown, share: { visibility: string }) =>+ ['card', 'link'].includes(share.visibility),+ ),findOperation: vi.fn(),findShare: vi.fn(),resolveChannelAttachments: vi.fn(),@@ -46,7 +51,9 @@ vi.mock('@/database/repositories/channel', () => ({}},}));-vi.mock('@/database/models/agentShare', () => ({ AgentShareModel: { findByShareId: findShare } }));+vi.mock('@/database/models/agentShare', () => ({+ AgentShareModel: { admitsVisitor, findByShareId: findShare },+}));vi.mock('@/database/models/agentOperation', () => ({AgentOperationModel: class {findById = findOperation;@@ -196,11 +203,30 @@ describe('dispatching a contact’s shared Agent', () => {expect(params.shareGate).toBeDefined();});+ it('runs a card-only share for a requester its owner granted it to', async () => {+ findShare.mockResolvedValue({ ...liveShare, visibility: 'card' });+ await coordinator().advance('channel');++ expect(admitsVisitor).toHaveBeenCalledWith(+ expect.anything(),+ expect.objectContaining({ visibility: 'card' }),+ expect.any(String),+ );+ expect(execAgent).toHaveBeenCalled();+ });+it.each([['the share was paused',() => findShare.mockResolvedValue({ ...liveShare, visibility: 'private' }),],+ [+ 'a card-only share no longer admits the requester',+ () => {+ findShare.mockResolvedValue({ ...liveShare, visibility: 'card' });+ admitsVisitor.mockResolvedValueOnce(false);+ },+ ],['the share moved to another owner',() => findShare.mockResolvedValue({ ...liveShare, ownerId: 'x' }),diff --git a/apps/server/src/services/channel/ChannelCoordinator.ts b/apps/server/src/services/channel/ChannelCoordinator.tsindex a4d06bdb809..4d179f552e1 100644--- a/apps/server/src/services/channel/ChannelCoordinator.ts+++ b/apps/server/src/services/channel/ChannelCoordinator.ts@@ -127,9 +127,9 @@ export class ChannelCoordinator {const share = await AgentShareModel.findByShareId(this.db, access.shareId);if (!share ||- share.visibility !== 'link' ||share.agentId !== agentId ||- share.ownerId !== access.ownerId+ share.ownerId !== access.ownerId ||+ !(await AgentShareModel.admitsVisitor(this.db, share, requesterId)))throw new Error('This Agent is no longer shared');if (request.length > SHARE_VISITOR_PROMPT_MAX_LENGTH)diff --git a/docs/development/database-schema.dbml b/docs/development/database-schema.dbmlindex 1c73741fc04..a52960504a5 100644--- a/docs/development/database-schema.dbml+++ b/docs/development/database-schema.dbml@@ -1188,6 +1188,20 @@ table agent_quota_windows {}}+table agent_share_grants {+ id uuid [pk, not null, default: `gen_random_uuid()`]+ share_id uuid [not null]+ user_id text [not null]+ source jsonb [not null]+ revoked_at "timestamp with time zone"+ created_at "timestamp with time zone" [not null, default: `now()`]++ indexes {+ (share_id, user_id) [name: 'agent_share_grants_share_user_unique', unique]+ user_id [name: 'agent_share_grants_user_id_idx']+ }+}+table agent_shares {id uuid [pk, not null, default: `gen_random_uuid()`]agent_id text [not null]diff --git a/packages/database/migrations/0226_agent_share_grants.sql b/packages/database/migrations/0226_agent_share_grants.sqlnew file mode 100644index 00000000000..9bf5acfcd4c--- /dev/null+++ b/packages/database/migrations/0226_agent_share_grants.sql@@ -0,0 +1,15 @@+CREATE TABLE IF NOT EXISTS "agent_share_grants" (+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,+ "share_id" uuid NOT NULL,+ "user_id" text NOT NULL,+ "source" jsonb NOT NULL,+ "revoked_at" timestamp with time zone,+ "created_at" timestamp with time zone DEFAULT now() NOT NULL+);+--> statement-breakpoint+ALTER TABLE "agent_share_grants" DROP CONSTRAINT IF EXISTS "agent_share_grants_share_id_agent_shares_id_fk";--> statement-breakpoint+ALTER TABLE "agent_share_grants" ADD CONSTRAINT "agent_share_grants_share_id_agent_shares_id_fk" FOREIGN KEY ("share_id") REFERENCES "public"."agent_shares"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint+ALTER TABLE "agent_share_grants" DROP CONSTRAINT IF EXISTS "agent_share_grants_user_id_users_id_fk";--> statement-breakpoint+ALTER TABLE "agent_share_grants" ADD CONSTRAINT "agent_share_grants_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint+CREATE UNIQUE INDEX IF NOT EXISTS "agent_share_grants_share_user_unique" ON "agent_share_grants" USING btree ("share_id","user_id");--> statement-breakpoint+CREATE INDEX IF NOT EXISTS "agent_share_grants_user_id_idx" ON "agent_share_grants" USING btree ("user_id");diff --git a/packages/database/migrations/meta/0216_snapshot.json b/packages/database/migrations/meta/0226_snapshot.jsonsimilarity index 94%rename from packages/database/migrations/meta/0216_snapshot.jsonrename to packages/database/migrations/meta/0226_snapshot.jsonindex 4dc75ba117f..4dd625f54f8 100644--- a/packages/database/migrations/meta/0216_snapshot.json+++ b/packages/database/migrations/meta/0226_snapshot.json@@ -6,9 +6,9 @@},"dialect": "postgresql","enums": {},- "id": "7c29d9b7-1cda-4670-a1a0-27ecc5cf0017",+ "id": "8ec85155-fd27-45c2-b98d-3c7910174744","policies": {},- "prevId": "7cbe8fa4-a70b-4460-89b2-8ba138152fc6",+ "prevId": "df89ac9e-890e-41f3-84cf-fe7c52d6c50e","roles": {},"schemas": {},"sequences": {@@ -2752,8 +2752,8 @@"checkConstraints": {},"isRLSEnabled": false},- "public.agent_documents": {- "name": "agent_documents",+ "public.agent_deliveries": {+ "name": "agent_deliveries","schema": "","columns": {"id": {@@ -2763,6 +2763,12 @@"notNull": true,"default": "gen_random_uuid()"},+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },"user_id": {"name": "user_id","type": "text",@@ -2775,103 +2781,170 @@"primaryKey": false,"notNull": false},- "agent_id": {- "name": "agent_id",+ "subject_type": {+ "name": "subject_type","type": "text","primaryKey": false,"notNull": true},- "document_id": {- "name": "document_id",- "type": "varchar(255)",+ "subject_id": {+ "name": "subject_id",+ "type": "text","primaryKey": false,"notNull": true},- "template_id": {- "name": "template_id",- "type": "varchar(100)",+ "parent_delivery_id": {+ "name": "parent_delivery_id",+ "type": "uuid","primaryKey": false,"notNull": false},- "access_self": {- "name": "access_self",- "type": "integer",+ "requester_user_id": {+ "name": "requester_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "channel_id": {+ "name": "channel_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "task_id": {+ "name": "task_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "summary": {+ "name": "summary",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "category": {+ "name": "category",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "outcome": {+ "name": "outcome",+ "type": "text","primaryKey": false,"notNull": true,- "default": 31+ "default": "'unknown'"},- "access_shared": {- "name": "access_shared",+ "outcome_source": {+ "name": "outcome_source",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "outcome_confidence": {+ "name": "outcome_confidence",+ "type": "real",+ "primaryKey": false,+ "notNull": false+ },+ "shots": {+ "name": "shots","type": "integer","primaryKey": false,- "notNull": true,- "default": 0+ "notNull": false},- "access_public": {- "name": "access_public",+ "frictions": {+ "name": "frictions",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "total_cost": {+ "name": "total_cost",+ "type": "numeric(20, 6)",+ "primaryKey": false,+ "notNull": false+ },+ "total_tokens": {+ "name": "total_tokens","type": "integer","primaryKey": false,- "notNull": true,- "default": 0+ "notNull": false},- "policy_load": {- "name": "policy_load",- "type": "varchar(30)",+ "tool_calls": {+ "name": "tool_calls",+ "type": "integer","primaryKey": false,- "notNull": true,- "default": "'always'"+ "notNull": false},- "policy": {- "name": "policy",- "type": "jsonb",+ "user_messages": {+ "name": "user_messages",+ "type": "integer","primaryKey": false,"notNull": false},- "policy_load_position": {- "name": "policy_load_position",- "type": "varchar(50)",+ "agent_messages": {+ "name": "agent_messages",+ "type": "integer","primaryKey": false,- "notNull": true,- "default": "'before-first-user'"+ "notNull": false},- "policy_load_format": {- "name": "policy_load_format",- "type": "varchar(20)",+ "duration_ms": {+ "name": "duration_ms",+ "type": "integer","primaryKey": false,- "notNull": true,- "default": "'raw'"+ "notNull": false},- "policy_load_rule": {- "name": "policy_load_rule",- "type": "varchar(50)",+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone","primaryKey": false,- "notNull": true,- "default": "'always'"+ "notNull": false},- "deleted_at": {- "name": "deleted_at",+ "delivered_at": {+ "name": "delivered_at","type": "timestamp with time zone","primaryKey": false,"notNull": false},- "deleted_by_user_id": {- "name": "deleted_by_user_id",- "type": "text",+ "settled_at": {+ "name": "settled_at",+ "type": "timestamp with time zone","primaryKey": false,"notNull": false},- "deleted_by_agent_id": {- "name": "deleted_by_agent_id",- "type": "text",+ "distilled_at": {+ "name": "distilled_at",+ "type": "timestamp with time zone","primaryKey": false,"notNull": false},- "delete_reason": {- "name": "delete_reason",- "type": "text",+ "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",@@ -2888,71 +2961,44 @@}},"indexes": {- "agent_documents_workspace_id_idx": {- "name": "agent_documents_workspace_id_idx",+ "agent_deliveries_subject_agent_unique": {+ "name": "agent_deliveries_subject_agent_unique","columns": [{- "expression": "workspace_id",+ "expression": "subject_type","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",+ "expression": "subject_id","isExpression": false,"asc": true,"nulls": "last"- }- ],- "isUnique": false,- "concurrently": false,- "method": "btree",- "with": {}- },- "agent_documents_deleted_by_user_id_idx": {- "name": "agent_documents_deleted_by_user_id_idx",- "columns": [+ },{- "expression": "deleted_by_user_id",+ "expression": "agent_id","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": false,+ "isUnique": true,"concurrently": false,"method": "btree","with": {}},- "agent_documents_agent_id_idx": {- "name": "agent_documents_agent_id_idx",+ "agent_deliveries_agent_id_settled_at_idx": {+ "name": "agent_deliveries_agent_id_settled_at_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",+ "expression": "settled_at","isExpression": false,"asc": true,"nulls": "last"@@ -2963,26 +3009,17 @@"method": "btree","with": {}},- "agent_documents_access_shared_idx": {- "name": "agent_documents_access_shared_idx",+ "agent_deliveries_user_id_settled_at_idx": {+ "name": "agent_deliveries_user_id_settled_at_idx","columns": [{- "expression": "access_shared",+ "expression": "user_id","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",+ "expression": "settled_at","isExpression": false,"asc": true,"nulls": "last"@@ -2993,149 +3030,247 @@"method": "btree","with": {}},- "agent_documents_policy_load_idx": {- "name": "agent_documents_policy_load_idx",+ "agent_deliveries_workspace_id_settled_at_idx": {+ "name": "agent_deliveries_workspace_id_settled_at_idx","columns": [{- "expression": "policy_load",+ "expression": "workspace_id","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",+ "expression": "settled_at","isExpression": false,"asc": true,"nulls": "last"}],"isUnique": false,+ "where": "\"agent_deliveries\".\"workspace_id\" IS NOT NULL","concurrently": false,"method": "btree","with": {}},- "agent_documents_policy_load_position_idx": {- "name": "agent_documents_policy_load_position_idx",+ "agent_deliveries_parent_delivery_id_idx": {+ "name": "agent_deliveries_parent_delivery_id_idx","columns": [{- "expression": "policy_load_position",+ "expression": "parent_delivery_id","isExpression": false,"asc": true,"nulls": "last"}],"isUnique": false,+ "where": "\"agent_deliveries\".\"parent_delivery_id\" IS NOT NULL","concurrently": false,"method": "btree","with": {}},- "agent_documents_policy_load_format_idx": {- "name": "agent_documents_policy_load_format_idx",+ "agent_deliveries_project_id_idx": {+ "name": "agent_deliveries_project_id_idx","columns": [{- "expression": "policy_load_format",+ "expression": "project_id","isExpression": false,"asc": true,"nulls": "last"}],"isUnique": false,+ "where": "\"agent_deliveries\".\"project_id\" IS NOT NULL","concurrently": false,"method": "btree","with": {}},- "agent_documents_policy_load_rule_idx": {- "name": "agent_documents_policy_load_rule_idx",+ "agent_deliveries_task_id_idx": {+ "name": "agent_deliveries_task_id_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",+ "expression": "task_id","isExpression": false,"asc": true,"nulls": "last"}],"isUnique": false,+ "where": "\"agent_deliveries\".\"task_id\" IS NOT NULL","concurrently": false,"method": "btree","with": {}+ }+ },+ "foreignKeys": {+ "agent_deliveries_agent_id_agents_id_fk": {+ "name": "agent_deliveries_agent_id_agents_id_fk",+ "tableFrom": "agent_deliveries",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"},- "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_deliveries_user_id_users_id_fk": {+ "name": "agent_deliveries_user_id_users_id_fk",+ "tableFrom": "agent_deliveries",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"},- "agent_documents_agent_autoload_deleted_idx": {- "name": "agent_documents_agent_autoload_deleted_idx",+ "agent_deliveries_workspace_id_workspaces_id_fk": {+ "name": "agent_deliveries_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_deliveries",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_deliveries_parent_delivery_id_agent_deliveries_id_fk": {+ "name": "agent_deliveries_parent_delivery_id_agent_deliveries_id_fk",+ "tableFrom": "agent_deliveries",+ "tableTo": "agent_deliveries",+ "columnsFrom": ["parent_delivery_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_deliveries_requester_user_id_users_id_fk": {+ "name": "agent_deliveries_requester_user_id_users_id_fk",+ "tableFrom": "agent_deliveries",+ "tableTo": "users",+ "columnsFrom": ["requester_user_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_deliveries_project_id_projects_id_fk": {+ "name": "agent_deliveries_project_id_projects_id_fk",+ "tableFrom": "agent_deliveries",+ "tableTo": "projects",+ "columnsFrom": ["project_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_deliveries_channel_id_channels_id_fk": {+ "name": "agent_deliveries_channel_id_channels_id_fk",+ "tableFrom": "agent_deliveries",+ "tableTo": "channels",+ "columnsFrom": ["channel_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_deliveries_task_id_tasks_id_fk": {+ "name": "agent_deliveries_task_id_tasks_id_fk",+ "tableFrom": "agent_deliveries",+ "tableTo": "tasks",+ "columnsFrom": ["task_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_delivery_works": {+ "name": "agent_delivery_works",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "delivery_id": {+ "name": "delivery_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "work_id": {+ "name": "work_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+ },+ "work_version_id": {+ "name": "work_version_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": {+ "agent_delivery_works_delivery_id_work_id_unique": {+ "name": "agent_delivery_works_delivery_id_work_id_unique","columns": [{- "expression": "agent_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "deleted_at",+ "expression": "delivery_id","isExpression": false,"asc": true,"nulls": "last"},{- "expression": "policy_load",+ "expression": "work_id","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": false,+ "isUnique": true,"concurrently": false,"method": "btree","with": {}},- "agent_documents_document_id_idx": {- "name": "agent_documents_document_id_idx",+ "agent_delivery_works_work_id_idx": {+ "name": "agent_delivery_works_work_id_idx","columns": [{- "expression": "document_id",+ "expression": "work_id","isExpression": false,"asc": true,"nulls": "last"@@ -3146,85 +3281,56 @@"method": "btree","with": {}},- "agent_documents_agent_document_user_unique": {- "name": "agent_documents_agent_document_user_unique",+ "agent_delivery_works_workspace_id_idx": {+ "name": "agent_delivery_works_workspace_id_idx","columns": [{- "expression": "agent_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "document_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "user_id",+ "expression": "workspace_id","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": true,+ "isUnique": false,+ "where": "\"agent_delivery_works\".\"workspace_id\" IS NOT NULL","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"],+ "agent_delivery_works_delivery_id_agent_deliveries_id_fk": {+ "name": "agent_delivery_works_delivery_id_agent_deliveries_id_fk",+ "tableFrom": "agent_delivery_works",+ "tableTo": "agent_deliveries",+ "columnsFrom": ["delivery_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"],+ "agent_delivery_works_work_id_works_id_fk": {+ "name": "agent_delivery_works_work_id_works_id_fk",+ "tableFrom": "agent_delivery_works",+ "tableTo": "works",+ "columnsFrom": ["work_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"],+ "agent_delivery_works_workspace_id_workspaces_id_fk": {+ "name": "agent_delivery_works_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_delivery_works",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_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"],+ "agent_delivery_works_work_version_id_work_versions_id_fk": {+ "name": "agent_delivery_works_work_version_id_work_versions_id_fk",+ "tableFrom": "agent_delivery_works",+ "tableTo": "work_versions",+ "columnsFrom": ["work_version_id"],"columnsTo": ["id"],"onDelete": "set null","onUpdate": "no action"@@ -3236,8 +3342,8 @@"checkConstraints": {},"isRLSEnabled": false},- "public.agent_eval_memories": {- "name": "agent_eval_memories",+ "public.agent_documents": {+ "name": "agent_documents","schema": "","columns": {"id": {@@ -3259,121 +3365,103 @@"primaryKey": false,"notNull": false},- "run_id": {- "name": "run_id",+ "agent_id": {+ "name": "agent_id","type": "text","primaryKey": false,"notNull": true},- "topic_id": {- "name": "topic_id",- "type": "text",+ "document_id": {+ "name": "document_id",+ "type": "varchar(255)","primaryKey": false,- "notNull": false+ "notNull": true},- "thread_id": {- "name": "thread_id",- "type": "text",+ "template_id": {+ "name": "template_id",+ "type": "varchar(100)","primaryKey": false,"notNull": false},- "attempt_id": {- "name": "attempt_id",- "type": "text",+ "access_self": {+ "name": "access_self",+ "type": "integer","primaryKey": false,- "notNull": true- },- "layer": {- "name": "layer",- "type": "text",- "primaryKey": false,- "notNull": true+ "notNull": true,+ "default": 31},- "source": {- "name": "source",- "type": "text",+ "access_shared": {+ "name": "access_shared",+ "type": "integer","primaryKey": false,- "notNull": true+ "notNull": true,+ "default": 0},- "fixture_hash": {- "name": "fixture_hash",- "type": "text",+ "access_public": {+ "name": "access_public",+ "type": "integer","primaryKey": false,- "notNull": false+ "notNull": true,+ "default": 0},- "title": {- "name": "title",- "type": "text",+ "policy_load": {+ "name": "policy_load",+ "type": "varchar(30)","primaryKey": false,- "notNull": false+ "notNull": true,+ "default": "'always'"},- "summary": {- "name": "summary",- "type": "text",+ "policy": {+ "name": "policy",+ "type": "jsonb","primaryKey": false,"notNull": false},- "details": {- "name": "details",- "type": "text",+ "policy_load_position": {+ "name": "policy_load_position",+ "type": "varchar(50)","primaryKey": false,- "notNull": false+ "notNull": true,+ "default": "'before-first-user'"},- "memory_category": {- "name": "memory_category",- "type": "text",+ "policy_load_format": {+ "name": "policy_load_format",+ "type": "varchar(20)","primaryKey": false,- "notNull": false+ "notNull": true,+ "default": "'raw'"},- "memory_type": {- "name": "memory_type",- "type": "text",+ "policy_load_rule": {+ "name": "policy_load_rule",+ "type": "varchar(50)","primaryKey": false,- "notNull": false+ "notNull": true,+ "default": "'always'"},- "tags": {- "name": "tags",- "type": "jsonb",+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone","primaryKey": false,"notNull": false},- "payload": {- "name": "payload",- "type": "jsonb",- "primaryKey": false,- "notNull": true- },- "embedding": {- "name": "embedding",- "type": "vector(1024)",+ "deleted_by_user_id": {+ "name": "deleted_by_user_id",+ "type": "text","primaryKey": false,"notNull": false},- "captured_at": {- "name": "captured_at",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true- },- "removed_reason": {- "name": "removed_reason",+ "deleted_by_agent_id": {+ "name": "deleted_by_agent_id","type": "text","primaryKey": false,"notNull": false},- "metadata": {- "name": "metadata",- "type": "jsonb",+ "delete_reason": {+ "name": "delete_reason",+ "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",@@ -3390,11 +3478,11 @@}},"indexes": {- "agent_eval_memories_attempt_id_idx": {- "name": "agent_eval_memories_attempt_id_idx",+ "agent_documents_workspace_id_idx": {+ "name": "agent_documents_workspace_id_idx","columns": [{- "expression": "attempt_id",+ "expression": "workspace_id","isExpression": false,"asc": true,"nulls": "last"@@ -3405,11 +3493,11 @@"method": "btree","with": {}},- "agent_eval_memories_run_id_idx": {- "name": "agent_eval_memories_run_id_idx",+ "agent_documents_user_id_idx": {+ "name": "agent_documents_user_id_idx","columns": [{- "expression": "run_id",+ "expression": "user_id","isExpression": false,"asc": true,"nulls": "last"@@ -3420,11 +3508,11 @@"method": "btree","with": {}},- "agent_eval_memories_topic_id_idx": {- "name": "agent_eval_memories_topic_id_idx",+ "agent_documents_deleted_by_user_id_idx": {+ "name": "agent_documents_deleted_by_user_id_idx","columns": [{- "expression": "topic_id",+ "expression": "deleted_by_user_id","isExpression": false,"asc": true,"nulls": "last"@@ -3435,11 +3523,11 @@"method": "btree","with": {}},- "agent_eval_memories_thread_id_idx": {- "name": "agent_eval_memories_thread_id_idx",+ "agent_documents_agent_id_idx": {+ "name": "agent_documents_agent_id_idx","columns": [{- "expression": "thread_id",+ "expression": "agent_id","isExpression": false,"asc": true,"nulls": "last"@@ -3450,11 +3538,11 @@"method": "btree","with": {}},- "agent_eval_memories_user_id_idx": {- "name": "agent_eval_memories_user_id_idx",+ "agent_documents_access_self_idx": {+ "name": "agent_documents_access_self_idx","columns": [{- "expression": "user_id",+ "expression": "access_self","isExpression": false,"asc": true,"nulls": "last"@@ -3465,11 +3553,11 @@"method": "btree","with": {}},- "agent_eval_memories_workspace_id_idx": {- "name": "agent_eval_memories_workspace_id_idx",+ "agent_documents_access_shared_idx": {+ "name": "agent_documents_access_shared_idx","columns": [{- "expression": "workspace_id",+ "expression": "access_shared","isExpression": false,"asc": true,"nulls": "last"@@ -3479,176 +3567,123 @@"concurrently": false,"method": "btree","with": {}- }- },- "foreignKeys": {- "agent_eval_memories_user_id_users_id_fk": {- "name": "agent_eval_memories_user_id_users_id_fk",- "tableFrom": "agent_eval_memories",- "tableTo": "users",- "columnsFrom": ["user_id"],- "columnsTo": ["id"],- "onDelete": "cascade",- "onUpdate": "no action"- },- "agent_eval_memories_workspace_id_workspaces_id_fk": {- "name": "agent_eval_memories_workspace_id_workspaces_id_fk",- "tableFrom": "agent_eval_memories",- "tableTo": "workspaces",- "columnsFrom": ["workspace_id"],- "columnsTo": ["id"],- "onDelete": "cascade",- "onUpdate": "no action"- },- "agent_eval_memories_run_id_agent_eval_runs_id_fk": {- "name": "agent_eval_memories_run_id_agent_eval_runs_id_fk",- "tableFrom": "agent_eval_memories",- "tableTo": "agent_eval_runs",- "columnsFrom": ["run_id"],- "columnsTo": ["id"],- "onDelete": "cascade",- "onUpdate": "no action"},- "agent_eval_memories_topic_id_topics_id_fk": {- "name": "agent_eval_memories_topic_id_topics_id_fk",- "tableFrom": "agent_eval_memories",- "tableTo": "topics",- "columnsFrom": ["topic_id"],- "columnsTo": ["id"],- "onDelete": "set null",- "onUpdate": "no action"+ "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_eval_memories_thread_id_threads_id_fk": {- "name": "agent_eval_memories_thread_id_threads_id_fk",- "tableFrom": "agent_eval_memories",- "tableTo": "threads",- "columnsFrom": ["thread_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+ "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": {}},- "identifier": {- "name": "identifier",- "type": "text",- "primaryKey": false,- "notNull": true+ "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": {}},- "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+ "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": {}},- "accessed_at": {- "name": "accessed_at",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"+ "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": {}},- "created_at": {- "name": "created_at",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"+ "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": {}},- "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",+ "agent_documents_agent_load_position_idx": {+ "name": "agent_documents_agent_load_position_idx","columns": [{- "expression": "identifier",+ "expression": "agent_id","isExpression": false,"asc": true,"nulls": "last"},{- "expression": "user_id",+ "expression": "policy_load_position","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": true,- "where": "\"agent_eval_benchmarks\".\"workspace_id\" is null",+ "isUnique": false,"concurrently": false,"method": "btree","with": {}},- "agent_eval_benchmarks_is_system_idx": {- "name": "agent_eval_benchmarks_is_system_idx",+ "agent_documents_deleted_at_idx": {+ "name": "agent_documents_deleted_at_idx","columns": [{- "expression": "is_system",+ "expression": "deleted_at","isExpression": false,"asc": true,"nulls": "last"@@ -3659,11 +3694,23 @@"method": "btree","with": {}},- "agent_eval_benchmarks_user_id_idx": {- "name": "agent_eval_benchmarks_user_id_idx",+ "agent_documents_agent_autoload_deleted_idx": {+ "name": "agent_documents_agent_autoload_deleted_idx","columns": [{- "expression": "user_id",+ "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"@@ -3674,11 +3721,11 @@"method": "btree","with": {}},- "agent_eval_benchmarks_workspace_id_idx": {- "name": "agent_eval_benchmarks_workspace_id_idx",+ "agent_documents_document_id_idx": {+ "name": "agent_documents_document_id_idx","columns": [{- "expression": "workspace_id",+ "expression": "document_id","isExpression": false,"asc": true,"nulls": "last"@@ -3689,47 +3736,88 @@"method": "btree","with": {}},- "agent_eval_benchmarks_identifier_workspace_id_unique": {- "name": "agent_eval_benchmarks_identifier_workspace_id_unique",+ "agent_documents_agent_document_user_unique": {+ "name": "agent_documents_agent_document_user_unique","columns": [{- "expression": "workspace_id",+ "expression": "agent_id","isExpression": false,"asc": true,"nulls": "last"},{- "expression": "identifier",+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id","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",+ "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_eval_benchmarks_workspace_id_workspaces_id_fk": {- "name": "agent_eval_benchmarks_workspace_id_workspaces_id_fk",- "tableFrom": "agent_eval_benchmarks",+ "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": {},@@ -3738,68 +3826,129 @@"checkConstraints": {},"isRLSEnabled": false},- "public.agent_eval_datasets": {- "name": "agent_eval_datasets",+ "public.agent_eval_memories": {+ "name": "agent_eval_memories","schema": "","columns": {"id": {"name": "id",- "type": "text",+ "type": "uuid","primaryKey": true,- "notNull": true+ "notNull": true,+ "default": "gen_random_uuid()"},- "benchmark_id": {- "name": "benchmark_id",+ "user_id": {+ "name": "user_id","type": "text","primaryKey": false,- "notNull": false+ "notNull": true},- "source_experiment_id": {- "name": "source_experiment_id",+ "workspace_id": {+ "name": "workspace_id","type": "text","primaryKey": false,"notNull": false},- "identifier": {- "name": "identifier",+ "run_id": {+ "name": "run_id","type": "text","primaryKey": false,"notNull": true},- "user_id": {- "name": "user_id",+ "topic_id": {+ "name": "topic_id","type": "text","primaryKey": false,"notNull": false},- "workspace_id": {- "name": "workspace_id",+ "thread_id": {+ "name": "thread_id","type": "text","primaryKey": false,"notNull": false},- "name": {- "name": "name",+ "attempt_id": {+ "name": "attempt_id","type": "text","primaryKey": false,"notNull": true},- "description": {- "name": "description",+ "layer": {+ "name": "layer","type": "text","primaryKey": false,- "notNull": false+ "notNull": true},- "eval_mode": {- "name": "eval_mode",+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "fixture_hash": {+ "name": "fixture_hash","type": "text","primaryKey": false,"notNull": false},- "eval_config": {- "name": "eval_config",+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "summary": {+ "name": "summary",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "details": {+ "name": "details",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "memory_category": {+ "name": "memory_category",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "memory_type": {+ "name": "memory_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "tags": {+ "name": "tags",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "payload": {+ "name": "payload","type": "jsonb","primaryKey": false,+ "notNull": true+ },+ "embedding": {+ "name": "embedding",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "removed_reason": {+ "name": "removed_reason",+ "type": "text",+ "primaryKey": false,"notNull": false},"metadata": {@@ -3831,33 +3980,26 @@}},"indexes": {- "agent_eval_datasets_identifier_user_id_unique": {- "name": "agent_eval_datasets_identifier_user_id_unique",+ "agent_eval_memories_attempt_id_idx": {+ "name": "agent_eval_memories_attempt_id_idx","columns": [{- "expression": "identifier",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "user_id",+ "expression": "attempt_id","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": true,- "where": "\"agent_eval_datasets\".\"workspace_id\" is null",+ "isUnique": false,"concurrently": false,"method": "btree","with": {}},- "agent_eval_datasets_benchmark_id_idx": {- "name": "agent_eval_datasets_benchmark_id_idx",+ "agent_eval_memories_run_id_idx": {+ "name": "agent_eval_memories_run_id_idx","columns": [{- "expression": "benchmark_id",+ "expression": "run_id","isExpression": false,"asc": true,"nulls": "last"@@ -3868,11 +4010,11 @@"method": "btree","with": {}},- "agent_eval_datasets_source_experiment_id_idx": {- "name": "agent_eval_datasets_source_experiment_id_idx",+ "agent_eval_memories_topic_id_idx": {+ "name": "agent_eval_memories_topic_id_idx","columns": [{- "expression": "source_experiment_id",+ "expression": "topic_id","isExpression": false,"asc": true,"nulls": "last"@@ -3883,11 +4025,11 @@"method": "btree","with": {}},- "agent_eval_datasets_user_id_idx": {- "name": "agent_eval_datasets_user_id_idx",+ "agent_eval_memories_thread_id_idx": {+ "name": "agent_eval_memories_thread_id_idx","columns": [{- "expression": "user_id",+ "expression": "thread_id","isExpression": false,"asc": true,"nulls": "last"@@ -3898,11 +4040,11 @@"method": "btree","with": {}},- "agent_eval_datasets_workspace_id_idx": {- "name": "agent_eval_datasets_workspace_id_idx",+ "agent_eval_memories_user_id_idx": {+ "name": "agent_eval_memories_user_id_idx","columns": [{- "expression": "workspace_id",+ "expression": "user_id","isExpression": false,"asc": true,"nulls": "last"@@ -3913,64 +4055,66 @@"method": "btree","with": {}},- "agent_eval_datasets_identifier_workspace_id_unique": {- "name": "agent_eval_datasets_identifier_workspace_id_unique",+ "agent_eval_memories_workspace_id_idx": {+ "name": "agent_eval_memories_workspace_id_idx","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",+ "isUnique": false,"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"],+ "agent_eval_memories_user_id_users_id_fk": {+ "name": "agent_eval_memories_user_id_users_id_fk",+ "tableFrom": "agent_eval_memories",+ "tableTo": "users",+ "columnsFrom": ["user_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"],+ "agent_eval_memories_workspace_id_workspaces_id_fk": {+ "name": "agent_eval_memories_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_eval_memories",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],"columnsTo": ["id"],- "onDelete": "set null",+ "onDelete": "cascade","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"],+ "agent_eval_memories_run_id_agent_eval_runs_id_fk": {+ "name": "agent_eval_memories_run_id_agent_eval_runs_id_fk",+ "tableFrom": "agent_eval_memories",+ "tableTo": "agent_eval_runs",+ "columnsFrom": ["run_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"],+ "agent_eval_memories_topic_id_topics_id_fk": {+ "name": "agent_eval_memories_topic_id_topics_id_fk",+ "tableFrom": "agent_eval_memories",+ "tableTo": "topics",+ "columnsFrom": ["topic_id"],"columnsTo": ["id"],- "onDelete": "cascade",+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_eval_memories_thread_id_threads_id_fk": {+ "name": "agent_eval_memories_thread_id_threads_id_fk",+ "tableFrom": "agent_eval_memories",+ "tableTo": "threads",+ "columnsFrom": ["thread_id"],+ "columnsTo": ["id"],+ "onDelete": "set null","onUpdate": "no action"}},@@ -3980,34 +4124,21 @@"checkConstraints": {},"isRLSEnabled": false},- "public.agent_eval_environments": {- "name": "agent_eval_environments",+ "public.agent_eval_benchmarks": {+ "name": "agent_eval_benchmarks","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": false- },- "workspace_id": {- "name": "workspace_id","type": "text",- "primaryKey": false,- "notNull": false+ "primaryKey": true,+ "notNull": true},"identifier": {"name": "identifier","type": "text","primaryKey": false,- "notNull": false+ "notNull": true},"name": {"name": "name",@@ -4021,18 +4152,43 @@"primaryKey": false,"notNull": false},- "config": {- "name": "config",+ "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",@@ -4056,9 +4212,15 @@}},"indexes": {- "agent_eval_environments_user_id_idx": {- "name": "agent_eval_environments_user_id_idx",+ "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,@@ -4066,16 +4228,17 @@"nulls": "last"}],- "isUnique": false,+ "isUnique": true,+ "where": "\"agent_eval_benchmarks\".\"workspace_id\" is null","concurrently": false,"method": "btree","with": {}},- "agent_eval_environments_workspace_id_idx": {- "name": "agent_eval_environments_workspace_id_idx",+ "agent_eval_benchmarks_is_system_idx": {+ "name": "agent_eval_benchmarks_is_system_idx","columns": [{- "expression": "workspace_id",+ "expression": "is_system","isExpression": false,"asc": true,"nulls": "last"@@ -4086,15 +4249,9 @@"method": "btree","with": {}},- "agent_eval_environments_identifier_user_id_unique": {- "name": "agent_eval_environments_identifier_user_id_unique",+ "agent_eval_benchmarks_user_id_idx": {+ "name": "agent_eval_benchmarks_user_id_idx","columns": [- {- "expression": "identifier",- "isExpression": false,- "asc": true,- "nulls": "last"- },{"expression": "user_id","isExpression": false,@@ -4102,48 +4259,62 @@"nulls": "last"}],- "isUnique": true,- "where": "\"agent_eval_environments\".\"identifier\" IS NOT NULL AND \"agent_eval_environments\".\"workspace_id\" IS NULL",+ "isUnique": false,"concurrently": false,"method": "btree","with": {}},- "agent_eval_environments_identifier_workspace_id_unique": {- "name": "agent_eval_environments_identifier_workspace_id_unique",+ "agent_eval_benchmarks_workspace_id_idx": {+ "name": "agent_eval_benchmarks_workspace_id_idx","columns": [{- "expression": "identifier",+ "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_environments\".\"identifier\" IS NOT NULL AND \"agent_eval_environments\".\"workspace_id\" IS NOT NULL",+ "where": "\"agent_eval_benchmarks\".\"workspace_id\" is not null","concurrently": false,"method": "btree","with": {}}},"foreignKeys": {- "agent_eval_environments_user_id_users_id_fk": {- "name": "agent_eval_environments_user_id_users_id_fk",- "tableFrom": "agent_eval_environments",+ "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_environments_workspace_id_workspaces_id_fk": {- "name": "agent_eval_environments_workspace_id_workspaces_id_fk",- "tableFrom": "agent_eval_environments",+ "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"],@@ -4157,27 +4328,39 @@"checkConstraints": {},"isRLSEnabled": false},- "public.agent_eval_experiment_benchmarks": {- "name": "agent_eval_experiment_benchmarks",+ "public.agent_eval_datasets": {+ "name": "agent_eval_datasets","schema": "","columns": {- "experiment_id": {- "name": "experiment_id",+ "id": {+ "name": "id","type": "text",- "primaryKey": false,+ "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": true+ "notNull": false},"workspace_id": {"name": "workspace_id",@@ -4185,17 +4368,83 @@"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_experiment_benchmarks_benchmark_id_idx": {- "name": "agent_eval_experiment_benchmarks_benchmark_id_idx",+ "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",@@ -4209,8 +4458,23 @@"method": "btree","with": {}},- "agent_eval_experiment_benchmarks_user_id_idx": {- "name": "agent_eval_experiment_benchmarks_user_id_idx",+ "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",@@ -4224,8 +4488,8 @@"method": "btree","with": {}},- "agent_eval_experiment_benchmarks_workspace_id_idx": {- "name": "agent_eval_experiment_benchmarks_workspace_id_idx",+ "agent_eval_datasets_workspace_id_idx": {+ "name": "agent_eval_datasets_workspace_id_idx","columns": [{"expression": "workspace_id",@@ -4238,39 +4502,61 @@"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_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"],+ "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_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"],+ "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": "cascade",+ "onDelete": "set null","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",+ "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_experiment_benchmarks_workspace_id_workspaces_id_fk": {- "name": "agent_eval_experiment_benchmarks_workspace_id_workspaces_id_fk",- "tableFrom": "agent_eval_experiment_benchmarks",+ "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"],@@ -4278,32 +4564,28 @@"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"]- }- },+ "compositePrimaryKeys": {},"uniqueConstraints": {},"policies": {},"checkConstraints": {},"isRLSEnabled": false},- "public.agent_eval_experiments": {- "name": "agent_eval_experiments",+ "public.agent_eval_environments": {+ "name": "agent_eval_environments","schema": "","columns": {"id": {"name": "id",- "type": "text",+ "type": "uuid","primaryKey": true,- "notNull": true+ "notNull": true,+ "default": "gen_random_uuid()"},"user_id": {"name": "user_id","type": "text","primaryKey": false,- "notNull": true+ "notNull": false},"workspace_id": {"name": "workspace_id",@@ -4311,6 +4593,12 @@"primaryKey": false,"notNull": false},+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },"name": {"name": "name","type": "text",@@ -4323,6 +4611,12 @@"primaryKey": false,"notNull": false},+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },"metadata": {"name": "metadata","type": "jsonb",@@ -4352,8 +4646,8 @@}},"indexes": {- "agent_eval_experiments_user_id_idx": {- "name": "agent_eval_experiments_user_id_idx",+ "agent_eval_environments_user_id_idx": {+ "name": "agent_eval_environments_user_id_idx","columns": [{"expression": "user_id",@@ -4367,8 +4661,8 @@"method": "btree","with": {}},- "agent_eval_experiments_workspace_id_idx": {- "name": "agent_eval_experiments_workspace_id_idx",+ "agent_eval_environments_workspace_id_idx": {+ "name": "agent_eval_environments_workspace_id_idx","columns": [{"expression": "workspace_id",@@ -4381,21 +4675,65 @@"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"],+ },+ "agent_eval_environments_identifier_user_id_unique": {+ "name": "agent_eval_environments_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_environments\".\"identifier\" IS NOT NULL AND \"agent_eval_environments\".\"workspace_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_environments_identifier_workspace_id_unique": {+ "name": "agent_eval_environments_identifier_workspace_id_unique",+ "columns": [+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_eval_environments\".\"identifier\" IS NOT NULL AND \"agent_eval_environments\".\"workspace_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_eval_environments_user_id_users_id_fk": {+ "name": "agent_eval_environments_user_id_users_id_fk",+ "tableFrom": "agent_eval_environments",+ "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",+ "agent_eval_environments_workspace_id_workspaces_id_fk": {+ "name": "agent_eval_environments_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_eval_environments","tableTo": "workspaces","columnsFrom": ["workspace_id"],"columnsTo": ["id"],@@ -4409,64 +4747,34 @@"checkConstraints": {},"isRLSEnabled": false},- "public.agent_eval_run_topics": {- "name": "agent_eval_run_topics",+ "public.agent_eval_experiment_benchmarks": {+ "name": "agent_eval_experiment_benchmarks","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",+ "experiment_id": {+ "name": "experiment_id","type": "text","primaryKey": false,"notNull": true},- "topic_id": {- "name": "topic_id",+ "benchmark_id": {+ "name": "benchmark_id","type": "text","primaryKey": false,"notNull": true},- "test_case_id": {- "name": "test_case_id",+ "user_id": {+ "name": "user_id","type": "text","primaryKey": false,"notNull": true},- "status": {- "name": "status",+ "workspace_id": {+ "name": "workspace_id","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",@@ -4476,26 +4784,11 @@}},"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",+ "agent_eval_experiment_benchmarks_benchmark_id_idx": {+ "name": "agent_eval_experiment_benchmarks_benchmark_id_idx","columns": [{- "expression": "run_id",+ "expression": "benchmark_id","isExpression": false,"asc": true,"nulls": "last"@@ -4506,11 +4799,11 @@"method": "btree","with": {}},- "agent_eval_run_topics_test_case_id_idx": {- "name": "agent_eval_run_topics_test_case_id_idx",+ "agent_eval_experiment_benchmarks_user_id_idx": {+ "name": "agent_eval_experiment_benchmarks_user_id_idx","columns": [{- "expression": "test_case_id",+ "expression": "user_id","isExpression": false,"asc": true,"nulls": "last"@@ -4521,8 +4814,8 @@"method": "btree","with": {}},- "agent_eval_run_topics_workspace_id_idx": {- "name": "agent_eval_run_topics_workspace_id_idx",+ "agent_eval_experiment_benchmarks_workspace_id_idx": {+ "name": "agent_eval_experiment_benchmarks_workspace_id_idx","columns": [{"expression": "workspace_id",@@ -4538,56 +4831,47 @@}},"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"],+ "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_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"],+ "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_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"],+ "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_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"],+ "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_run_topics_run_id_topic_id_pk": {- "name": "agent_eval_run_topics_run_id_topic_id_pk",- "columns": ["run_id", "topic_id"]+ "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": {},@@ -4595,8 +4879,8 @@"checkConstraints": {},"isRLSEnabled": false},- "public.agent_eval_runs": {- "name": "agent_eval_runs",+ "public.agent_eval_experiments": {+ "name": "agent_eval_experiments","schema": "","columns": {"id": {@@ -4605,30 +4889,6 @@"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",@@ -4645,33 +4905,20 @@"name": "name","type": "text","primaryKey": false,- "notNull": false+ "notNull": true},- "status": {- "name": "status",+ "description": {+ "name": "description","type": "text","primaryKey": false,- "notNull": true,- "default": "'idle'"- },- "config": {- "name": "config",- "type": "jsonb",- "primaryKey": false,"notNull": false},- "metrics": {- "name": "metrics",+ "metadata": {+ "name": "metadata","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",@@ -4695,11 +4942,11 @@}},"indexes": {- "agent_eval_runs_dataset_id_idx": {- "name": "agent_eval_runs_dataset_id_idx",+ "agent_eval_experiments_user_id_idx": {+ "name": "agent_eval_experiments_user_id_idx","columns": [{- "expression": "dataset_id",+ "expression": "user_id","isExpression": false,"asc": true,"nulls": "last"@@ -4710,83 +4957,8 @@"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",+ "agent_eval_experiments_workspace_id_idx": {+ "name": "agent_eval_experiments_workspace_id_idx","columns": [{"expression": "workspace_id",@@ -4802,59 +4974,23 @@}},"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",+ "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_runs_workspace_id_workspaces_id_fk": {- "name": "agent_eval_runs_workspace_id_workspaces_id_fk",- "tableFrom": "agent_eval_runs",+ "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"- },- "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": {},@@ -4863,21 +4999,15 @@"checkConstraints": {},"isRLSEnabled": false},- "public.agent_eval_test_cases": {- "name": "agent_eval_test_cases",+ "public.agent_eval_run_topics": {+ "name": "agent_eval_run_topics","schema": "","columns": {- "id": {- "name": "id",- "type": "text",- "primaryKey": true,- "notNull": true- },"user_id": {"name": "user_id","type": "text","primaryKey": false,- "notNull": false+ "notNull": true},"workspace_id": {"name": "workspace_id",@@ -4885,73 +5015,59 @@"primaryKey": false,"notNull": false},- "dataset_id": {- "name": "dataset_id",+ "run_id": {+ "name": "run_id","type": "text","primaryKey": false,"notNull": true},- "environment_id": {- "name": "environment_id",- "type": "uuid",+ "topic_id": {+ "name": "topic_id",+ "type": "text","primaryKey": false,- "notNull": false+ "notNull": true},- "content": {- "name": "content",- "type": "jsonb",+ "test_case_id": {+ "name": "test_case_id",+ "type": "text","primaryKey": false,"notNull": true},- "eval_mode": {- "name": "eval_mode",+ "status": {+ "name": "status","type": "text","primaryKey": false,"notNull": false},- "eval_config": {- "name": "eval_config",- "type": "jsonb",+ "score": {+ "name": "score",+ "type": "real","primaryKey": false,"notNull": false},- "metadata": {- "name": "metadata",- "type": "jsonb",+ "passed": {+ "name": "passed",+ "type": "boolean","primaryKey": false,"notNull": false},- "sort_order": {- "name": "sort_order",- "type": "integer",+ "eval_result": {+ "name": "eval_result",+ "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_test_cases_user_id_idx": {- "name": "agent_eval_test_cases_user_id_idx",+ "agent_eval_run_topics_user_id_idx": {+ "name": "agent_eval_run_topics_user_id_idx","columns": [{"expression": "user_id",@@ -4965,26 +5081,11 @@"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_environment_id_idx": {- "name": "agent_eval_test_cases_environment_id_idx",+ "agent_eval_run_topics_run_id_idx": {+ "name": "agent_eval_run_topics_run_id_idx","columns": [{- "expression": "environment_id",+ "expression": "run_id","isExpression": false,"asc": true,"nulls": "last"@@ -4995,11 +5096,11 @@"method": "btree","with": {}},- "agent_eval_test_cases_sort_order_idx": {- "name": "agent_eval_test_cases_sort_order_idx",+ "agent_eval_run_topics_test_case_id_idx": {+ "name": "agent_eval_run_topics_test_case_id_idx","columns": [{- "expression": "sort_order",+ "expression": "test_case_id","isExpression": false,"asc": true,"nulls": "last"@@ -5010,8 +5111,8 @@"method": "btree","with": {}},- "agent_eval_test_cases_workspace_id_idx": {- "name": "agent_eval_test_cases_workspace_id_idx",+ "agent_eval_run_topics_workspace_id_idx": {+ "name": "agent_eval_run_topics_workspace_id_idx","columns": [{"expression": "workspace_id",@@ -5027,100 +5128,198 @@}},"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",+ "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_test_cases_workspace_id_workspaces_id_fk": {- "name": "agent_eval_test_cases_workspace_id_workspaces_id_fk",- "tableFrom": "agent_eval_test_cases",+ "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_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"],+ "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_test_cases_environment_id_agent_eval_environments_id_fk": {- "name": "agent_eval_test_cases_environment_id_agent_eval_environments_id_fk",- "tableFrom": "agent_eval_test_cases",- "tableTo": "agent_eval_environments",- "columnsFrom": ["environment_id"],+ "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": "set null",+ "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": {},+ "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_history_job_agents": {- "name": "agent_history_job_agents",+ "public.agent_eval_runs": {+ "name": "agent_eval_runs","schema": "","columns": {"id": {"name": "id",- "type": "uuid",+ "type": "text","primaryKey": true,- "notNull": true,- "default": "gen_random_uuid()"+ "notNull": true},- "job_id": {- "name": "job_id",+ "dataset_id": {+ "name": "dataset_id","type": "text","primaryKey": false,"notNull": true},- "agent_id": {- "name": "agent_id",+ "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_history_job_agents_job_id_agent_id_unique": {- "name": "agent_history_job_agents_job_id_agent_id_unique",+ "agent_eval_runs_dataset_id_idx": {+ "name": "agent_eval_runs_dataset_id_idx","columns": [{- "expression": "job_id",+ "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": "agent_id",+ "expression": "experiment_id","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": true,+ "isUnique": false,"concurrently": false,"method": "btree","with": {}},- "agent_history_job_agents_agent_id_idx": {- "name": "agent_history_job_agents_agent_id_idx",+ "agent_eval_runs_parent_run_id_idx": {+ "name": "agent_eval_runs_parent_run_id_idx","columns": [{- "expression": "agent_id",+ "expression": "parent_run_id","isExpression": false,"asc": true,"nulls": "last"@@ -5130,85 +5329,57 @@"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+ "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": {}},- "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",+ "agent_eval_runs_status_idx": {+ "name": "agent_eval_runs_status_idx","columns": [{- "expression": "job_id",+ "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": "group_id",+ "expression": "target_agent_id","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": true,+ "isUnique": false,"concurrently": false,"method": "btree","with": {}},- "agent_history_job_groups_group_id_idx": {- "name": "agent_history_job_groups_group_id_idx",+ "agent_eval_runs_workspace_id_idx": {+ "name": "agent_eval_runs_workspace_id_idx","columns": [{- "expression": "group_id",+ "expression": "workspace_id","isExpression": false,"asc": true,"nulls": "last"@@ -5221,157 +5392,59 @@}},"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"],+ "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_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"],+ "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": "cascade",+ "onDelete": "no action","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_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_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"],+ "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_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"],+ "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": {},@@ -5380,8 +5453,8 @@"checkConstraints": {},"isRLSEnabled": false},- "public.agent_history_jobs": {- "name": "agent_history_jobs",+ "public.agent_eval_test_cases": {+ "name": "agent_eval_test_cases","schema": "","columns": {"id": {@@ -5390,86 +5463,58 @@"primaryKey": true,"notNull": true},- "status": {- "name": "status",+ "user_id": {+ "name": "user_id","type": "text","primaryKey": false,- "notNull": true,- "default": "'pending'"+ "notNull": false},- "type": {- "name": "type",+ "workspace_id": {+ "name": "workspace_id","type": "text","primaryKey": false,- "notNull": true,- "default": "'transfer'"- },- "payload": {- "name": "payload",- "type": "jsonb",- "primaryKey": false,"notNull": false},- "agent_ids": {- "name": "agent_ids",- "type": "jsonb",+ "dataset_id": {+ "name": "dataset_id",+ "type": "text","primaryKey": false,"notNull": true},- "session_ids": {- "name": "session_ids",- "type": "jsonb",+ "environment_id": {+ "name": "environment_id",+ "type": "uuid","primaryKey": false,- "notNull": true+ "notNull": false},- "group_ids": {- "name": "group_ids",+ "content": {+ "name": "content","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",+ "eval_mode": {+ "name": "eval_mode","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",+ "eval_config": {+ "name": "eval_config",+ "type": "jsonb","primaryKey": false,"notNull": false},- "total_topics": {- "name": "total_topics",- "type": "integer",+ "metadata": {+ "name": "metadata",+ "type": "jsonb","primaryKey": false,- "notNull": true+ "notNull": false},- "completed_topics": {- "name": "completed_topics",+ "sort_order": {+ "name": "sort_order","type": "integer","primaryKey": false,- "notNull": true,- "default": 0- },- "completed_at": {- "name": "completed_at",- "type": "timestamp with time zone",- "primaryKey": false,"notNull": false},"accessed_at": {@@ -5495,11 +5540,11 @@}},"indexes": {- "agent_history_jobs_status_idx": {- "name": "agent_history_jobs_status_idx",+ "agent_eval_test_cases_user_id_idx": {+ "name": "agent_eval_test_cases_user_id_idx","columns": [{- "expression": "status",+ "expression": "user_id","isExpression": false,"asc": true,"nulls": "last"@@ -5510,11 +5555,11 @@"method": "btree","with": {}},- "agent_history_jobs_source_user_id_idx": {- "name": "agent_history_jobs_source_user_id_idx",+ "agent_eval_test_cases_dataset_id_idx": {+ "name": "agent_eval_test_cases_dataset_id_idx","columns": [{- "expression": "source_user_id",+ "expression": "dataset_id","isExpression": false,"asc": true,"nulls": "last"@@ -5525,11 +5570,11 @@"method": "btree","with": {}},- "agent_history_jobs_target_user_id_idx": {- "name": "agent_history_jobs_target_user_id_idx",+ "agent_eval_test_cases_environment_id_idx": {+ "name": "agent_eval_test_cases_environment_id_idx","columns": [{- "expression": "target_user_id",+ "expression": "environment_id","isExpression": false,"asc": true,"nulls": "last"@@ -5540,11 +5585,11 @@"method": "btree","with": {}},- "agent_history_jobs_source_workspace_id_idx": {- "name": "agent_history_jobs_source_workspace_id_idx",+ "agent_eval_test_cases_sort_order_idx": {+ "name": "agent_eval_test_cases_sort_order_idx","columns": [{- "expression": "source_workspace_id",+ "expression": "sort_order","isExpression": false,"asc": true,"nulls": "last"@@ -5555,11 +5600,11 @@"method": "btree","with": {}},- "agent_history_jobs_target_workspace_id_idx": {- "name": "agent_history_jobs_target_workspace_id_idx",+ "agent_eval_test_cases_workspace_id_idx": {+ "name": "agent_eval_test_cases_workspace_id_idx","columns": [{- "expression": "target_workspace_id",+ "expression": "workspace_id","isExpression": false,"asc": true,"nulls": "last"@@ -5571,15 +5616,52 @@"with": {}}},- "foreignKeys": {},+ "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"+ },+ "agent_eval_test_cases_environment_id_agent_eval_environments_id_fk": {+ "name": "agent_eval_test_cases_environment_id_agent_eval_environments_id_fk",+ "tableFrom": "agent_eval_test_cases",+ "tableTo": "agent_eval_environments",+ "columnsFrom": ["environment_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },"compositePrimaryKeys": {},"uniqueConstraints": {},"policies": {},"checkConstraints": {},"isRLSEnabled": false},- "public.agent_inbox_messages": {- "name": "agent_inbox_messages",+ "public.agent_history_job_agents": {+ "name": "agent_history_job_agents","schema": "","columns": {"id": {@@ -5589,131 +5671,31 @@"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- },- "account_id": {- "name": "account_id",- "type": "uuid",- "primaryKey": false,- "notNull": false- },- "source_type": {- "name": "source_type",- "type": "text",- "primaryKey": false,- "notNull": true- },- "source_id": {- "name": "source_id",- "type": "uuid",- "primaryKey": false,- "notNull": true- },- "sender": {- "name": "sender",+ "job_id": {+ "name": "job_id","type": "text","primaryKey": false,"notNull": true},- "title": {- "name": "title",- "type": "text",- "primaryKey": false,- "notNull": false- },- "preview": {- "name": "preview",- "type": "text",- "primaryKey": false,- "notNull": false- },- "thread_key": {- "name": "thread_key",+ "agent_id": {+ "name": "agent_id","type": "text","primaryKey": false,- "notNull": false- },- "received_at": {- "name": "received_at",- "type": "timestamp with time zone",- "primaryKey": false,"notNull": true- },- "read_at": {- "name": "read_at",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "topic_id": {- "name": "topic_id",- "type": "text",- "primaryKey": false,- "notNull": false- },- "wake_claimed_at": {- "name": "wake_claimed_at",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "wait_consumed_by": {- "name": "wait_consumed_by",- "type": "jsonb",- "primaryKey": false,- "notNull": true,- "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_inbox_messages_source_unique": {- "name": "agent_inbox_messages_source_unique",+ "agent_history_job_agents_job_id_agent_id_unique": {+ "name": "agent_history_job_agents_job_id_agent_id_unique","columns": [{- "expression": "source_type",+ "expression": "job_id","isExpression": false,"asc": true,"nulls": "last"},{- "expression": "source_id",+ "expression": "agent_id","isExpression": false,"asc": true,"nulls": "last"@@ -5724,59 +5706,99 @@"method": "btree","with": {}},- "agent_inbox_messages_agent_received_at_idx": {- "name": "agent_inbox_messages_agent_received_at_idx",+ "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"- },- {- "expression": "received_at",- "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_inbox_messages_agent_created_at_idx": {- "name": "agent_inbox_messages_agent_created_at_idx",+ "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": "agent_id",+ "expression": "job_id","isExpression": false,"asc": true,"nulls": "last"},{- "expression": "created_at",+ "expression": "group_id","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": false,+ "isUnique": true,"concurrently": false,"method": "btree","with": {}},- "agent_inbox_messages_account_created_at_idx": {- "name": "agent_inbox_messages_account_created_at_idx",+ "agent_history_job_groups_group_id_idx": {+ "name": "agent_history_job_groups_group_id_idx","columns": [{- "expression": "account_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "created_at",+ "expression": "group_id","isExpression": false,"asc": true,"nulls": "last"@@ -5786,45 +5808,104 @@"concurrently": false,"method": "btree","with": {}- },- "agent_inbox_messages_account_sender_created_at_idx": {- "name": "agent_inbox_messages_account_sender_created_at_idx",- "columns": [- {- "expression": "account_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },+ }+ },+ "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": "sender",+ "expression": "job_id","isExpression": false,"asc": true,"nulls": "last"},{- "expression": "created_at",+ "expression": "topic_id","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": false,+ "isUnique": true,"concurrently": false,"method": "btree","with": {}},- "agent_inbox_messages_account_thread_idx": {- "name": "agent_inbox_messages_account_thread_idx",+ "agent_history_job_topics_topic_id_idx": {+ "name": "agent_history_job_topics_topic_id_idx","columns": [{- "expression": "account_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "thread_key",+ "expression": "topic_id","isExpression": false,"asc": true,"nulls": "last"@@ -5835,26 +5916,23 @@"method": "btree","with": {}},- "agent_inbox_messages_topic_id_idx": {- "name": "agent_inbox_messages_topic_id_idx",+ "agent_history_job_topics_pick_idx": {+ "name": "agent_history_job_topics_pick_idx","columns": [{- "expression": "topic_id",+ "expression": "job_id","isExpression": false,"asc": true,"nulls": "last"- }- ],- "isUnique": false,- "concurrently": false,- "method": "btree",- "with": {}- },- "agent_inbox_messages_user_id_idx": {- "name": "agent_inbox_messages_user_id_idx",- "columns": [+ },{- "expression": "user_id",+ "expression": "priority",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "activity_at","isExpression": false,"asc": true,"nulls": "last"@@ -5867,49 +5945,22 @@}},"foreignKeys": {- "agent_inbox_messages_agent_id_agents_id_fk": {- "name": "agent_inbox_messages_agent_id_agents_id_fk",- "tableFrom": "agent_inbox_messages",- "tableTo": "agents",- "columnsFrom": ["agent_id"],- "columnsTo": ["id"],- "onDelete": "cascade",- "onUpdate": "no action"- },- "agent_inbox_messages_user_id_users_id_fk": {- "name": "agent_inbox_messages_user_id_users_id_fk",- "tableFrom": "agent_inbox_messages",- "tableTo": "users",- "columnsFrom": ["user_id"],- "columnsTo": ["id"],- "onDelete": "cascade",- "onUpdate": "no action"- },- "agent_inbox_messages_workspace_id_workspaces_id_fk": {- "name": "agent_inbox_messages_workspace_id_workspaces_id_fk",- "tableFrom": "agent_inbox_messages",- "tableTo": "workspaces",- "columnsFrom": ["workspace_id"],- "columnsTo": ["id"],- "onDelete": "cascade",- "onUpdate": "no action"- },- "agent_inbox_messages_account_id_agent_accounts_id_fk": {- "name": "agent_inbox_messages_account_id_agent_accounts_id_fk",- "tableFrom": "agent_inbox_messages",- "tableTo": "agent_accounts",- "columnsFrom": ["account_id"],+ "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_inbox_messages_topic_id_topics_id_fk": {- "name": "agent_inbox_messages_topic_id_topics_id_fk",- "tableFrom": "agent_inbox_messages",+ "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": "set null",+ "onDelete": "cascade","onUpdate": "no action"}},@@ -5919,224 +5970,105 @@"checkConstraints": {},"isRLSEnabled": false},- "public.agent_intervention_resolutions": {- "name": "agent_intervention_resolutions",+ "public.agent_history_jobs": {+ "name": "agent_history_jobs","schema": "","columns": {"id": {"name": "id",- "type": "uuid",+ "type": "text","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",+ "status": {+ "name": "status","type": "text","primaryKey": false,- "notNull": true+ "notNull": true,+ "default": "'pending'"},- "batch_id": {- "name": "batch_id",+ "type": {+ "name": "type","type": "text","primaryKey": false,- "notNull": true+ "notNull": true,+ "default": "'transfer'"},- "source": {- "name": "source",- "type": "text",+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "agent_ids": {+ "name": "agent_ids",+ "type": "jsonb","primaryKey": false,"notNull": true},- "user_id": {- "name": "user_id",- "type": "text",+ "session_ids": {+ "name": "session_ids",+ "type": "jsonb","primaryKey": false,"notNull": true},- "workspace_id": {- "name": "workspace_id",- "type": "text",+ "group_ids": {+ "name": "group_ids",+ "type": "jsonb","primaryKey": false,- "notNull": false+ "notNull": true,+ "default": "'[]'::jsonb"},- "actor_id": {- "name": "actor_id",+ "source_user_id": {+ "name": "source_user_id","type": "text","primaryKey": false,"notNull": true},- "scope": {- "name": "scope",+ "source_workspace_id": {+ "name": "source_workspace_id","type": "text","primaryKey": false,- "notNull": true+ "notNull": false},- "selected_intervention_ids": {- "name": "selected_intervention_ids",- "type": "jsonb",+ "target_user_id": {+ "name": "target_user_id",+ "type": "text","primaryKey": false,"notNull": true},- "expected_versions": {- "name": "expected_versions",- "type": "jsonb",+ "target_workspace_id": {+ "name": "target_workspace_id",+ "type": "text","primaryKey": false,- "notNull": true+ "notNull": false},- "expected_request_revision_hashes": {- "name": "expected_request_revision_hashes",- "type": "jsonb",+ "total_topics": {+ "name": "total_topics",+ "type": "integer","primaryKey": false,"notNull": true},- "expected_item_count": {- "name": "expected_item_count",+ "completed_topics": {+ "name": "completed_topics","type": "integer","primaryKey": false,- "notNull": true+ "notNull": true,+ "default": 0},- "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",+ "completed_at": {+ "name": "completed_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",+ "accessed_at": {+ "name": "accessed_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",@@ -6153,38 +6085,41 @@}},"indexes": {- "agent_intervention_resolutions_request_unique": {- "name": "agent_intervention_resolutions_request_unique",+ "agent_history_jobs_status_idx": {+ "name": "agent_history_jobs_status_idx","columns": [{- "expression": "resolution_request_id",+ "expression": "status","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": true,+ "isUnique": false,"concurrently": false,"method": "btree","with": {}},- "agent_intervention_resolutions_owner_batch_idx": {- "name": "agent_intervention_resolutions_owner_batch_idx",+ "agent_history_jobs_source_user_id_idx": {+ "name": "agent_history_jobs_source_user_id_idx","columns": [{- "expression": "user_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "workspace_id",+ "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": "batch_id",+ "expression": "target_user_id","isExpression": false,"asc": true,"nulls": "last"@@ -6195,17 +6130,26 @@"method": "btree","with": {}},- "agent_intervention_resolutions_status_created_idx": {- "name": "agent_intervention_resolutions_status_created_idx",+ "agent_history_jobs_source_workspace_id_idx": {+ "name": "agent_history_jobs_source_workspace_id_idx","columns": [{- "expression": "status",+ "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": "created_at",+ "expression": "target_workspace_id","isExpression": false,"asc": true,"nulls": "last"@@ -6217,64 +6161,15 @@"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"- }- },+ "foreignKeys": {},"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"- }- },+ "checkConstraints": {},"isRLSEnabled": false},- "public.agent_interventions": {- "name": "agent_interventions",+ "public.agent_inbox_messages": {+ "name": "agent_inbox_messages","schema": "","columns": {"id": {@@ -6284,24 +6179,12 @@"notNull": true,"default": "gen_random_uuid()"},- "operation_id": {- "name": "operation_id",- "type": "text",- "primaryKey": false,- "notNull": true- },- "tool_call_id": {- "name": "tool_call_id",+ "agent_id": {+ "name": "agent_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",@@ -6314,170 +6197,85 @@"primaryKey": false,"notNull": false},- "source": {- "name": "source",- "type": "text",- "primaryKey": false,- "notNull": true- },- "provider": {- "name": "provider",- "type": "text",+ "account_id": {+ "name": "account_id",+ "type": "uuid","primaryKey": false,"notNull": false},- "interaction_kind": {- "name": "interaction_kind",+ "source_type": {+ "name": "source_type","type": "text","primaryKey": false,"notNull": true},- "surface": {- "name": "surface",- "type": "text",+ "source_id": {+ "name": "source_id",+ "type": "uuid","primaryKey": false,"notNull": true},- "system_action_eligibility": {- "name": "system_action_eligibility",+ "sender": {+ "name": "sender","type": "text","primaryKey": false,"notNull": true},- "approval_mode": {- "name": "approval_mode",+ "title": {+ "name": "title","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",+ "preview": {+ "name": "preview","type": "text","primaryKey": false,"notNull": false},- "request_revision_hash": {- "name": "request_revision_hash",+ "thread_key": {+ "name": "thread_key","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",+ "received_at": {+ "name": "received_at","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",+ "read_at": {+ "name": "read_at","type": "timestamp with time zone","primaryKey": false,"notNull": false},- "published_at": {- "name": "published_at",- "type": "timestamp with time zone",+ "topic_id": {+ "name": "topic_id",+ "type": "text","primaryKey": false,"notNull": false},- "resolved_at": {- "name": "resolved_at",+ "wake_claimed_at": {+ "name": "wake_claimed_at","type": "timestamp with time zone","primaryKey": false,"notNull": false},- "producer_ack_at": {- "name": "producer_ack_at",- "type": "timestamp with time zone",+ "wait_consumed_by": {+ "name": "wait_consumed_by",+ "type": "jsonb","primaryKey": false,- "notNull": false+ "notNull": true,+ "default": "'[]'::jsonb"},- "version": {- "name": "version",- "type": "integer",+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone","primaryKey": false,"notNull": true,- "default": 1+ "default": "now()"},"created_at": {"name": "created_at",@@ -6495,38 +6293,17 @@}},"indexes": {- "agent_interventions_operation_batch_tool_call_unique": {- "name": "agent_interventions_operation_batch_tool_call_unique",+ "agent_inbox_messages_source_unique": {+ "name": "agent_inbox_messages_source_unique","columns": [{- "expression": "operation_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "batch_id",+ "expression": "source_type","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",+ "expression": "source_id","isExpression": false,"asc": true,"nulls": "last"@@ -6537,83 +6314,59 @@"method": "btree","with": {}},- "agent_interventions_operation_batch_item_unique": {- "name": "agent_interventions_operation_batch_item_unique",+ "agent_inbox_messages_agent_received_at_idx": {+ "name": "agent_inbox_messages_agent_received_at_idx","columns": [{- "expression": "operation_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "batch_id",+ "expression": "agent_id","isExpression": false,"asc": true,"nulls": "last"},{- "expression": "item_index",+ "expression": "received_at","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": true,+ "isUnique": false,"concurrently": false,"method": "btree","with": {}},- "agent_interventions_owner_activity_item_unique": {- "name": "agent_interventions_owner_activity_item_unique",+ "agent_inbox_messages_agent_created_at_idx": {+ "name": "agent_inbox_messages_agent_created_at_idx","columns": [{- "expression": "user_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "activity_key",+ "expression": "agent_id","isExpression": false,"asc": true,"nulls": "last"},{- "expression": "item_index",+ "expression": "created_at","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": true,+ "isUnique": false,"concurrently": false,"method": "btree","with": {}},- "agent_interventions_owner_status_deadline_idx": {- "name": "agent_interventions_owner_status_deadline_idx",+ "agent_inbox_messages_account_created_at_idx": {+ "name": "agent_inbox_messages_account_created_at_idx","columns": [{- "expression": "user_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "workspace_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "status",+ "expression": "account_id","isExpression": false,"asc": true,"nulls": "last"},{- "expression": "deadline",+ "expression": "created_at","isExpression": false,"asc": true,"nulls": "last"@@ -6624,29 +6377,23 @@"method": "btree","with": {}},- "agent_interventions_owner_batch_idx": {- "name": "agent_interventions_owner_batch_idx",+ "agent_inbox_messages_account_sender_created_at_idx": {+ "name": "agent_inbox_messages_account_sender_created_at_idx","columns": [{- "expression": "user_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "workspace_id",+ "expression": "account_id","isExpression": false,"asc": true,"nulls": "last"},{- "expression": "batch_id",+ "expression": "sender","isExpression": false,"asc": true,"nulls": "last"},{- "expression": "item_index",+ "expression": "created_at","isExpression": false,"asc": true,"nulls": "last"@@ -6657,17 +6404,17 @@"method": "btree","with": {}},- "agent_interventions_activity_key_idx": {- "name": "agent_interventions_activity_key_idx",+ "agent_inbox_messages_account_thread_idx": {+ "name": "agent_inbox_messages_account_thread_idx","columns": [{- "expression": "user_id",+ "expression": "account_id","isExpression": false,"asc": true,"nulls": "last"},{- "expression": "activity_key",+ "expression": "thread_key","isExpression": false,"asc": true,"nulls": "last"@@ -6678,17 +6425,26 @@"method": "btree","with": {}},- "agent_interventions_status_deadline_idx": {- "name": "agent_interventions_status_deadline_idx",+ "agent_inbox_messages_topic_id_idx": {+ "name": "agent_inbox_messages_topic_id_idx","columns": [{- "expression": "status",+ "expression": "topic_id","isExpression": false,"asc": true,"nulls": "last"- },+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_inbox_messages_user_id_idx": {+ "name": "agent_inbox_messages_user_id_idx",+ "columns": [{- "expression": "deadline",+ "expression": "user_id","isExpression": false,"asc": true,"nulls": "last"@@ -6701,38 +6457,47 @@}},"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"],+ "agent_inbox_messages_agent_id_agents_id_fk": {+ "name": "agent_inbox_messages_agent_id_agents_id_fk",+ "tableFrom": "agent_inbox_messages",+ "tableTo": "agents",+ "columnsFrom": ["agent_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",+ "agent_inbox_messages_user_id_users_id_fk": {+ "name": "agent_inbox_messages_user_id_users_id_fk",+ "tableFrom": "agent_inbox_messages","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",+ "agent_inbox_messages_workspace_id_workspaces_id_fk": {+ "name": "agent_inbox_messages_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_inbox_messages","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"],+ "agent_inbox_messages_account_id_agent_accounts_id_fk": {+ "name": "agent_inbox_messages_account_id_agent_accounts_id_fk",+ "tableFrom": "agent_inbox_messages",+ "tableTo": "agent_accounts",+ "columnsFrom": ["account_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_inbox_messages_topic_id_topics_id_fk": {+ "name": "agent_inbox_messages_topic_id_topics_id_fk",+ "tableFrom": "agent_inbox_messages",+ "tableTo": "topics",+ "columnsFrom": ["topic_id"],"columnsTo": ["id"],"onDelete": "set null","onUpdate": "no action"@@ -6741,63 +6506,2799 @@"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}$'"+ "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()"},- "agent_interventions_request_revision_hash_check": {- "name": "agent_interventions_request_revision_hash_check",- "value": "\"agent_interventions\".\"request_revision_hash\" ~ '^[a-f0-9]{64}$'"+ "resolution_request_id": {+ "name": "resolution_request_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true},- "agent_interventions_step_index_check": {- "name": "agent_interventions_step_index_check",- "value": "\"agent_interventions\".\"step_index\" >= 0"+ "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_batch_tool_call_unique": {+ "name": "agent_interventions_operation_batch_tool_call_unique",+ "columns": [+ {+ "expression": "operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "batch_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_user_id_idx": {+ "name": "agent_label_assignments_user_id_idx",+ "columns": [+ {+ "expression": "user_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_mails": {+ "name": "agent_mails",+ "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+ },+ "account_id": {+ "name": "account_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "signal_id": {+ "name": "signal_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "direction": {+ "name": "direction",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider_message_id": {+ "name": "provider_message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "message_id": {+ "name": "message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "in_reply_to": {+ "name": "in_reply_to",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "references": {+ "name": "references",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "thread_key": {+ "name": "thread_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "from_address": {+ "name": "from_address",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "from_name": {+ "name": "from_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "to": {+ "name": "to",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "cc": {+ "name": "cc",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "reply_to": {+ "name": "reply_to",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "subject": {+ "name": "subject",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "text": {+ "name": "text",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "attachments": {+ "name": "attachments",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "codes": {+ "name": "codes",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "delivered_at": {+ "name": "delivered_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": {+ "agent_mails_account_provider_message_unique": {+ "name": "agent_mails_account_provider_message_unique",+ "columns": [+ {+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider_message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_mails_account_thread_idx": {+ "name": "agent_mails_account_thread_idx",+ "columns": [+ {+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "thread_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_mails_agent_delivered_at_idx": {+ "name": "agent_mails_agent_delivered_at_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "delivered_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_mails_signal_id_idx": {+ "name": "agent_mails_signal_id_idx",+ "columns": [+ {+ "expression": "signal_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_mails_user_id_idx": {+ "name": "agent_mails_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_mails_agent_id_agents_id_fk": {+ "name": "agent_mails_agent_id_agents_id_fk",+ "tableFrom": "agent_mails",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_mails_user_id_users_id_fk": {+ "name": "agent_mails_user_id_users_id_fk",+ "tableFrom": "agent_mails",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_mails_workspace_id_workspaces_id_fk": {+ "name": "agent_mails_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_mails",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_mails_account_id_agent_accounts_id_fk": {+ "name": "agent_mails_account_id_agent_accounts_id_fk",+ "tableFrom": "agent_mails",+ "tableTo": "agent_accounts",+ "columnsFrom": ["account_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_mails_signal_id_signals_id_fk": {+ "name": "agent_mails_signal_id_signals_id_fk",+ "tableFrom": "agent_mails",+ "tableTo": "signals",+ "columnsFrom": ["signal_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "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_running_created_at_idx": {+ "name": "agent_operations_running_created_at_idx",+ "columns": [+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"agent_operations\".\"status\" = 'running'",+ "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_workspace_id_created_at_idx": {+ "name": "agent_operations_workspace_id_created_at_idx",+ "columns": [+ {+ "expression": "workspace_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_device_account_bindings": {+ "name": "agent_device_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+ },+ "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": true+ },+ "account_id": {+ "name": "account_id",+ "type": "uuid",+ "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": {+ "agent_device_account_bindings_agent_device_unique": {+ "name": "agent_device_account_bindings_agent_device_unique",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "device_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_device_account_bindings_device_id_idx": {+ "name": "agent_device_account_bindings_device_id_idx",+ "columns": [+ {+ "expression": "device_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_device_account_bindings_account_device_idx": {+ "name": "agent_device_account_bindings_account_device_idx",+ "columns": [+ {+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "device_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_device_account_bindings_user_id_idx": {+ "name": "agent_device_account_bindings_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_device_account_bindings_workspace_id_idx": {+ "name": "agent_device_account_bindings_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_device_account_bindings_agent_id_agents_id_fk": {+ "name": "agent_device_account_bindings_agent_id_agents_id_fk",+ "tableFrom": "agent_device_account_bindings",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_device_account_bindings_user_id_users_id_fk": {+ "name": "agent_device_account_bindings_user_id_users_id_fk",+ "tableFrom": "agent_device_account_bindings",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_device_account_bindings_workspace_id_workspaces_id_fk": {+ "name": "agent_device_account_bindings_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_device_account_bindings",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_device_account_bindings_device_id_devices_id_fk": {+ "name": "agent_device_account_bindings_device_id_devices_id_fk",+ "tableFrom": "agent_device_account_bindings",+ "tableTo": "devices",+ "columnsFrom": ["device_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_device_account_bindings_account_id_agent_provider_accounts_id_fk": {+ "name": "agent_device_account_bindings_account_id_agent_provider_accounts_id_fk",+ "tableFrom": "agent_device_account_bindings",+ "tableTo": "agent_provider_accounts",+ "columnsFrom": ["account_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_device_account_bindings_login_fk": {+ "name": "agent_device_account_bindings_login_fk",+ "tableFrom": "agent_device_account_bindings",+ "tableTo": "agent_provider_account_logins",+ "columnsFrom": ["account_id", "device_id"],+ "columnsTo": ["account_id", "device_id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_provider_account_logins": {+ "name": "agent_provider_account_logins",+ "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+ },+ "device_id": {+ "name": "device_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+ },+ "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": {+ "agent_provider_account_logins_device_id_idx": {+ "name": "agent_provider_account_logins_device_id_idx",+ "columns": [+ {+ "expression": "device_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_provider_account_logins_user_id_idx": {+ "name": "agent_provider_account_logins_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_provider_account_logins_workspace_id_idx": {+ "name": "agent_provider_account_logins_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_provider_account_logins_account_id_agent_provider_accounts_id_fk": {+ "name": "agent_provider_account_logins_account_id_agent_provider_accounts_id_fk",+ "tableFrom": "agent_provider_account_logins",+ "tableTo": "agent_provider_accounts",+ "columnsFrom": ["account_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_provider_account_logins_device_id_devices_id_fk": {+ "name": "agent_provider_account_logins_device_id_devices_id_fk",+ "tableFrom": "agent_provider_account_logins",+ "tableTo": "devices",+ "columnsFrom": ["device_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_provider_account_logins_user_id_users_id_fk": {+ "name": "agent_provider_account_logins_user_id_users_id_fk",+ "tableFrom": "agent_provider_account_logins",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_provider_account_logins_workspace_id_workspaces_id_fk": {+ "name": "agent_provider_account_logins_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_provider_account_logins",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "agent_provider_account_logins_account_device_unique": {+ "name": "agent_provider_account_logins_account_device_unique",+ "nullsNotDistinct": false,+ "columns": ["account_id", "device_id"]+ }+ },+ "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+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "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},- "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\""+ "plan_tier": {+ "name": "plan_tier",+ "type": "text",+ "primaryKey": false,+ "notNull": false},- "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()"+ "rate_limit_tier": {+ "name": "rate_limit_tier",+ "type": "text",+ "primaryKey": false,+ "notNull": false},- "label_id": {- "name": "label_id",- "type": "uuid",+ "label": {+ "name": "label",+ "type": "varchar(255)","primaryKey": false,- "notNull": true+ "notNull": false},- "agent_id": {- "name": "agent_id",+ "credential_mode": {+ "name": "credential_mode","type": "text","primaryKey": false,- "notNull": true+ "notNull": true,+ "default": "'referenced'"},- "user_id": {- "name": "user_id",+ "credentials": {+ "name": "credentials","type": "text","primaryKey": false,- "notNull": true+ "notNull": false},- "workspace_id": {- "name": "workspace_id",+ "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": {@@ -6823,32 +9324,68 @@}},"indexes": {- "agent_label_assignments_label_id_agent_id_unique": {- "name": "agent_label_assignments_label_id_agent_id_unique",+ "agent_provider_accounts_user_id_idx": {+ "name": "agent_provider_accounts_user_id_idx","columns": [{- "expression": "label_id",+ "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_workspace_visibility_idx": {+ "name": "agent_provider_accounts_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id","isExpression": false,"asc": true,"nulls": "last"},{- "expression": "agent_id",+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": true,+ "isUnique": false,"concurrently": false,"method": "btree","with": {}},- "agent_label_assignments_agent_id_idx": {- "name": "agent_label_assignments_agent_id_idx",+ "agent_provider_accounts_token_expires_at_idx": {+ "name": "agent_provider_accounts_token_expires_at_idx","columns": [{- "expression": "agent_id",+ "expression": "token_expires_at","isExpression": false,"asc": true,"nulls": "last"@@ -6859,24 +9396,49 @@"method": "btree","with": {}},- "agent_label_assignments_user_id_idx": {- "name": "agent_label_assignments_user_id_idx",+ "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": false,+ "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_label_assignments_workspace_id_idx": {- "name": "agent_label_assignments_workspace_id_idx",+ "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,@@ -6884,43 +9446,26 @@"nulls": "last"}],- "isUnique": false,+ "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_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",+ "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_label_assignments_workspace_id_workspaces_id_fk": {- "name": "agent_label_assignments_workspace_id_workspaces_id_fk",- "tableFrom": "agent_label_assignments",+ "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"],@@ -6934,8 +9479,8 @@"checkConstraints": {},"isRLSEnabled": false},- "public.agent_labels": {- "name": "agent_labels",+ "public.agent_quota_calibrations": {+ "name": "agent_quota_calibrations","schema": "","columns": {"id": {@@ -6945,59 +9490,94 @@"notNull": true,"default": "gen_random_uuid()"},- "name": {- "name": "name",+ "account_id": {+ "name": "account_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id","type": "text","primaryKey": false,"notNull": true},- "description": {- "name": "description",+ "workspace_id": {+ "name": "workspace_id","type": "text","primaryKey": false,"notNull": false},- "color": {- "name": "color",+ "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},- "archived": {- "name": "archived",- "type": "boolean",+ "sample_count": {+ "name": "sample_count",+ "type": "integer","primaryKey": false,- "notNull": true,- "default": false+ "notNull": true},- "user_id": {- "name": "user_id",- "type": "text",+ "confidence": {+ "name": "confidence",+ "type": "numeric(20, 6)","primaryKey": false,- "notNull": true+ "notNull": false},- "workspace_id": {- "name": "workspace_id",+ "method": {+ "name": "method","type": "text","primaryKey": false,"notNull": false},- "accessed_at": {- "name": "accessed_at",- "type": "timestamp with time zone",+ "window_seconds": {+ "name": "window_seconds",+ "type": "integer","primaryKey": false,- "notNull": true,- "default": "now()"+ "notNull": false},- "created_at": {- "name": "created_at",+ "calibrated_at": {+ "name": "calibrated_at","type": "timestamp with time zone","primaryKey": false,"notNull": true,"default": "now()"},- "updated_at": {- "name": "updated_at",+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at","type": "timestamp with time zone","primaryKey": false,"notNull": true,@@ -7005,94 +9585,92 @@}},"indexes": {- "agent_labels_user_id_idx": {- "name": "agent_labels_user_id_idx",+ "agent_quota_calibrations_account_type_scope_idx": {+ "name": "agent_quota_calibrations_account_type_scope_idx","columns": [{- "expression": "user_id",+ "expression": "account_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",+ "expression": "limit_type","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",+ "expression": "scope_key","isExpression": false,"asc": true,"nulls": "last"},{- "expression": "name",+ "expression": "calibrated_at","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": true,- "where": "\"agent_labels\".\"workspace_id\" IS NULL AND \"agent_labels\".\"archived\" = false",+ "isUnique": false,"concurrently": false,"method": "btree","with": {}},- "agent_labels_workspace_id_name_unique": {- "name": "agent_labels_workspace_id_name_unique",+ "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": {}+ },+ "agent_quota_calibrations_user_id_idx": {+ "name": "agent_quota_calibrations_user_id_idx",+ "columns": [{- "expression": "name",+ "expression": "user_id","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": true,- "where": "\"agent_labels\".\"workspace_id\" IS NOT NULL AND \"agent_labels\".\"archived\" = false",+ "isUnique": 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",+ "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_labels_workspace_id_workspaces_id_fk": {- "name": "agent_labels_workspace_id_workspaces_id_fk",- "tableFrom": "agent_labels",+ "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"],@@ -7106,8 +9684,8 @@"checkConstraints": {},"isRLSEnabled": false},- "public.agent_mails": {- "name": "agent_mails",+ "public.agent_quota_snapshots": {+ "name": "agent_quota_snapshots","schema": "","columns": {"id": {@@ -7117,9 +9695,9 @@"notNull": true,"default": "gen_random_uuid()"},- "agent_id": {- "name": "agent_id",- "type": "text",+ "account_id": {+ "name": "account_id",+ "type": "uuid","primaryKey": false,"notNull": true},@@ -7135,143 +9713,64 @@"primaryKey": false,"notNull": false},- "account_id": {- "name": "account_id",- "type": "uuid",- "primaryKey": false,- "notNull": true- },- "signal_id": {- "name": "signal_id",+ "device_id": {+ "name": "device_id","type": "uuid","primaryKey": false,"notNull": false},- "direction": {- "name": "direction",- "type": "text",- "primaryKey": false,- "notNull": true- },- "provider": {- "name": "provider",- "type": "text",- "primaryKey": false,- "notNull": true- },- "provider_message_id": {- "name": "provider_message_id",+ "limit_type": {+ "name": "limit_type","type": "text","primaryKey": false,"notNull": true},- "message_id": {- "name": "message_id",- "type": "text",- "primaryKey": false,- "notNull": false- },- "in_reply_to": {- "name": "in_reply_to",+ "scope_key": {+ "name": "scope_key","type": "text","primaryKey": false,- "notNull": false- },- "references": {- "name": "references",- "type": "jsonb",- "primaryKey": false,"notNull": true,- "default": "'[]'::jsonb"+ "default": "''"},- "thread_key": {- "name": "thread_key",- "type": "text",+ "resets_at": {+ "name": "resets_at",+ "type": "timestamp with time zone","primaryKey": false,"notNull": false},- "from_address": {- "name": "from_address",- "type": "text",+ "utilization": {+ "name": "utilization",+ "type": "integer","primaryKey": false,"notNull": true},- "from_name": {- "name": "from_name",+ "severity": {+ "name": "severity","type": "text","primaryKey": false,"notNull": false},- "to": {- "name": "to",- "type": "jsonb",- "primaryKey": false,- "notNull": true,- "default": "'[]'::jsonb"- },- "cc": {- "name": "cc",- "type": "jsonb",- "primaryKey": false,- "notNull": true,- "default": "'[]'::jsonb"- },- "reply_to": {- "name": "reply_to",- "type": "jsonb",- "primaryKey": false,- "notNull": true,- "default": "'[]'::jsonb"- },- "subject": {- "name": "subject",- "type": "text",+ "is_active": {+ "name": "is_active",+ "type": "boolean","primaryKey": false,"notNull": false},- "text": {- "name": "text",- "type": "text",- "primaryKey": false,- "notNull": true,- "default": "''"- },- "attachments": {- "name": "attachments",- "type": "jsonb",- "primaryKey": false,- "notNull": true,- "default": "'[]'::jsonb"- },- "codes": {- "name": "codes",- "type": "jsonb",- "primaryKey": false,- "notNull": true,- "default": "'[]'::jsonb"- },- "delivered_at": {- "name": "delivered_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",+ "captured_at": {+ "name": "captured_at","type": "timestamp with time zone","primaryKey": false,"notNull": true,"default": "now()"},- "updated_at": {- "name": "updated_at",+ "raw": {+ "name": "raw",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at","type": "timestamp with time zone","primaryKey": false,"notNull": true,@@ -7279,8 +9778,8 @@}},"indexes": {- "agent_mails_account_provider_message_unique": {- "name": "agent_mails_account_provider_message_unique",+ "agent_quota_snapshots_account_type_scope_idx": {+ "name": "agent_quota_snapshots_account_type_scope_idx","columns": [{"expression": "account_id",@@ -7289,19 +9788,31 @@"nulls": "last"},{- "expression": "provider_message_id",+ "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": true,+ "isUnique": false,"concurrently": false,"method": "btree","with": {}},- "agent_mails_account_thread_idx": {- "name": "agent_mails_account_thread_idx",+ "agent_quota_snapshots_account_captured_idx": {+ "name": "agent_quota_snapshots_account_captured_idx","columns": [{"expression": "account_id",@@ -7310,7 +9821,7 @@"nulls": "last"},{- "expression": "thread_key",+ "expression": "captured_at","isExpression": false,"asc": true,"nulls": "last"@@ -7321,17 +9832,11 @@"method": "btree","with": {}},- "agent_mails_agent_delivered_at_idx": {- "name": "agent_mails_agent_delivered_at_idx",+ "agent_quota_snapshots_resets_at_idx": {+ "name": "agent_quota_snapshots_resets_at_idx","columns": [{- "expression": "agent_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "delivered_at",+ "expression": "resets_at","isExpression": false,"asc": true,"nulls": "last"@@ -7342,11 +9847,11 @@"method": "btree","with": {}},- "agent_mails_signal_id_idx": {- "name": "agent_mails_signal_id_idx",+ "agent_quota_snapshots_workspace_id_idx": {+ "name": "agent_quota_snapshots_workspace_id_idx","columns": [{- "expression": "signal_id",+ "expression": "workspace_id","isExpression": false,"asc": true,"nulls": "last"@@ -7357,8 +9862,8 @@"method": "btree","with": {}},- "agent_mails_user_id_idx": {- "name": "agent_mails_user_id_idx",+ "agent_quota_snapshots_user_id_idx": {+ "name": "agent_quota_snapshots_user_id_idx","columns": [{"expression": "user_id",@@ -7374,47 +9879,38 @@}},"foreignKeys": {- "agent_mails_agent_id_agents_id_fk": {- "name": "agent_mails_agent_id_agents_id_fk",- "tableFrom": "agent_mails",- "tableTo": "agents",- "columnsFrom": ["agent_id"],+ "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_mails_user_id_users_id_fk": {- "name": "agent_mails_user_id_users_id_fk",- "tableFrom": "agent_mails",+ "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_mails_workspace_id_workspaces_id_fk": {- "name": "agent_mails_workspace_id_workspaces_id_fk",- "tableFrom": "agent_mails",+ "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_mails_account_id_agent_accounts_id_fk": {- "name": "agent_mails_account_id_agent_accounts_id_fk",- "tableFrom": "agent_mails",- "tableTo": "agent_accounts",- "columnsFrom": ["account_id"],- "columnsTo": ["id"],- "onDelete": "cascade",- "onUpdate": "no action"- },- "agent_mails_signal_id_signals_id_fk": {- "name": "agent_mails_signal_id_signals_id_fk",- "tableFrom": "agent_mails",- "tableTo": "signals",- "columnsFrom": ["signal_id"],+ "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"@@ -7426,15 +9922,22 @@"checkConstraints": {},"isRLSEnabled": false},- "public.agent_operations": {- "name": "agent_operations",+ "public.agent_quota_usage_ledger": {+ "name": "agent_quota_usage_ledger","schema": "","columns": {"id": {"name": "id",- "type": "text",+ "type": "uuid","primaryKey": true,- "notNull": true+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "account_id": {+ "name": "account_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false},"user_id": {"name": "user_id",@@ -7444,229 +9947,96 @@},"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",+ "type": "text","primaryKey": false,"notNull": false},- "llm_calls": {- "name": "llm_calls",- "type": "integer",+ "provider": {+ "name": "provider",+ "type": "text","primaryKey": false,- "notNull": false+ "notNull": true},- "tool_calls": {- "name": "tool_calls",- "type": "integer",+ "model": {+ "name": "model",+ "type": "text","primaryKey": false,"notNull": false},- "human_interventions": {- "name": "human_interventions",+ "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},- "processing_time_ms": {- "name": "processing_time_ms",+ "output_tokens": {+ "name": "output_tokens","type": "integer","primaryKey": false,"notNull": false},- "human_waiting_time_ms": {- "name": "human_waiting_time_ms",+ "cache_read_tokens": {+ "name": "cache_read_tokens","type": "integer","primaryKey": false,"notNull": false},- "cost": {- "name": "cost",- "type": "jsonb",+ "cache_write_tokens": {+ "name": "cache_write_tokens",+ "type": "integer","primaryKey": false,"notNull": false},- "usage": {- "name": "usage",- "type": "jsonb",+ "reasoning_tokens": {+ "name": "reasoning_tokens",+ "type": "integer","primaryKey": false,"notNull": false},- "cost_limit": {- "name": "cost_limit",- "type": "jsonb",+ "cost_usd": {+ "name": "cost_usd",+ "type": "numeric(20, 6)","primaryKey": false,"notNull": false},- "model": {- "name": "model",+ "cost_source": {+ "name": "cost_source","type": "text","primaryKey": false,"notNull": false},- "provider": {- "name": "provider",+ "message_id": {+ "name": "message_id","type": "text","primaryKey": false,"notNull": false},- "model_runtime_config": {- "name": "model_runtime_config",- "type": "jsonb",+ "operation_id": {+ "name": "operation_id",+ "type": "text","primaryKey": false,"notNull": false},- "trigger": {- "name": "trigger",+ "topic_id": {+ "name": "topic_id","type": "text","primaryKey": false,"notNull": false},- "app_context": {- "name": "app_context",- "type": "jsonb",+ "agent_id": {+ "name": "agent_id",+ "type": "text","primaryKey": false,"notNull": false},- "trace_s3_key": {- "name": "trace_s3_key",+ "external_event_id": {+ "name": "external_event_id","type": "text","primaryKey": false,"notNull": false@@ -7675,15 +10045,7 @@"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()"+ "notNull": false},"created_at": {"name": "created_at",@@ -7691,51 +10053,20 @@"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",+ "agent_quota_usage_ledger_account_occurred_idx": {+ "name": "agent_quota_usage_ledger_account_occurred_idx","columns": [{- "expression": "workspace_id",+ "expression": "account_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",+ "expression": "occurred_at","isExpression": false,"asc": true,"nulls": "last"@@ -7746,41 +10077,23 @@"method": "btree","with": {}},- "agent_operations_topic_id_idx": {- "name": "agent_operations_topic_id_idx",+ "agent_quota_usage_ledger_account_model_occurred_idx": {+ "name": "agent_quota_usage_ledger_account_model_occurred_idx","columns": [{- "expression": "topic_id",+ "expression": "account_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",+ "expression": "model","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",+ "expression": "occurred_at","isExpression": false,"asc": true,"nulls": "last"@@ -7791,11 +10104,11 @@"method": "btree","with": {}},- "agent_operations_chat_group_id_idx": {- "name": "agent_operations_chat_group_id_idx",+ "agent_quota_usage_ledger_message_id_idx": {+ "name": "agent_quota_usage_ledger_message_id_idx","columns": [{- "expression": "chat_group_id",+ "expression": "message_id","isExpression": false,"asc": true,"nulls": "last"@@ -7806,11 +10119,11 @@"method": "btree","with": {}},- "agent_operations_parent_operation_id_idx": {- "name": "agent_operations_parent_operation_id_idx",+ "agent_quota_usage_ledger_operation_id_idx": {+ "name": "agent_quota_usage_ledger_operation_id_idx","columns": [{- "expression": "parent_operation_id",+ "expression": "operation_id","isExpression": false,"asc": true,"nulls": "last"@@ -7821,11 +10134,11 @@"method": "btree","with": {}},- "agent_operations_status_idx": {- "name": "agent_operations_status_idx",+ "agent_quota_usage_ledger_workspace_id_idx": {+ "name": "agent_quota_usage_ledger_workspace_id_idx","columns": [{- "expression": "status",+ "expression": "workspace_id","isExpression": false,"asc": true,"nulls": "last"@@ -7836,20 +10149,14 @@"method": "btree","with": {}},- "agent_operations_user_id_created_at_idx": {- "name": "agent_operations_user_id_created_at_idx",+ "agent_quota_usage_ledger_user_id_idx": {+ "name": "agent_quota_usage_ledger_user_id_idx","columns": [{"expression": "user_id","isExpression": false,"asc": true,"nulls": "last"- },- {- "expression": "created_at",- "isExpression": false,- "asc": true,- "nulls": "last"}],"isUnique": false,@@ -7857,94 +10164,83 @@"method": "btree","with": {}},- "agent_operations_workspace_id_created_at_idx": {- "name": "agent_operations_workspace_id_created_at_idx",+ "agent_quota_usage_ledger_external_event_unique": {+ "name": "agent_quota_usage_ledger_external_event_unique","columns": [{- "expression": "workspace_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "created_at",+ "expression": "external_event_id","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": false,+ "isUnique": true,+ "where": "\"agent_quota_usage_ledger\".\"external_event_id\" IS NOT NULL","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"],+ "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": "cascade",+ "onDelete": "set null","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"],+ "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": "set null",+ "onDelete": "cascade","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"],+ "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_operations_thread_id_threads_id_fk": {- "name": "agent_operations_thread_id_threads_id_fk",- "tableFrom": "agent_operations",- "tableTo": "threads",- "columnsFrom": ["thread_id"],+ "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_operations_task_id_tasks_id_fk": {- "name": "agent_operations_task_id_tasks_id_fk",- "tableFrom": "agent_operations",- "tableTo": "tasks",- "columnsFrom": ["task_id"],+ "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_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"],+ "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"@@ -7956,8 +10252,8 @@"checkConstraints": {},"isRLSEnabled": false},- "public.agent_account_bindings": {- "name": "agent_account_bindings",+ "public.agent_quota_windows": {+ "name": "agent_quota_windows","schema": "","columns": {"id": {@@ -7967,12 +10263,6 @@"notNull": true,"default": "gen_random_uuid()"},- "agent_id": {- "name": "agent_id",- "type": "text",- "primaryKey": false,- "notNull": true- },"account_id": {"name": "account_id","type": "uuid",@@ -7991,33 +10281,92 @@"primaryKey": false,"notNull": false},- "role": {- "name": "role",+ "limit_type": {+ "name": "limit_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope_key": {+ "name": "scope_key","type": "text","primaryKey": false,"notNull": true,- "default": "'pool'"+ "default": "''"},- "priority": {- "name": "priority",+ "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},- "weight": {- "name": "weight",+ "last_utilization": {+ "name": "last_utilization","type": "integer","primaryKey": false,- "notNull": true,- "default": 1+ "notNull": false},- "enabled": {- "name": "enabled",+ "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": 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",@@ -8042,17 +10391,29 @@}},"indexes": {- "agent_account_bindings_agent_account_unique": {- "name": "agent_account_bindings_agent_account_unique",+ "agent_quota_windows_natural_key_unique": {+ "name": "agent_quota_windows_natural_key_unique","columns": [{- "expression": "agent_id",+ "expression": "account_id","isExpression": false,"asc": true,"nulls": "last"},{- "expression": "account_id",+ "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"@@ -8063,55 +10424,146 @@"method": "btree","with": {}},- "agent_account_bindings_agent_pinned_unique": {- "name": "agent_account_bindings_agent_pinned_unique",+ "agent_quota_windows_account_resets_idx": {+ "name": "agent_quota_windows_account_resets_idx","columns": [{- "expression": "agent_id",+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resets_at","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": true,- "where": "\"agent_account_bindings\".\"role\" = 'pinned'",+ "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_share_grants": {+ "name": "agent_share_grants",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "share_id": {+ "name": "share_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source": {+ "name": "source",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true},- "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": {}+ "revoked_at": {+ "name": "revoked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false},- "agent_account_bindings_account_id_idx": {- "name": "agent_account_bindings_account_id_idx",+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_share_grants_share_user_unique": {+ "name": "agent_share_grants_share_user_unique","columns": [{- "expression": "account_id",+ "expression": "share_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,@@ -8119,16 +10571,16 @@"nulls": "last"}],- "isUnique": false,+ "isUnique": true,"concurrently": false,"method": "btree","with": {}},- "agent_account_bindings_workspace_id_idx": {- "name": "agent_account_bindings_workspace_id_idx",+ "agent_share_grants_user_id_idx": {+ "name": "agent_share_grants_user_id_idx","columns": [{- "expression": "workspace_id",+ "expression": "user_id","isExpression": false,"asc": true,"nulls": "last"@@ -8141,41 +10593,23 @@}},"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"],+ "agent_share_grants_share_id_agent_shares_id_fk": {+ "name": "agent_share_grants_share_id_agent_shares_id_fk",+ "tableFrom": "agent_share_grants",+ "tableTo": "agent_shares",+ "columnsFrom": ["share_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",+ "agent_share_grants_user_id_users_id_fk": {+ "name": "agent_share_grants_user_id_users_id_fk",+ "tableFrom": "agent_share_grants","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": {},@@ -8184,8 +10618,8 @@"checkConstraints": {},"isRLSEnabled": false},- "public.agent_device_account_bindings": {- "name": "agent_device_account_bindings",+ "public.agent_shares": {+ "name": "agent_shares","schema": "","columns": {"id": {@@ -8201,29 +10635,25 @@"primaryKey": false,"notNull": true},- "user_id": {- "name": "user_id",+ "visibility": {+ "name": "visibility","type": "text","primaryKey": false,- "notNull": true+ "notNull": true,+ "default": "'private'"},- "workspace_id": {- "name": "workspace_id",- "type": "text",+ "share_config": {+ "name": "share_config",+ "type": "jsonb","primaryKey": false,"notNull": false},- "device_id": {- "name": "device_id",- "type": "uuid",- "primaryKey": false,- "notNull": true- },- "account_id": {- "name": "account_id",- "type": "uuid",+ "user_view_count": {+ "name": "user_view_count",+ "type": "integer","primaryKey": false,- "notNull": true+ "notNull": true,+ "default": 0},"accessed_at": {"name": "accessed_at",@@ -8248,20 +10678,14 @@}},"indexes": {- "agent_device_account_bindings_agent_device_unique": {- "name": "agent_device_account_bindings_agent_device_unique",+ "agent_shares_agent_id_unique": {+ "name": "agent_shares_agent_id_unique","columns": [{"expression": "agent_id","isExpression": false,"asc": true,"nulls": "last"- },- {- "expression": "device_id",- "isExpression": false,- "asc": true,- "nulls": "last"}],"isUnique": true,@@ -8269,62 +10693,11 @@"method": "btree","with": {}},- "agent_device_account_bindings_device_id_idx": {- "name": "agent_device_account_bindings_device_id_idx",- "columns": [- {- "expression": "device_id",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": false,- "concurrently": false,- "method": "btree",- "with": {}- },- "agent_device_account_bindings_account_device_idx": {- "name": "agent_device_account_bindings_account_device_idx",- "columns": [- {- "expression": "account_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "device_id",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": false,- "concurrently": false,- "method": "btree",- "with": {}- },- "agent_device_account_bindings_user_id_idx": {- "name": "agent_device_account_bindings_user_id_idx",- "columns": [- {- "expression": "user_id",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": false,- "concurrently": false,- "method": "btree",- "with": {}- },- "agent_device_account_bindings_workspace_id_idx": {- "name": "agent_device_account_bindings_workspace_id_idx",+ "agent_shares_visibility_idx": {+ "name": "agent_shares_visibility_idx","columns": [{- "expression": "workspace_id",+ "expression": "visibility","isExpression": false,"asc": true,"nulls": "last"@@ -8337,59 +10710,14 @@}},"foreignKeys": {- "agent_device_account_bindings_agent_id_agents_id_fk": {- "name": "agent_device_account_bindings_agent_id_agents_id_fk",- "tableFrom": "agent_device_account_bindings",+ "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"- },- "agent_device_account_bindings_user_id_users_id_fk": {- "name": "agent_device_account_bindings_user_id_users_id_fk",- "tableFrom": "agent_device_account_bindings",- "tableTo": "users",- "columnsFrom": ["user_id"],- "columnsTo": ["id"],- "onDelete": "cascade",- "onUpdate": "no action"- },- "agent_device_account_bindings_workspace_id_workspaces_id_fk": {- "name": "agent_device_account_bindings_workspace_id_workspaces_id_fk",- "tableFrom": "agent_device_account_bindings",- "tableTo": "workspaces",- "columnsFrom": ["workspace_id"],- "columnsTo": ["id"],- "onDelete": "cascade",- "onUpdate": "no action"- },- "agent_device_account_bindings_device_id_devices_id_fk": {- "name": "agent_device_account_bindings_device_id_devices_id_fk",- "tableFrom": "agent_device_account_bindings",- "tableTo": "devices",- "columnsFrom": ["device_id"],- "columnsTo": ["id"],- "onDelete": "cascade",- "onUpdate": "no action"- },- "agent_device_account_bindings_account_id_agent_provider_accounts_id_fk": {- "name": "agent_device_account_bindings_account_id_agent_provider_accounts_id_fk",- "tableFrom": "agent_device_account_bindings",- "tableTo": "agent_provider_accounts",- "columnsFrom": ["account_id"],- "columnsTo": ["id"],- "onDelete": "cascade",- "onUpdate": "no action"- },- "agent_device_account_bindings_login_fk": {- "name": "agent_device_account_bindings_login_fk",- "tableFrom": "agent_device_account_bindings",- "tableTo": "agent_provider_account_logins",- "columnsFrom": ["account_id", "device_id"],- "columnsTo": ["account_id", "device_id"],- "onDelete": "cascade",- "onUpdate": "no action"}},"compositePrimaryKeys": {},@@ -8398,28 +10726,77 @@"checkConstraints": {},"isRLSEnabled": false},- "public.agent_provider_account_logins": {- "name": "agent_provider_account_logins",+ "public.agent_skills": {+ "name": "agent_skills","schema": "","columns": {"id": {"name": "id",- "type": "uuid",+ "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+ },+ "upstream": {+ "name": "upstream",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "manifest": {+ "name": "manifest",+ "type": "jsonb",+ "primaryKey": false,"notNull": true,- "default": "gen_random_uuid()"+ "default": "'{}'::jsonb"},- "account_id": {- "name": "account_id",- "type": "uuid",+ "content": {+ "name": "content",+ "type": "text","primaryKey": false,- "notNull": true+ "notNull": false},- "device_id": {- "name": "device_id",- "type": "uuid",+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb","primaryKey": false,- "notNull": true+ "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",@@ -8433,19 +10810,17 @@"primaryKey": false,"notNull": false},- "first_seen_at": {- "name": "first_seen_at",+ "deleted_at": {+ "name": "deleted_at","type": "timestamp with time zone","primaryKey": false,- "notNull": true,- "default": "now()"+ "notNull": false},- "last_seen_at": {- "name": "last_seen_at",- "type": "timestamp with time zone",+ "is_deleted": {+ "name": "is_deleted",+ "type": "boolean","primaryKey": false,- "notNull": true,- "default": "now()"+ "notNull": false},"accessed_at": {"name": "accessed_at",@@ -8470,11 +10845,33 @@}},"indexes": {- "agent_provider_account_logins_device_id_idx": {- "name": "agent_provider_account_logins_device_id_idx",+ "agent_skills_user_name_idx": {+ "name": "agent_skills_user_name_idx","columns": [{- "expression": "device_id",+ "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"@@ -8485,8 +10882,8 @@"method": "btree","with": {}},- "agent_provider_account_logins_user_id_idx": {- "name": "agent_provider_account_logins_user_id_idx",+ "agent_skills_user_id_idx": {+ "name": "agent_skills_user_id_idx","columns": [{"expression": "user_id",@@ -8500,8 +10897,38 @@"method": "btree","with": {}},- "agent_provider_account_logins_workspace_id_idx": {- "name": "agent_provider_account_logins_workspace_id_idx",+ "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",@@ -8514,39 +10941,52 @@"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_provider_account_logins_account_id_agent_provider_accounts_id_fk": {- "name": "agent_provider_account_logins_account_id_agent_provider_accounts_id_fk",- "tableFrom": "agent_provider_account_logins",- "tableTo": "agent_provider_accounts",- "columnsFrom": ["account_id"],- "columnsTo": ["id"],- "onDelete": "cascade",- "onUpdate": "no action"- },- "agent_provider_account_logins_device_id_devices_id_fk": {- "name": "agent_provider_account_logins_device_id_devices_id_fk",- "tableFrom": "agent_provider_account_logins",- "tableTo": "devices",- "columnsFrom": ["device_id"],- "columnsTo": ["id"],- "onDelete": "cascade",+ "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_provider_account_logins_user_id_users_id_fk": {- "name": "agent_provider_account_logins_user_id_users_id_fk",- "tableFrom": "agent_provider_account_logins",+ "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_provider_account_logins_workspace_id_workspaces_id_fk": {- "name": "agent_provider_account_logins_workspace_id_workspaces_id_fk",- "tableFrom": "agent_provider_account_logins",+ "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"],@@ -8555,144 +10995,132 @@}},"compositePrimaryKeys": {},- "uniqueConstraints": {- "agent_provider_account_logins_account_device_unique": {- "name": "agent_provider_account_logins_account_device_unique",- "nullsNotDistinct": false,- "columns": ["account_id", "device_id"]- }- },+ "uniqueConstraints": {},"policies": {},"checkConstraints": {},"isRLSEnabled": false},- "public.agent_provider_accounts": {- "name": "agent_provider_accounts",+ "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()"},- "user_id": {- "name": "user_id",- "type": "text",- "primaryKey": false,- "notNull": true- },- "workspace_id": {- "name": "workspace_id",- "type": "text",+ "display_name": {+ "name": "display_name",+ "type": "varchar(200)","primaryKey": false,"notNull": false},- "visibility": {- "name": "visibility",- "type": "text",- "primaryKey": false,- "notNull": true,- "default": "'public'"- },- "provider": {- "name": "provider",+ "description": {+ "name": "description","type": "text","primaryKey": false,- "notNull": true+ "notNull": false},- "external_account_id": {- "name": "external_account_id",- "type": "text",+ "organization": {+ "name": "organization",+ "type": "varchar(100)","primaryKey": false,"notNull": false},- "email": {- "name": "email",- "type": "text",+ "enabled": {+ "name": "enabled",+ "type": "boolean","primaryKey": false,"notNull": false},- "display_name": {- "name": "display_name",- "type": "text",+ "provider_id": {+ "name": "provider_id",+ "type": "varchar(64)","primaryKey": false,- "notNull": false+ "notNull": true},- "organization_id": {- "name": "organization_id",- "type": "text",+ "type": {+ "name": "type",+ "type": "varchar(20)","primaryKey": false,- "notNull": false+ "notNull": true,+ "default": "'chat'"},- "plan_tier": {- "name": "plan_tier",- "type": "text",+ "sort": {+ "name": "sort",+ "type": "integer","primaryKey": false,"notNull": false},- "rate_limit_tier": {- "name": "rate_limit_tier",+ "user_id": {+ "name": "user_id","type": "text","primaryKey": false,- "notNull": false+ "notNull": true},- "label": {- "name": "label",- "type": "varchar(255)",+ "pricing": {+ "name": "pricing",+ "type": "jsonb","primaryKey": false,"notNull": false},- "credential_mode": {- "name": "credential_mode",- "type": "text",+ "parameters": {+ "name": "parameters",+ "type": "jsonb","primaryKey": false,- "notNull": true,- "default": "'referenced'"+ "notNull": false,+ "default": "'{}'::jsonb"},- "credentials": {- "name": "credentials",- "type": "text",+ "config": {+ "name": "config",+ "type": "jsonb","primaryKey": false,"notNull": false},- "credential_ref": {- "name": "credential_ref",+ "abilities": {+ "name": "abilities","type": "jsonb","primaryKey": false,- "notNull": false+ "notNull": false,+ "default": "'{}'::jsonb"},- "token_expires_at": {- "name": "token_expires_at",- "type": "timestamp with time zone",+ "context_window_tokens": {+ "name": "context_window_tokens",+ "type": "integer","primaryKey": false,"notNull": false},- "status": {- "name": "status",- "type": "text",- "primaryKey": false,- "notNull": true,- "default": "'active'"- },- "enabled": {- "name": "enabled",- "type": "boolean",+ "source": {+ "name": "source",+ "type": "varchar(20)","primaryKey": false,- "notNull": true,- "default": true+ "notNull": false},- "last_validated_at": {- "name": "last_validated_at",- "type": "timestamp with time zone",+ "released_at": {+ "name": "released_at",+ "type": "varchar(10)","primaryKey": false,"notNull": false},- "metadata": {- "name": "metadata",+ "settings": {+ "name": "settings","type": "jsonb","primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,"notNull": false},"accessed_at": {@@ -8718,47 +11146,45 @@}},"indexes": {- "agent_provider_accounts_user_id_idx": {- "name": "agent_provider_accounts_user_id_idx",+ "ai_models_id_provider_id_user_id_unique": {+ "name": "ai_models_id_provider_id_user_id_unique","columns": [{- "expression": "user_id",+ "expression": "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",+ "expression": "provider_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": false,+ "isUnique": true,+ "where": "\"ai_models\".\"workspace_id\" is null","concurrently": false,"method": "btree","with": {}},- "agent_provider_accounts_workspace_visibility_idx": {- "name": "agent_provider_accounts_workspace_visibility_idx",+ "ai_models_id_provider_id_user_id_workspace_id_unique": {+ "name": "ai_models_id_provider_id_user_id_workspace_id_unique","columns": [{- "expression": "workspace_id",+ "expression": "id","isExpression": false,"asc": true,"nulls": "last"},{- "expression": "visibility",+ "expression": "provider_id","isExpression": false,"asc": true,"nulls": "last"@@ -8768,71 +11194,38 @@"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",+ "expression": "workspace_id","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": false,+ "isUnique": true,+ "where": "\"ai_models\".\"workspace_id\" is not null","concurrently": false,"method": "btree","with": {}},- "agent_provider_accounts_identity_unique": {- "name": "agent_provider_accounts_identity_unique",+ "ai_models_user_id_idx": {+ "name": "ai_models_user_id_idx","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",+ "isUnique": false,"concurrently": false,"method": "btree","with": {}},- "agent_provider_accounts_identity_workspace_unique": {- "name": "agent_provider_accounts_identity_workspace_unique",+ "ai_models_workspace_id_idx": {+ "name": "ai_models_workspace_id_idx","columns": [- {- "expression": "provider",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "external_account_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },{"expression": "workspace_id","isExpression": false,@@ -8840,26 +11233,25 @@"nulls": "last"}],- "isUnique": true,- "where": "\"agent_provider_accounts\".\"external_account_id\" IS NOT NULL and \"agent_provider_accounts\".\"workspace_id\" is not null",+ "isUnique": false,"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",+ "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"},- "agent_provider_accounts_workspace_id_workspaces_id_fk": {- "name": "agent_provider_accounts_workspace_id_workspaces_id_fk",- "tableFrom": "agent_provider_accounts",+ "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"],@@ -8873,150 +11265,179 @@"checkConstraints": {},"isRLSEnabled": false},- "public.agent_quota_calibrations": {- "name": "agent_quota_calibrations",+ "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()"},- "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",+ "sort": {+ "name": "sort",+ "type": "integer","primaryKey": false,"notNull": false},- "limit_type": {- "name": "limit_type",- "type": "text",+ "enabled": {+ "name": "enabled",+ "type": "boolean","primaryKey": false,- "notNull": true+ "notNull": false},- "scope_key": {- "name": "scope_key",- "type": "text",+ "fetch_on_client": {+ "name": "fetch_on_client",+ "type": "boolean","primaryKey": false,- "notNull": true,- "default": "''"+ "notNull": false},- "capacity_usd": {- "name": "capacity_usd",- "type": "numeric(20, 6)",+ "check_model": {+ "name": "check_model",+ "type": "text","primaryKey": false,- "notNull": true+ "notNull": false},- "capacity_tokens_equivalent": {- "name": "capacity_tokens_equivalent",- "type": "bigint",+ "logo": {+ "name": "logo",+ "type": "text","primaryKey": false,"notNull": false},- "model_mix": {- "name": "model_mix",- "type": "jsonb",+ "description": {+ "name": "description",+ "type": "text","primaryKey": false,"notNull": false},- "sample_count": {- "name": "sample_count",- "type": "integer",+ "key_vaults": {+ "name": "key_vaults",+ "type": "text","primaryKey": false,- "notNull": true+ "notNull": false},- "confidence": {- "name": "confidence",- "type": "numeric(20, 6)",+ "source": {+ "name": "source",+ "type": "varchar(20)",+ "primaryKey": false,+ "notNull": false+ },+ "settings": {+ "name": "settings",+ "type": "jsonb","primaryKey": false,"notNull": false},- "method": {- "name": "method",- "type": "text",+ "config": {+ "name": "config",+ "type": "jsonb","primaryKey": false,"notNull": false},- "window_seconds": {- "name": "window_seconds",- "type": "integer",+ "workspace_id": {+ "name": "workspace_id",+ "type": "text","primaryKey": false,"notNull": false},- "calibrated_at": {- "name": "calibrated_at",+ "accessed_at": {+ "name": "accessed_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()"+ },+ "updated_at": {+ "name": "updated_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",+ "ai_providers_id_user_id_unique": {+ "name": "ai_providers_id_user_id_unique","columns": [{- "expression": "account_id",+ "expression": "id","isExpression": false,"asc": true,"nulls": "last"},{- "expression": "limit_type",+ "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": "scope_key",+ "expression": "user_id","isExpression": false,"asc": true,"nulls": "last"},{- "expression": "calibrated_at",+ "expression": "workspace_id","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": false,+ "isUnique": true,+ "where": "\"ai_providers\".\"workspace_id\" is not null","concurrently": false,"method": "btree","with": {}},- "agent_quota_calibrations_workspace_id_idx": {- "name": "agent_quota_calibrations_workspace_id_idx",+ "ai_providers_user_id_idx": {+ "name": "ai_providers_user_id_idx","columns": [{- "expression": "workspace_id",+ "expression": "user_id","isExpression": false,"asc": true,"nulls": "last"@@ -9027,11 +11448,11 @@"method": "btree","with": {}},- "agent_quota_calibrations_user_id_idx": {- "name": "agent_quota_calibrations_user_id_idx",+ "ai_providers_workspace_id_idx": {+ "name": "ai_providers_workspace_id_idx","columns": [{- "expression": "user_id",+ "expression": "workspace_id","isExpression": false,"asc": true,"nulls": "last"@@ -9044,27 +11465,18 @@}},"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",+ "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"},- "agent_quota_calibrations_workspace_id_workspaces_id_fk": {- "name": "agent_quota_calibrations_workspace_id_workspaces_id_fk",- "tableFrom": "agent_quota_calibrations",+ "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"],@@ -9078,174 +11490,99 @@"checkConstraints": {},"isRLSEnabled": false},- "public.agent_quota_snapshots": {- "name": "agent_quota_snapshots",+ "public.api_keys": {+ "name": "api_keys","schema": "","columns": {"id": {"name": "id",- "type": "uuid",+ "type": "text","primaryKey": true,- "notNull": true,- "default": "gen_random_uuid()"+ "notNull": true},- "account_id": {- "name": "account_id",- "type": "uuid",+ "name": {+ "name": "name",+ "type": "varchar(256)","primaryKey": false,"notNull": true},- "user_id": {- "name": "user_id",- "type": "text",+ "key": {+ "name": "key",+ "type": "varchar(256)","primaryKey": false,"notNull": true},- "workspace_id": {- "name": "workspace_id",- "type": "text",+ "key_hash": {+ "name": "key_hash",+ "type": "varchar(128)","primaryKey": false,"notNull": false},- "device_id": {- "name": "device_id",- "type": "uuid",+ "enabled": {+ "name": "enabled",+ "type": "boolean","primaryKey": false,- "notNull": false+ "notNull": false,+ "default": true},- "limit_type": {- "name": "limit_type",- "type": "text",+ "scopes": {+ "name": "scopes",+ "type": "jsonb","primaryKey": false,- "notNull": true+ "notNull": false},- "scope_key": {- "name": "scope_key",- "type": "text",+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone","primaryKey": false,- "notNull": true,- "default": "''"+ "notNull": false},- "resets_at": {- "name": "resets_at",+ "last_used_at": {+ "name": "last_used_at","type": "timestamp with time zone","primaryKey": false,"notNull": false},- "utilization": {- "name": "utilization",- "type": "integer",+ "user_id": {+ "name": "user_id",+ "type": "text","primaryKey": false,"notNull": true},- "severity": {- "name": "severity",+ "workspace_id": {+ "name": "workspace_id","type": "text","primaryKey": false,"notNull": false},- "is_active": {- "name": "is_active",- "type": "boolean",- "primaryKey": false,- "notNull": false- },- "captured_at": {- "name": "captured_at",+ "accessed_at": {+ "name": "accessed_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": {}+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"},- "agent_quota_snapshots_workspace_id_idx": {- "name": "agent_quota_snapshots_workspace_id_idx",+ "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": "workspace_id",+ "expression": "user_id","isExpression": false,"asc": true,"nulls": "last"@@ -9256,11 +11593,11 @@"method": "btree","with": {}},- "agent_quota_snapshots_user_id_idx": {- "name": "agent_quota_snapshots_user_id_idx",+ "api_keys_workspace_id_idx": {+ "name": "api_keys_workspace_id_idx","columns": [{- "expression": "user_id",+ "expression": "workspace_id","isExpression": false,"asc": true,"nulls": "last"@@ -9273,51 +11610,44 @@}},"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",+ "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"},- "agent_quota_snapshots_workspace_id_workspaces_id_fk": {- "name": "agent_quota_snapshots_workspace_id_workspaces_id_fk",- "tableFrom": "agent_quota_snapshots",+ "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"- },- "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": {},+ "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.agent_quota_usage_ledger": {- "name": "agent_quota_usage_ledger",+ "public.artboard_boards": {+ "name": "artboard_boards","schema": "","columns": {"id": {@@ -9327,110 +11657,86 @@"notNull": true,"default": "gen_random_uuid()"},- "account_id": {- "name": "account_id",- "type": "uuid",- "primaryKey": false,- "notNull": false- },- "user_id": {- "name": "user_id",+ "artboard_id": {+ "name": "artboard_id","type": "text","primaryKey": false,"notNull": true},- "workspace_id": {- "name": "workspace_id",- "type": "text",- "primaryKey": false,- "notNull": false- },- "provider": {- "name": "provider",+ "page_id": {+ "name": "page_id","type": "text","primaryKey": false,"notNull": true},- "model": {- "name": "model",+ "group_id": {+ "name": "group_id","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",+ "round_id": {+ "name": "round_id",+ "type": "uuid","primaryKey": false,"notNull": false},- "cache_read_tokens": {- "name": "cache_read_tokens",- "type": "integer",+ "user_id": {+ "name": "user_id",+ "type": "text","primaryKey": false,- "notNull": false+ "notNull": true},- "cache_write_tokens": {- "name": "cache_write_tokens",- "type": "integer",+ "workspace_id": {+ "name": "workspace_id",+ "type": "text","primaryKey": false,"notNull": false},- "reasoning_tokens": {- "name": "reasoning_tokens",- "type": "integer",+ "project_id": {+ "name": "project_id",+ "type": "text","primaryKey": false,"notNull": false},- "cost_usd": {- "name": "cost_usd",- "type": "numeric(20, 6)",+ "acceptance_flow_node_id": {+ "name": "acceptance_flow_node_id",+ "type": "uuid","primaryKey": false,"notNull": false},- "cost_source": {- "name": "cost_source",+ "type": {+ "name": "type","type": "text","primaryKey": false,- "notNull": false+ "notNull": true},- "message_id": {- "name": "message_id",+ "title": {+ "name": "title","type": "text","primaryKey": false,- "notNull": false+ "notNull": true},- "operation_id": {- "name": "operation_id",+ "description": {+ "name": "description","type": "text","primaryKey": false,"notNull": false},- "topic_id": {- "name": "topic_id",+ "expected": {+ "name": "expected","type": "text","primaryKey": false,"notNull": false},- "agent_id": {- "name": "agent_id",- "type": "text",+ "rect": {+ "name": "rect",+ "type": "jsonb","primaryKey": false,- "notNull": false+ "notNull": true},- "external_event_id": {- "name": "external_event_id",+ "source_path": {+ "name": "source_path","type": "text","primaryKey": false,"notNull": false@@ -9441,26 +11747,34 @@"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_usage_ledger_account_occurred_idx": {- "name": "agent_quota_usage_ledger_account_occurred_idx",+ "artboard_boards_artboard_id_idx": {+ "name": "artboard_boards_artboard_id_idx","columns": [{- "expression": "account_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "occurred_at",+ "expression": "artboard_id","isExpression": false,"asc": true,"nulls": "last"@@ -9471,80 +11785,87 @@"method": "btree","with": {}},- "agent_quota_usage_ledger_account_model_occurred_idx": {- "name": "agent_quota_usage_ledger_account_model_occurred_idx",+ "artboard_boards_page_id_idx": {+ "name": "artboard_boards_page_id_idx","columns": [{- "expression": "account_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "model",+ "expression": "page_id","isExpression": false,"asc": true,"nulls": "last"- },+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "artboard_boards_group_id_idx": {+ "name": "artboard_boards_group_id_idx",+ "columns": [{- "expression": "occurred_at",+ "expression": "group_id","isExpression": false,"asc": true,"nulls": "last"}],"isUnique": false,+ "where": "\"artboard_boards\".\"group_id\" IS NOT NULL","concurrently": false,"method": "btree","with": {}},- "agent_quota_usage_ledger_message_id_idx": {- "name": "agent_quota_usage_ledger_message_id_idx",+ "artboard_boards_round_id_idx": {+ "name": "artboard_boards_round_id_idx","columns": [{- "expression": "message_id",+ "expression": "round_id","isExpression": false,"asc": true,"nulls": "last"}],"isUnique": false,+ "where": "\"artboard_boards\".\"round_id\" IS NOT NULL","concurrently": false,"method": "btree","with": {}},- "agent_quota_usage_ledger_operation_id_idx": {- "name": "agent_quota_usage_ledger_operation_id_idx",+ "artboard_boards_project_id_idx": {+ "name": "artboard_boards_project_id_idx","columns": [{- "expression": "operation_id",+ "expression": "project_id","isExpression": false,"asc": true,"nulls": "last"}],"isUnique": false,+ "where": "\"artboard_boards\".\"project_id\" IS NOT NULL","concurrently": false,"method": "btree","with": {}},- "agent_quota_usage_ledger_workspace_id_idx": {- "name": "agent_quota_usage_ledger_workspace_id_idx",+ "artboard_boards_acceptance_flow_node_id_unique": {+ "name": "artboard_boards_acceptance_flow_node_id_unique","columns": [{- "expression": "workspace_id",+ "expression": "acceptance_flow_node_id","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": false,+ "isUnique": true,+ "where": "\"artboard_boards\".\"acceptance_flow_node_id\" IS NOT NULL","concurrently": false,"method": "btree","with": {}},- "agent_quota_usage_ledger_user_id_idx": {- "name": "agent_quota_usage_ledger_user_id_idx",+ "artboard_boards_user_id_idx": {+ "name": "artboard_boards_user_id_idx","columns": [{"expression": "user_id",@@ -9558,83 +11879,83 @@"method": "btree","with": {}},- "agent_quota_usage_ledger_external_event_unique": {- "name": "agent_quota_usage_ledger_external_event_unique",+ "artboard_boards_workspace_id_idx": {+ "name": "artboard_boards_workspace_id_idx","columns": [{- "expression": "external_event_id",+ "expression": "workspace_id","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": true,- "where": "\"agent_quota_usage_ledger\".\"external_event_id\" IS NOT NULL",+ "isUnique": false,+ "where": "\"artboard_boards\".\"workspace_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"],+ "artboard_boards_artboard_id_artboards_id_fk": {+ "name": "artboard_boards_artboard_id_artboards_id_fk",+ "tableFrom": "artboard_boards",+ "tableTo": "artboards",+ "columnsFrom": ["artboard_id"],"columnsTo": ["id"],- "onDelete": "set null",+ "onDelete": "cascade","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"],+ "artboard_boards_page_id_artboard_pages_id_fk": {+ "name": "artboard_boards_page_id_artboard_pages_id_fk",+ "tableFrom": "artboard_boards",+ "tableTo": "artboard_pages",+ "columnsFrom": ["page_id"],"columnsTo": ["id"],- "onDelete": "cascade",+ "onDelete": "no action","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"],+ "artboard_boards_group_id_artboard_groups_id_fk": {+ "name": "artboard_boards_group_id_artboard_groups_id_fk",+ "tableFrom": "artboard_boards",+ "tableTo": "artboard_groups",+ "columnsFrom": ["group_id"],"columnsTo": ["id"],- "onDelete": "cascade",+ "onDelete": "no action","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"],+ "artboard_boards_round_id_artboard_rounds_id_fk": {+ "name": "artboard_boards_round_id_artboard_rounds_id_fk",+ "tableFrom": "artboard_boards",+ "tableTo": "artboard_rounds",+ "columnsFrom": ["round_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"],+ "artboard_boards_user_id_users_id_fk": {+ "name": "artboard_boards_user_id_users_id_fk",+ "tableFrom": "artboard_boards",+ "tableTo": "users",+ "columnsFrom": ["user_id"],"columnsTo": ["id"],- "onDelete": "set null",+ "onDelete": "cascade","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"],+ "artboard_boards_workspace_id_workspaces_id_fk": {+ "name": "artboard_boards_workspace_id_workspaces_id_fk",+ "tableFrom": "artboard_boards",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],"columnsTo": ["id"],- "onDelete": "set null",+ "onDelete": "cascade","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"],+ "artboard_boards_project_id_projects_id_fk": {+ "name": "artboard_boards_project_id_projects_id_fk",+ "tableFrom": "artboard_boards",+ "tableTo": "projects",+ "columnsFrom": ["project_id"],"columnsTo": ["id"],"onDelete": "set null","onUpdate": "no action"@@ -9643,11 +11964,16 @@"compositePrimaryKeys": {},"uniqueConstraints": {},"policies": {},- "checkConstraints": {},+ "checkConstraints": {+ "artboard_boards_decision_no_source_check": {+ "name": "artboard_boards_decision_no_source_check",+ "value": "\"artboard_boards\".\"type\" <> 'decision' OR \"artboard_boards\".\"source_path\" IS NULL"+ }+ },"isRLSEnabled": false},- "public.agent_quota_windows": {- "name": "agent_quota_windows",+ "public.artboard_comments": {+ "name": "artboard_comments","schema": "","columns": {"id": {@@ -9657,12 +11983,30 @@"notNull": true,"default": "gen_random_uuid()"},- "account_id": {- "name": "account_id",- "type": "uuid",+ "artboard_id": {+ "name": "artboard_id",+ "type": "text","primaryKey": false,"notNull": true},+ "parent_comment_id": {+ "name": "parent_comment_id",+ "type": "uuid",+ "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+ },"user_id": {"name": "user_id","type": "text",@@ -9675,90 +12019,63 @@"primaryKey": false,"notNull": false},- "limit_type": {- "name": "limit_type",+ "page_id": {+ "name": "page_id","type": "text","primaryKey": false,- "notNull": true+ "notNull": false},- "scope_key": {- "name": "scope_key",+ "group_id": {+ "name": "group_id","type": "text","primaryKey": false,- "notNull": true,- "default": "''"+ "notNull": false},- "resets_at": {- "name": "resets_at",- "type": "timestamp with time zone",+ "board_id": {+ "name": "board_id",+ "type": "uuid","primaryKey": false,- "notNull": true+ "notNull": false},- "window_start_at": {- "name": "window_start_at",- "type": "timestamp with time zone",+ "content": {+ "name": "content",+ "type": "text","primaryKey": false,"notNull": true},- "window_seconds": {- "name": "window_seconds",- "type": "integer",+ "client_id": {+ "name": "client_id",+ "type": "text","primaryKey": false,"notNull": true},- "peak_utilization": {- "name": "peak_utilization",- "type": "integer",- "primaryKey": false,- "notNull": true,- "default": 0- },- "last_utilization": {- "name": "last_utilization",- "type": "integer",+ "anchor": {+ "name": "anchor",+ "type": "jsonb","primaryKey": false,"notNull": false},- "rate_limited_at": {- "name": "rate_limited_at",+ "delivered_at": {+ "name": "delivered_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)",+ "resolved_at": {+ "name": "resolved_at",+ "type": "timestamp with time zone","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",+ "resolved_by_user_id": {+ "name": "resolved_by_user_id",+ "type": "text","primaryKey": false,"notNull": false},- "last_seen_at": {- "name": "last_seen_at",- "type": "timestamp with time zone",+ "metadata": {+ "name": "metadata",+ "type": "jsonb","primaryKey": false,"notNull": false},@@ -9785,50 +12102,74 @@}},"indexes": {- "agent_quota_windows_natural_key_unique": {- "name": "agent_quota_windows_natural_key_unique",+ "artboard_comments_artboard_id_author_user_id_client_id_unique": {+ "name": "artboard_comments_artboard_id_author_user_id_client_id_unique","columns": [{- "expression": "account_id",+ "expression": "artboard_id","isExpression": false,"asc": true,"nulls": "last"},{- "expression": "limit_type",+ "expression": "author_user_id","isExpression": false,"asc": true,"nulls": "last"},{- "expression": "scope_key",+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "artboard_comments_artboard_id_created_at_idx": {+ "name": "artboard_comments_artboard_id_created_at_idx",+ "columns": [+ {+ "expression": "artboard_id","isExpression": false,"asc": true,"nulls": "last"},{- "expression": "resets_at",+ "expression": "created_at","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": true,+ "isUnique": false,"concurrently": false,"method": "btree","with": {}},- "agent_quota_windows_account_resets_idx": {- "name": "agent_quota_windows_account_resets_idx",+ "artboard_comments_parent_comment_id_idx": {+ "name": "artboard_comments_parent_comment_id_idx","columns": [{- "expression": "account_id",+ "expression": "parent_comment_id","isExpression": false,"asc": true,"nulls": "last"- },+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "artboard_comments_board_id_idx": {+ "name": "artboard_comments_board_id_idx",+ "columns": [{- "expression": "resets_at",+ "expression": "board_id","isExpression": false,"asc": true,"nulls": "last"@@ -9839,8 +12180,8 @@"method": "btree","with": {}},- "agent_quota_windows_user_id_idx": {- "name": "agent_quota_windows_user_id_idx",+ "artboard_comments_user_id_idx": {+ "name": "artboard_comments_user_id_idx","columns": [{"expression": "user_id",@@ -9854,8 +12195,8 @@"method": "btree","with": {}},- "agent_quota_windows_workspace_id_idx": {- "name": "agent_quota_windows_workspace_id_idx",+ "artboard_comments_workspace_id_idx": {+ "name": "artboard_comments_workspace_id_idx","columns": [{"expression": "workspace_id",@@ -9865,38 +12206,133 @@}],"isUnique": false,+ "where": "\"artboard_comments\".\"workspace_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "artboard_comments_page_id_idx": {+ "name": "artboard_comments_page_id_idx",+ "columns": [+ {+ "expression": "page_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "artboard_comments_group_id_idx": {+ "name": "artboard_comments_group_id_idx",+ "columns": [+ {+ "expression": "group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"artboard_comments\".\"group_id\" IS NOT NULL","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"],+ "artboard_comments_artboard_id_artboards_id_fk": {+ "name": "artboard_comments_artboard_id_artboards_id_fk",+ "tableFrom": "artboard_comments",+ "tableTo": "artboards",+ "columnsFrom": ["artboard_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",+ "artboard_comments_parent_comment_id_artboard_comments_id_fk": {+ "name": "artboard_comments_parent_comment_id_artboard_comments_id_fk",+ "tableFrom": "artboard_comments",+ "tableTo": "artboard_comments",+ "columnsFrom": ["parent_comment_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "artboard_comments_author_user_id_users_id_fk": {+ "name": "artboard_comments_author_user_id_users_id_fk",+ "tableFrom": "artboard_comments",+ "tableTo": "users",+ "columnsFrom": ["author_user_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "artboard_comments_author_agent_id_agents_id_fk": {+ "name": "artboard_comments_author_agent_id_agents_id_fk",+ "tableFrom": "artboard_comments",+ "tableTo": "agents",+ "columnsFrom": ["author_agent_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "artboard_comments_user_id_users_id_fk": {+ "name": "artboard_comments_user_id_users_id_fk",+ "tableFrom": "artboard_comments","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",+ "artboard_comments_workspace_id_workspaces_id_fk": {+ "name": "artboard_comments_workspace_id_workspaces_id_fk",+ "tableFrom": "artboard_comments","tableTo": "workspaces","columnsFrom": ["workspace_id"],"columnsTo": ["id"],"onDelete": "cascade","onUpdate": "no action"+ },+ "artboard_comments_page_id_artboard_pages_id_fk": {+ "name": "artboard_comments_page_id_artboard_pages_id_fk",+ "tableFrom": "artboard_comments",+ "tableTo": "artboard_pages",+ "columnsFrom": ["page_id"],+ "columnsTo": ["id"],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "artboard_comments_group_id_artboard_groups_id_fk": {+ "name": "artboard_comments_group_id_artboard_groups_id_fk",+ "tableFrom": "artboard_comments",+ "tableTo": "artboard_groups",+ "columnsFrom": ["group_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "artboard_comments_board_id_artboard_boards_id_fk": {+ "name": "artboard_comments_board_id_artboard_boards_id_fk",+ "tableFrom": "artboard_comments",+ "tableTo": "artboard_boards",+ "columnsFrom": ["board_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "artboard_comments_resolved_by_user_id_users_id_fk": {+ "name": "artboard_comments_resolved_by_user_id_users_id_fk",+ "tableFrom": "artboard_comments",+ "tableTo": "users",+ "columnsFrom": ["resolved_by_user_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"}},"compositePrimaryKeys": {},@@ -9905,8 +12341,8 @@"checkConstraints": {},"isRLSEnabled": false},- "public.agent_shares": {- "name": "agent_shares",+ "public.artboard_edges": {+ "name": "artboard_edges","schema": "","columns": {"id": {@@ -9916,32 +12352,75 @@"notNull": true,"default": "gen_random_uuid()"},- "agent_id": {- "name": "agent_id",+ "artboard_id": {+ "name": "artboard_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_board_id": {+ "name": "source_board_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "target_board_id": {+ "name": "target_board_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id","type": "text","primaryKey": false,"notNull": true},- "visibility": {- "name": "visibility",+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "acceptance_flow_edge_id": {+ "name": "acceptance_flow_edge_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "label": {+ "name": "label","type": "text","primaryKey": false,"notNull": true,- "default": "'private'"+ "default": "''"},- "share_config": {- "name": "share_config",- "type": "jsonb",+ "condition": {+ "name": "condition",+ "type": "text","primaryKey": false,"notNull": false},- "user_view_count": {- "name": "user_view_count",+ "is_default": {+ "name": "is_default",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "sort_order": {+ "name": "sort_order","type": "integer","primaryKey": false,"notNull": true,"default": 0},+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },"accessed_at": {"name": "accessed_at","type": "timestamp with time zone",@@ -9965,43 +12444,157 @@}},"indexes": {- "agent_shares_agent_id_unique": {- "name": "agent_shares_agent_id_unique",+ "artboard_edges_artboard_id_idx": {+ "name": "artboard_edges_artboard_id_idx","columns": [{- "expression": "agent_id",+ "expression": "artboard_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "artboard_edges_source_board_id_idx": {+ "name": "artboard_edges_source_board_id_idx",+ "columns": [+ {+ "expression": "source_board_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "artboard_edges_source_board_id_default_unique": {+ "name": "artboard_edges_source_board_id_default_unique",+ "columns": [+ {+ "expression": "source_board_id","isExpression": false,"asc": true,"nulls": "last"}],"isUnique": true,+ "where": "\"artboard_edges\".\"is_default\" = true","concurrently": false,"method": "btree","with": {}},- "agent_shares_visibility_idx": {- "name": "agent_shares_visibility_idx",+ "artboard_edges_target_board_id_idx": {+ "name": "artboard_edges_target_board_id_idx","columns": [{- "expression": "visibility",+ "expression": "target_board_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "artboard_edges_acceptance_flow_edge_id_unique": {+ "name": "artboard_edges_acceptance_flow_edge_id_unique",+ "columns": [+ {+ "expression": "acceptance_flow_edge_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"artboard_edges\".\"acceptance_flow_edge_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "artboard_edges_user_id_idx": {+ "name": "artboard_edges_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "artboard_edges_workspace_id_idx": {+ "name": "artboard_edges_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id","isExpression": false,"asc": true,"nulls": "last"}],"isUnique": false,+ "where": "\"artboard_edges\".\"workspace_id\" IS NOT NULL","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"],+ "artboard_edges_artboard_id_artboards_id_fk": {+ "name": "artboard_edges_artboard_id_artboards_id_fk",+ "tableFrom": "artboard_edges",+ "tableTo": "artboards",+ "columnsFrom": ["artboard_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "artboard_edges_source_board_id_artboard_boards_id_fk": {+ "name": "artboard_edges_source_board_id_artboard_boards_id_fk",+ "tableFrom": "artboard_edges",+ "tableTo": "artboard_boards",+ "columnsFrom": ["source_board_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "artboard_edges_target_board_id_artboard_boards_id_fk": {+ "name": "artboard_edges_target_board_id_artboard_boards_id_fk",+ "tableFrom": "artboard_edges",+ "tableTo": "artboard_boards",+ "columnsFrom": ["target_board_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "artboard_edges_user_id_users_id_fk": {+ "name": "artboard_edges_user_id_users_id_fk",+ "tableFrom": "artboard_edges",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "artboard_edges_workspace_id_workspaces_id_fk": {+ "name": "artboard_edges_workspace_id_workspaces_id_fk",+ "tableFrom": "artboard_edges",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],"columnsTo": ["id"],"onDelete": "cascade","onUpdate": "no action"@@ -10013,8 +12606,8 @@"checkConstraints": {},"isRLSEnabled": false},- "public.agent_skills": {- "name": "agent_skills",+ "public.artboard_groups": {+ "name": "artboard_groups","schema": "","columns": {"id": {@@ -10023,83 +12616,57 @@"primaryKey": true,"notNull": true},- "name": {- "name": "name",- "type": "text",- "primaryKey": false,- "notNull": true- },- "description": {- "name": "description",+ "artboard_id": {+ "name": "artboard_id","type": "text","primaryKey": false,"notNull": true},- "identifier": {- "name": "identifier",+ "page_id": {+ "name": "page_id","type": "text","primaryKey": false,"notNull": true},- "source": {- "name": "source",+ "user_id": {+ "name": "user_id","type": "text","primaryKey": false,"notNull": true},- "manifest": {- "name": "manifest",- "type": "jsonb",- "primaryKey": false,- "notNull": true,- "default": "'{}'::jsonb"- },- "content": {- "name": "content",+ "workspace_id": {+ "name": "workspace_id","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)",+ "kind": {+ "name": "kind",+ "type": "text","primaryKey": false,- "notNull": false+ "notNull": true},- "user_id": {- "name": "user_id",+ "title": {+ "name": "title","type": "text","primaryKey": false,"notNull": true},- "workspace_id": {- "name": "workspace_id",+ "description": {+ "name": "description","type": "text","primaryKey": false,"notNull": false},- "deleted_at": {- "name": "deleted_at",- "type": "timestamp with time zone",+ "rect": {+ "name": "rect",+ "type": "jsonb","primaryKey": false,- "notNull": false+ "notNull": true},- "is_deleted": {- "name": "is_deleted",- "type": "boolean",+ "metadata": {+ "name": "metadata",+ "type": "jsonb","primaryKey": false,"notNull": false},@@ -10124,65 +12691,13 @@"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",+ },+ "indexes": {+ "artboard_groups_artboard_id_idx": {+ "name": "artboard_groups_artboard_id_idx","columns": [{- "expression": "source",+ "expression": "artboard_id","isExpression": false,"asc": true,"nulls": "last"@@ -10193,11 +12708,11 @@"method": "btree","with": {}},- "agent_skills_zip_hash_idx": {- "name": "agent_skills_zip_hash_idx",+ "artboard_groups_page_id_idx": {+ "name": "artboard_groups_page_id_idx","columns": [{- "expression": "zip_file_hash",+ "expression": "page_id","isExpression": false,"asc": true,"nulls": "last"@@ -10208,11 +12723,11 @@"method": "btree","with": {}},- "agent_skills_workspace_id_idx": {- "name": "agent_skills_workspace_id_idx",+ "artboard_groups_user_id_idx": {+ "name": "artboard_groups_user_id_idx","columns": [{- "expression": "workspace_id",+ "expression": "user_id","isExpression": false,"asc": true,"nulls": "last"@@ -10223,51 +12738,54 @@"method": "btree","with": {}},- "agent_skills_name_workspace_id_unique": {- "name": "agent_skills_name_workspace_id_unique",+ "artboard_groups_workspace_id_idx": {+ "name": "artboard_groups_workspace_id_idx","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",+ "isUnique": false,+ "where": "\"artboard_groups\".\"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",+ "artboard_groups_artboard_id_artboards_id_fk": {+ "name": "artboard_groups_artboard_id_artboards_id_fk",+ "tableFrom": "artboard_groups",+ "tableTo": "artboards",+ "columnsFrom": ["artboard_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade","onUpdate": "no action"},- "agent_skills_user_id_users_id_fk": {- "name": "agent_skills_user_id_users_id_fk",- "tableFrom": "agent_skills",+ "artboard_groups_page_id_artboard_pages_id_fk": {+ "name": "artboard_groups_page_id_artboard_pages_id_fk",+ "tableFrom": "artboard_groups",+ "tableTo": "artboard_pages",+ "columnsFrom": ["page_id"],+ "columnsTo": ["id"],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "artboard_groups_user_id_users_id_fk": {+ "name": "artboard_groups_user_id_users_id_fk",+ "tableFrom": "artboard_groups","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",+ "artboard_groups_workspace_id_workspaces_id_fk": {+ "name": "artboard_groups_workspace_id_workspaces_id_fk",+ "tableFrom": "artboard_groups","tableTo": "workspaces","columnsFrom": ["workspace_id"],"columnsTo": ["id"],@@ -10281,127 +12799,51 @@"checkConstraints": {},"isRLSEnabled": false},- "public.ai_models": {- "name": "ai_models",+ "public.artboard_pages": {+ "name": "artboard_pages","schema": "","columns": {"id": {"name": "id",- "type": "varchar(150)",- "primaryKey": false,- "notNull": true- },- "_id": {- "name": "_id",- "type": "uuid",+ "type": "text","primaryKey": true,- "notNull": true,- "default": "gen_random_uuid()"- },- "display_name": {- "name": "display_name",- "type": "varchar(200)",- "primaryKey": false,- "notNull": false+ "notNull": true},- "description": {- "name": "description",+ "artboard_id": {+ "name": "artboard_id","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",+ "workspace_id": {+ "name": "workspace_id",+ "type": "text","primaryKey": false,"notNull": false},- "abilities": {- "name": "abilities",- "type": "jsonb",+ "name": {+ "name": "name",+ "type": "text","primaryKey": false,- "notNull": false,- "default": "'{}'::jsonb"+ "notNull": true},- "context_window_tokens": {- "name": "context_window_tokens",+ "sort_order": {+ "name": "sort_order","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+ "notNull": true,+ "default": 0},- "settings": {- "name": "settings",+ "metadata": {+ "name": "metadata","type": "jsonb","primaryKey": false,- "notNull": false,- "default": "'{}'::jsonb"- },- "workspace_id": {- "name": "workspace_id",- "type": "text",- "primaryKey": false,"notNull": false},"accessed_at": {@@ -10427,70 +12869,23 @@}},"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",+ "artboard_pages_artboard_id_idx": {+ "name": "artboard_pages_artboard_id_idx","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",+ "expression": "artboard_id","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": true,- "where": "\"ai_models\".\"workspace_id\" is not null",+ "isUnique": false,"concurrently": false,"method": "btree","with": {}},- "ai_models_user_id_idx": {- "name": "ai_models_user_id_idx",+ "artboard_pages_user_id_idx": {+ "name": "artboard_pages_user_id_idx","columns": [{"expression": "user_id",@@ -10504,8 +12899,8 @@"method": "btree","with": {}},- "ai_models_workspace_id_idx": {- "name": "ai_models_workspace_id_idx",+ "artboard_pages_workspace_id_idx": {+ "name": "artboard_pages_workspace_id_idx","columns": [{"expression": "workspace_id",@@ -10515,24 +12910,34 @@}],"isUnique": false,+ "where": "\"artboard_pages\".\"workspace_id\" IS NOT NULL","concurrently": false,"method": "btree","with": {}}},"foreignKeys": {- "ai_models_user_id_users_id_fk": {- "name": "ai_models_user_id_users_id_fk",- "tableFrom": "ai_models",+ "artboard_pages_artboard_id_artboards_id_fk": {+ "name": "artboard_pages_artboard_id_artboards_id_fk",+ "tableFrom": "artboard_pages",+ "tableTo": "artboards",+ "columnsFrom": ["artboard_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "artboard_pages_user_id_users_id_fk": {+ "name": "artboard_pages_user_id_users_id_fk",+ "tableFrom": "artboard_pages","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",+ "artboard_pages_workspace_id_workspaces_id_fk": {+ "name": "artboard_pages_workspace_id_workspaces_id_fk",+ "tableFrom": "artboard_pages","tableTo": "workspaces","columnsFrom": ["workspace_id"],"columnsTo": ["id"],@@ -10546,98 +12951,81 @@"checkConstraints": {},"isRLSEnabled": false},- "public.ai_providers": {- "name": "ai_providers",+ "public.artboard_rounds": {+ "name": "artboard_rounds","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",+ "artboard_id": {+ "name": "artboard_id","type": "text","primaryKey": false,"notNull": true},- "sort": {- "name": "sort",- "type": "integer",- "primaryKey": false,- "notNull": false- },- "enabled": {- "name": "enabled",- "type": "boolean",+ "page_id": {+ "name": "page_id",+ "type": "text","primaryKey": false,- "notNull": false+ "notNull": true},- "fetch_on_client": {- "name": "fetch_on_client",- "type": "boolean",+ "user_id": {+ "name": "user_id",+ "type": "text","primaryKey": false,- "notNull": false+ "notNull": true},- "check_model": {- "name": "check_model",+ "workspace_id": {+ "name": "workspace_id","type": "text","primaryKey": false,"notNull": false},- "logo": {- "name": "logo",+ "title": {+ "name": "title","type": "text","primaryKey": false,- "notNull": false+ "notNull": true},- "description": {- "name": "description",+ "status": {+ "name": "status","type": "text","primaryKey": false,- "notNull": false+ "notNull": true,+ "default": "'open'"},- "key_vaults": {- "name": "key_vaults",- "type": "text",+ "recommended_board_id": {+ "name": "recommended_board_id",+ "type": "uuid","primaryKey": false,"notNull": false},- "source": {- "name": "source",- "type": "varchar(20)",+ "chosen_board_id": {+ "name": "chosen_board_id",+ "type": "uuid","primaryKey": false,"notNull": false},- "settings": {- "name": "settings",- "type": "jsonb",+ "selected_by": {+ "name": "selected_by",+ "type": "text","primaryKey": false,"notNull": false},- "config": {- "name": "config",- "type": "jsonb",+ "selected_at": {+ "name": "selected_at",+ "type": "timestamp with time zone","primaryKey": false,"notNull": false},- "workspace_id": {- "name": "workspace_id",- "type": "text",+ "metadata": {+ "name": "metadata",+ "type": "jsonb","primaryKey": false,"notNull": false},@@ -10664,43 +13052,54 @@}},"indexes": {- "ai_providers_id_user_id_unique": {- "name": "ai_providers_id_user_id_unique",+ "artboard_rounds_artboard_id_idx": {+ "name": "artboard_rounds_artboard_id_idx","columns": [{- "expression": "id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "user_id",+ "expression": "artboard_id","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": true,- "where": "\"ai_providers\".\"workspace_id\" is null",+ "isUnique": false,"concurrently": false,"method": "btree","with": {}},- "ai_providers_id_user_id_workspace_id_unique": {- "name": "ai_providers_id_user_id_workspace_id_unique",+ "artboard_rounds_page_id_idx": {+ "name": "artboard_rounds_page_id_idx","columns": [{- "expression": "id",+ "expression": "page_id","isExpression": false,"asc": true,"nulls": "last"- },+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "artboard_rounds_user_id_idx": {+ "name": "artboard_rounds_user_id_idx",+ "columns": [{"expression": "user_id","isExpression": false,"asc": true,"nulls": "last"- },+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "artboard_rounds_workspace_id_idx": {+ "name": "artboard_rounds_workspace_id_idx",+ "columns": [{"expression": "workspace_id","isExpression": false,@@ -10708,61 +13107,108 @@"nulls": "last"}],- "isUnique": true,- "where": "\"ai_providers\".\"workspace_id\" is not null",+ "isUnique": false,+ "where": "\"artboard_rounds\".\"workspace_id\" IS NOT NULL","concurrently": false,"method": "btree","with": {}},- "ai_providers_user_id_idx": {- "name": "ai_providers_user_id_idx",+ "artboard_rounds_recommended_board_id_idx": {+ "name": "artboard_rounds_recommended_board_id_idx","columns": [{- "expression": "user_id",+ "expression": "recommended_board_id","isExpression": false,"asc": true,"nulls": "last"}],"isUnique": false,+ "where": "\"artboard_rounds\".\"recommended_board_id\" IS NOT NULL","concurrently": false,"method": "btree","with": {}},- "ai_providers_workspace_id_idx": {- "name": "ai_providers_workspace_id_idx",+ "artboard_rounds_chosen_board_id_idx": {+ "name": "artboard_rounds_chosen_board_id_idx","columns": [{- "expression": "workspace_id",+ "expression": "chosen_board_id","isExpression": false,"asc": true,"nulls": "last"}],"isUnique": false,+ "where": "\"artboard_rounds\".\"chosen_board_id\" IS NOT NULL","concurrently": false,"method": "btree","with": {}}},"foreignKeys": {- "ai_providers_user_id_users_id_fk": {- "name": "ai_providers_user_id_users_id_fk",- "tableFrom": "ai_providers",+ "artboard_rounds_artboard_id_artboards_id_fk": {+ "name": "artboard_rounds_artboard_id_artboards_id_fk",+ "tableFrom": "artboard_rounds",+ "tableTo": "artboards",+ "columnsFrom": ["artboard_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "artboard_rounds_page_id_artboard_pages_id_fk": {+ "name": "artboard_rounds_page_id_artboard_pages_id_fk",+ "tableFrom": "artboard_rounds",+ "tableTo": "artboard_pages",+ "columnsFrom": ["page_id"],+ "columnsTo": ["id"],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "artboard_rounds_user_id_users_id_fk": {+ "name": "artboard_rounds_user_id_users_id_fk",+ "tableFrom": "artboard_rounds","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",+ "artboard_rounds_workspace_id_workspaces_id_fk": {+ "name": "artboard_rounds_workspace_id_workspaces_id_fk",+ "tableFrom": "artboard_rounds","tableTo": "workspaces","columnsFrom": ["workspace_id"],"columnsTo": ["id"],"onDelete": "cascade","onUpdate": "no action"+ },+ "artboard_rounds_recommended_board_id_artboard_boards_id_fk": {+ "name": "artboard_rounds_recommended_board_id_artboard_boards_id_fk",+ "tableFrom": "artboard_rounds",+ "tableTo": "artboard_boards",+ "columnsFrom": ["recommended_board_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "artboard_rounds_chosen_board_id_artboard_boards_id_fk": {+ "name": "artboard_rounds_chosen_board_id_artboard_boards_id_fk",+ "tableFrom": "artboard_rounds",+ "tableTo": "artboard_boards",+ "columnsFrom": ["chosen_board_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "artboard_rounds_selected_by_users_id_fk": {+ "name": "artboard_rounds_selected_by_users_id_fk",+ "tableFrom": "artboard_rounds",+ "tableTo": "users",+ "columnsFrom": ["selected_by"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"}},"compositePrimaryKeys": {},@@ -10771,8 +13217,8 @@"checkConstraints": {},"isRLSEnabled": false},- "public.api_keys": {- "name": "api_keys",+ "public.artboards": {+ "name": "artboards","schema": "","columns": {"id": {@@ -10781,59 +13227,78 @@"primaryKey": true,"notNull": true},- "name": {- "name": "name",- "type": "varchar(256)",+ "user_id": {+ "name": "user_id",+ "type": "text","primaryKey": false,"notNull": true},- "key": {- "name": "key",- "type": "varchar(256)",+ "workspace_id": {+ "name": "workspace_id",+ "type": "text","primaryKey": false,- "notNull": true+ "notNull": false},- "key_hash": {- "name": "key_hash",- "type": "varchar(128)",+ "topic_id": {+ "name": "topic_id",+ "type": "text","primaryKey": false,"notNull": false},- "enabled": {- "name": "enabled",- "type": "boolean",+ "task_id": {+ "name": "task_id",+ "type": "text","primaryKey": false,- "notNull": false,- "default": true+ "notNull": false},- "scopes": {- "name": "scopes",- "type": "jsonb",+ "project_id": {+ "name": "project_id",+ "type": "text","primaryKey": false,"notNull": false},- "expires_at": {- "name": "expires_at",- "type": "timestamp with time zone",+ "acceptance_id": {+ "name": "acceptance_id",+ "type": "uuid","primaryKey": false,"notNull": false},- "last_used_at": {- "name": "last_used_at",- "type": "timestamp with time zone",+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text","primaryKey": false,"notNull": false},- "user_id": {- "name": "user_id",+ "content": {+ "name": "content","type": "text","primaryKey": false,- "notNull": true+ "notNull": false},- "workspace_id": {- "name": "workspace_id",+ "phase": {+ "name": "phase","type": "text","primaryKey": false,+ "notNull": true,+ "default": "'discuss'"+ },+ "revision": {+ "name": "revision",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,"notNull": false},"accessed_at": {@@ -10850,20 +13315,113 @@"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",+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "artboards_user_id_idx": {+ "name": "artboards_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "artboards_workspace_id_idx": {+ "name": "artboards_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"artboards\".\"workspace_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "artboards_topic_id_idx": {+ "name": "artboards_topic_id_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"artboards\".\"topic_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "artboards_task_id_idx": {+ "name": "artboards_task_id_idx",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"artboards\".\"task_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "artboards_project_id_idx": {+ "name": "artboards_project_id_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "artboards_phase_idx": {+ "name": "artboards_phase_idx",+ "columns": [+ {+ "expression": "phase",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "artboards_created_at_idx": {+ "name": "artboards_created_at_idx","columns": [{- "expression": "user_id",+ "expression": "created_at","isExpression": false,"asc": true,"nulls": "last"@@ -10874,11 +13432,11 @@"method": "btree","with": {}},- "api_keys_workspace_id_idx": {- "name": "api_keys_workspace_id_idx",+ "artboards_updated_at_idx": {+ "name": "artboards_updated_at_idx","columns": [{- "expression": "workspace_id",+ "expression": "updated_at","isExpression": false,"asc": true,"nulls": "last"@@ -10891,38 +13449,63 @@}},"foreignKeys": {- "api_keys_user_id_users_id_fk": {- "name": "api_keys_user_id_users_id_fk",- "tableFrom": "api_keys",+ "artboards_user_id_users_id_fk": {+ "name": "artboards_user_id_users_id_fk",+ "tableFrom": "artboards","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",+ "artboards_workspace_id_workspaces_id_fk": {+ "name": "artboards_workspace_id_workspaces_id_fk",+ "tableFrom": "artboards","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"]+ "artboards_topic_id_topics_id_fk": {+ "name": "artboards_topic_id_topics_id_fk",+ "tableFrom": "artboards",+ "tableTo": "topics",+ "columnsFrom": ["topic_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "artboards_task_id_tasks_id_fk": {+ "name": "artboards_task_id_tasks_id_fk",+ "tableFrom": "artboards",+ "tableTo": "tasks",+ "columnsFrom": ["task_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "artboards_project_id_projects_id_fk": {+ "name": "artboards_project_id_projects_id_fk",+ "tableFrom": "artboards",+ "tableTo": "projects",+ "columnsFrom": ["project_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "artboards_acceptance_id_acceptances_id_fk": {+ "name": "artboards_acceptance_id_acceptances_id_fk",+ "tableFrom": "artboards",+ "tableTo": "acceptances",+ "columnsFrom": ["acceptance_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"}},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},"policies": {},"checkConstraints": {},"isRLSEnabled": false@@ -12053,24 +14636,8 @@"method": "btree","with": {}},- "channel_jobs_active_member_unique": {- "name": "channel_jobs_active_member_unique",- "columns": [- {- "expression": "member_id",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": true,- "where": "\"channel_jobs\".\"writer_held\" AND \"channel_jobs\".\"isolated_at\" IS NULL",- "concurrently": false,- "method": "btree",- "with": {}- },- "channel_jobs_active_directory_unique": {- "name": "channel_jobs_active_directory_unique",+ "channel_jobs_active_directory_idx": {+ "name": "channel_jobs_active_directory_idx","columns": [{"expression": "device_id",@@ -12085,8 +14652,8 @@"nulls": "last"}],- "isUnique": true,- "where": "\"channel_jobs\".\"device_id\" IS NOT NULL AND \"channel_jobs\".\"working_directory\" IS NOT NULL AND \"channel_jobs\".\"writer_held\"",+ "isUnique": false,+ "where": "\"channel_jobs\".\"writer_held\"","concurrently": false,"method": "btree","with": {}@@ -12391,6 +14958,32 @@"primaryKey": false,"notNull": false},+ "section_id": {+ "name": "section_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "pinned": {+ "name": "pinned",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "hidden": {+ "name": "hidden",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "pinned_at": {+ "name": "pinned_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },"agent_id": {"name": "agent_id","type": "text",@@ -12483,6 +15076,22 @@"method": "btree","with": {}},+ "channel_members_section_id_idx": {+ "name": "channel_members_section_id_idx",+ "columns": [+ {+ "expression": "section_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"channel_members\".\"section_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },"channel_members_agent_id_idx": {"name": "channel_members_agent_id_idx","columns": [@@ -12518,6 +15127,15 @@"onDelete": "set null","onUpdate": "no action"},+ "channel_members_section_id_channel_sections_id_fk": {+ "name": "channel_members_section_id_channel_sections_id_fk",+ "tableFrom": "channel_members",+ "tableTo": "channel_sections",+ "columnsFrom": ["section_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },"channel_members_agent_id_agents_id_fk": {"name": "channel_members_agent_id_agents_id_fk","tableFrom": "channel_members",@@ -12562,6 +15180,10 @@"name": "channel_members_agent_id_owner_check","value": "\"channel_members\".\"agent_id\" IS NULL OR \"channel_members\".\"actor_type\" = 'agent'"},+ "channel_members_section_id_owner_check": {+ "name": "channel_members_section_id_owner_check",+ "value": "\"channel_members\".\"section_id\" IS NULL OR \"channel_members\".\"actor_type\" = 'user'"+ },"channel_members_config_owner_check": {"name": "channel_members_config_owner_check","value": "\"channel_members\".\"config\" IS NULL OR \"channel_members\".\"actor_type\" <> 'user'"@@ -12869,80 +15491,182 @@"nulls": "last"},{- "expression": "id",+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"channel_messages\".\"routing_status\" = 'pending'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "channel_messages_channel_id_channels_id_fk": {+ "name": "channel_messages_channel_id_channels_id_fk",+ "tableFrom": "channel_messages",+ "tableTo": "channels",+ "columnsFrom": ["channel_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "channel_messages_user_id_users_id_fk": {+ "name": "channel_messages_user_id_users_id_fk",+ "tableFrom": "channel_messages",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "channel_messages_agent_id_agents_id_fk": {+ "name": "channel_messages_agent_id_agents_id_fk",+ "tableFrom": "channel_messages",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "channel_messages_thread_fk": {+ "name": "channel_messages_thread_fk",+ "tableFrom": "channel_messages",+ "tableTo": "channel_threads",+ "columnsFrom": ["channel_id", "thread_id"],+ "columnsTo": ["channel_id", "id"],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "channel_messages_scope_unique": {+ "name": "channel_messages_scope_unique",+ "nullsNotDistinct": false,+ "columns": ["channel_id", "id"]+ }+ },+ "policies": {},+ "checkConstraints": {+ "channel_messages_sender_check": {+ "name": "channel_messages_sender_check",+ "value": "\"channel_messages\".\"user_id\" IS NULL OR \"channel_messages\".\"agent_id\" IS NULL"+ },+ "channel_messages_user_sender_check": {+ "name": "channel_messages_user_sender_check",+ "value": "\"channel_messages\".\"routing_status\" <> 'reply' OR \"channel_messages\".\"user_id\" IS NULL"+ }+ },+ "isRLSEnabled": false+ },+ "public.channel_sections": {+ "name": "channel_sections",+ "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+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "sort": {+ "name": "sort",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "collapsed": {+ "name": "collapsed",+ "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": {+ "channel_sections_user_id_workspace_id_idx": {+ "name": "channel_sections_user_id_workspace_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "workspace_id","isExpression": false,"asc": true,"nulls": "last"}],"isUnique": false,- "where": "\"channel_messages\".\"routing_status\" = 'pending'","concurrently": false,"method": "btree","with": {}}},"foreignKeys": {- "channel_messages_channel_id_channels_id_fk": {- "name": "channel_messages_channel_id_channels_id_fk",- "tableFrom": "channel_messages",- "tableTo": "channels",- "columnsFrom": ["channel_id"],- "columnsTo": ["id"],- "onDelete": "cascade",- "onUpdate": "no action"- },- "channel_messages_user_id_users_id_fk": {- "name": "channel_messages_user_id_users_id_fk",- "tableFrom": "channel_messages",+ "channel_sections_user_id_users_id_fk": {+ "name": "channel_sections_user_id_users_id_fk",+ "tableFrom": "channel_sections","tableTo": "users","columnsFrom": ["user_id"],"columnsTo": ["id"],- "onDelete": "set null",+ "onDelete": "cascade","onUpdate": "no action"},- "channel_messages_agent_id_agents_id_fk": {- "name": "channel_messages_agent_id_agents_id_fk",- "tableFrom": "channel_messages",- "tableTo": "agents",- "columnsFrom": ["agent_id"],+ "channel_sections_workspace_id_workspaces_id_fk": {+ "name": "channel_sections_workspace_id_workspaces_id_fk",+ "tableFrom": "channel_sections",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],"columnsTo": ["id"],- "onDelete": "set null",- "onUpdate": "no action"- },- "channel_messages_thread_fk": {- "name": "channel_messages_thread_fk",- "tableFrom": "channel_messages",- "tableTo": "channel_threads",- "columnsFrom": ["channel_id", "thread_id"],- "columnsTo": ["channel_id", "id"],- "onDelete": "no action",+ "onDelete": "cascade","onUpdate": "no action"}},"compositePrimaryKeys": {},- "uniqueConstraints": {- "channel_messages_scope_unique": {- "name": "channel_messages_scope_unique",- "nullsNotDistinct": false,- "columns": ["channel_id", "id"]- }- },+ "uniqueConstraints": {},"policies": {},- "checkConstraints": {- "channel_messages_sender_check": {- "name": "channel_messages_sender_check",- "value": "\"channel_messages\".\"user_id\" IS NULL OR \"channel_messages\".\"agent_id\" IS NULL"- },- "channel_messages_user_sender_check": {- "name": "channel_messages_user_sender_check",- "value": "\"channel_messages\".\"routing_status\" <> 'reply' OR \"channel_messages\".\"user_id\" IS NULL"- },- "channel_messages_agent_sender_check": {- "name": "channel_messages_agent_sender_check",- "value": "\"channel_messages\".\"routing_status\" = 'reply' OR \"channel_messages\".\"agent_id\" IS NULL"- }- },+ "checkConstraints": {},"isRLSEnabled": false},"public.channel_threads": {@@ -13110,6 +15834,12 @@"primaryKey": false,"notNull": false},+ "agent_pair_key": {+ "name": "agent_pair_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },"title": {"name": "title","type": "text",@@ -13221,6 +15951,34 @@"method": "btree","with": {}},+ "channels_agent_pair_unique": {+ "name": "channels_agent_pair_unique",+ "columns": [+ {+ "expression": "agent_pair_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "coalesce(\"workspace_id\", '')",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"channels\".\"agent_pair_key\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },"channels_project_id_idx": {"name": "channels_project_id_idx","columns": [@@ -14401,12 +17159,24 @@"primaryKey": false,"notNull": true},+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },"message": {"name": "message","type": "text","primaryKey": false,"notNull": false},+ "source": {+ "name": "source",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },"status": {"name": "status","type": "text",@@ -14460,7 +17230,35 @@}],"isUnique": true,- "where": "\"user_contact_requests\".\"status\" = 'pending'",+ "where": "\"user_contact_requests\".\"status\" = 'pending' AND \"user_contact_requests\".\"workspace_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_contact_requests_workspace_pending_unique": {+ "name": "user_contact_requests_workspace_pending_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "requester_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "addressee_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"user_contact_requests\".\"status\" = 'pending' AND \"user_contact_requests\".\"workspace_id\" IS NOT NULL","concurrently": false,"method": "btree","with": {}@@ -14506,6 +17304,21 @@"concurrently": false,"method": "btree","with": {}+ },+ "user_contact_requests_workspace_id_idx": {+ "name": "user_contact_requests_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}}},"foreignKeys": {@@ -14526,6 +17339,15 @@"columnsTo": ["id"],"onDelete": "cascade","onUpdate": "no action"+ },+ "user_contact_requests_workspace_id_workspaces_id_fk": {+ "name": "user_contact_requests_workspace_id_workspaces_id_fk",+ "tableFrom": "user_contact_requests",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"}},"compositePrimaryKeys": {},@@ -14793,6 +17615,12 @@"primaryKey": false,"notNull": true},+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },"type": {"name": "type","type": "text",@@ -14875,7 +17703,35 @@}],"isUnique": true,- "where": "\"user_contacts\".\"contact_user_id\" IS NOT NULL",+ "where": "\"user_contacts\".\"contact_user_id\" IS NOT NULL AND \"user_contacts\".\"workspace_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_contacts_workspace_user_unique": {+ "name": "user_contacts_workspace_user_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "contact_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"user_contacts\".\"contact_user_id\" IS NOT NULL AND \"user_contacts\".\"workspace_id\" IS NOT NULL","concurrently": false,"method": "btree","with": {}@@ -14897,7 +17753,29 @@}],"isUnique": true,- "where": "\"user_contacts\".\"agent_id\" IS NOT NULL",+ "where": "\"user_contacts\".\"agent_id\" IS NOT NULL AND \"user_contacts\".\"workspace_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_contacts_workspace_agent_unique": {+ "name": "user_contacts_workspace_agent_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"user_contacts\".\"agent_id\" IS NOT NULL AND \"user_contacts\".\"workspace_id\" IS NOT NULL","concurrently": false,"method": "btree","with": {}@@ -14931,6 +17809,21 @@"concurrently": false,"method": "btree","with": {}+ },+ "user_contacts_workspace_id_idx": {+ "name": "user_contacts_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}}},"foreignKeys": {@@ -14943,6 +17836,15 @@"onDelete": "cascade","onUpdate": "no action"},+ "user_contacts_workspace_id_workspaces_id_fk": {+ "name": "user_contacts_workspace_id_workspaces_id_fk",+ "tableFrom": "user_contacts",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },"user_contacts_contact_user_id_users_id_fk": {"name": "user_contacts_contact_user_id_users_id_fk","tableFrom": "user_contacts",@@ -16593,6 +19495,12 @@"primaryKey": false,"notNull": false},+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },"name": {"name": "name","type": "varchar(255)",@@ -16678,6 +19586,22 @@"method": "btree","with": {}},+ "environments_project_id_unique": {+ "name": "environments_project_id_unique",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"environments\".\"project_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },"environments_workspace_visibility_idx": {"name": "environments_workspace_visibility_idx","columns": [@@ -16722,7 +19646,7 @@}],"isUnique": true,- "where": "\"environments\".\"workspace_id\" is null",+ "where": "\"environments\".\"workspace_id\" IS NULL AND \"environments\".\"project_id\" IS NULL","concurrently": false,"method": "btree","with": {}@@ -16750,7 +19674,7 @@}],"isUnique": true,- "where": "\"environments\".\"workspace_id\" is not null",+ "where": "\"environments\".\"workspace_id\" IS NOT NULL AND \"environments\".\"project_id\" IS NULL","concurrently": false,"method": "btree","with": {}@@ -16774,6 +19698,15 @@"columnsTo": ["id"],"onDelete": "restrict","onUpdate": "no action"+ },+ "environments_project_id_projects_id_fk": {+ "name": "environments_project_id_projects_id_fk",+ "tableFrom": "environments",+ "tableTo": "projects",+ "columnsFrom": ["project_id"],+ "columnsTo": ["id"],+ "onDelete": "restrict",+ "onUpdate": "no action"}},"compositePrimaryKeys": {},@@ -26990,6 +29923,27 @@"method": "btree","with": {}},+ "messages_user_id_topic_id_idx": {+ "name": "messages_user_id_topic_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },"messages_session_id_idx": {"name": "messages_session_id_idx","columns": [diff --git a/packages/database/migrations/meta/_journal.json b/packages/database/migrations/meta/_journal.jsonindex 6f82e26fd97..f89f76d22ac 100644--- a/packages/database/migrations/meta/_journal.json+++ b/packages/database/migrations/meta/_journal.json@@ -1582,6 +1582,13 @@"when": 1795165712823,"tag": "0225_artboard_boards_drop_old_sources","breakpoints": true+ },+ {+ "idx": 226,+ "version": "7",+ "when": 1795232920077,+ "tag": "0226_agent_share_grants",+ "breakpoints": true}],"version": "6"diff --git a/packages/database/src/models/__tests__/agentShare.test.ts b/packages/database/src/models/__tests__/agentShare.test.tsindex 617948e2ef1..e0b18653574 100644--- a/packages/database/src/models/__tests__/agentShare.test.ts+++ b/packages/database/src/models/__tests__/agentShare.test.ts@@ -770,6 +770,24 @@ describe('AgentShareModel', () => {).rejects.toMatchObject({ code: 'NOT_FOUND', message: 'Share not found' });});+ // A card share admits its grantees in their Channels, never through the link page.+ it('hides a card share page from non-owners, grantees included', async () => {+ const created = await agentShareModel.create(agentId, 'card');+ await AgentShareModel.grant(serverDB, {+ issuedAt: new Date(),+ shareId: created!.id,+ source: { channelId: 'channel', messageId: 'message', type: 'card' },+ userId: otherUserId,+ });++ await expect(+ AgentShareModel.findByShareIdWithAccessCheck(serverDB, created!.id, otherUserId),+ ).rejects.toMatchObject({ code: 'NOT_FOUND' });+ expect(+ (await AgentShareModel.findByShareIdWithAccessCheck(serverDB, created!.id, userId)).shareId,+ ).toBe(created!.id);+ });+it('allows authenticated access to a link share', async () => {const created = await agentShareModel.create(agentId, 'link');diff --git a/packages/database/src/models/__tests__/contact.test.ts b/packages/database/src/models/__tests__/contact.test.tsindex cdd58bbb4e5..9ba035c6639 100644--- a/packages/database/src/models/__tests__/contact.test.ts+++ b/packages/database/src/models/__tests__/contact.test.ts@@ -5,6 +5,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { getTestDB } from '../../core/getTestDB';import {agents,+ agentShareGrants,agentShares,channelMembers,channelMessages,@@ -16,6 +17,7 @@ import {workspaces,} from '../../schemas';import type { LobeChatDatabase } from '../../type';+import { AgentShareModel } from '../agentShare';import { ContactModel, parseContactHandle } from '../contact';const serverDB: LobeChatDatabase = await getTestDB();@@ -682,6 +684,168 @@ describe('contact cards', () => {});});+describe('an Agent shared only by card', () => {+ let channelId: string;+ const card = { agentId: bobAgent, type: 'agent' as const };++ /** A card of Bob's Agent in the Channel, sent by `sender`. */+ const postCard = async (sender: string, sequence = 1) => {+ const [message] = await serverDB+ .insert(channelMessages)+ .values({+ channelId,+ content: '[Contact card] Bob Helper',+ metadata: { card: { ...(await bobModel.resolveCard(card)), name: 'Bob Helper' } },+ requestKey: `card-${sequence}`,+ routingStatus: 'skipped',+ sequence,+ userId: sender,+ })+ .returning();+ return message.id;+ };++ beforeEach(async () => {+ await serverDB+ .update(agentShares)+ .set({ visibility: 'card' })+ .where(eq(agentShares.agentId, bobAgent));+ const [channel] = await serverDB+ .insert(channels)+ .values({ title: 'Card', userId: bob })+ .returning();+ channelId = channel.id;+ await serverDB.insert(channelMembers).values([+ { actorType: 'user', channelId, role: 'owner', userId: bob },+ { actorType: 'user', channelId, role: 'member', userId: alice },+ ]);+ });++ afterEach(async () => {+ await serverDB.delete(channels);+ });++ it('is shared by its owner only, and its link adds nothing', async () => {+ expect(await bobModel.resolveCard(card)).toMatchObject({ shareId: bobShareId });+ await expect(aliceModel.resolveCard(card)).rejects.toThrow('Agent not found');+ await expect(aliceModel.addAgent(bobShareId)).rejects.toThrow('Agent not found');+ });++ it("admits the person who adds it from the owner's card, and only them", async () => {+ const messageId = await postCard(bob);+ expect(await aliceModel.findAgentAccess(bobAgent)).toBeUndefined();++ expect(await aliceModel.addAgentFromCard(messageId)).toMatchObject({ agentId: bobAgent });++ expect(await aliceModel.findAgentAccess(bobAgent)).toMatchObject({ shareId: bobShareId });+ const [grant] = await serverDB.select().from(agentShareGrants);+ expect(grant).toMatchObject({+ shareId: bobShareId,+ source: { channelId, messageId, type: 'card' },+ userId: alice,+ });+ const item = (await aliceModel.list()).find((entry) => entry.type === 'agent');+ expect(item).toMatchObject({ available: true });+ expect(+ await AgentShareModel.isRunStillAuthorized(serverDB, {+ agentId: bobAgent,+ shareId: bobShareId,+ visitorUserId: alice,+ }),+ ).toBe(true);+ // Neither a run that names nobody nor another person is admitted by Alice's grant.+ for (const visitorUserId of [undefined, carol])+ expect(+ await AgentShareModel.isRunStillAuthorized(serverDB, {+ agentId: bobAgent,+ shareId: bobShareId,+ visitorUserId,+ }),+ ).toBe(false);+ });++ it('pauses with the share, and stays admitted when a link share becomes card-only', async () => {+ await aliceModel.addAgentFromCard(await postCard(bob));+ await serverDB+ .update(agentShares)+ .set({ visibility: 'private' })+ .where(eq(agentShares.agentId, bobAgent));+ expect(await aliceModel.findAgentAccess(bobAgent)).toBeUndefined();++ await serverDB+ .update(agentShares)+ .set({ visibility: 'card' })+ .where(eq(agentShares.agentId, bobAgent));+ expect(await aliceModel.findAgentAccess(bobAgent)).toMatchObject({ shareId: bobShareId });+ });++ it('refuses a card someone else passed on, or one I cannot see', async () => {+ await serverDB+ .insert(channelMembers)+ .values({ actorType: 'user', channelId, role: 'member', userId: carol });+ const passedOn = await postCard(alice, 1);+ await expect(carolModel.addAgentFromCard(passedOn)).rejects.toThrow('Agent not found');++ const fromOwner = await postCard(bob, 2);+ await serverDB+ .update(channelMembers)+ .set({ status: 'left' })+ .where(eq(channelMembers.userId, carol));+ await expect(carolModel.addAgentFromCard(fromOwner)).rejects.toThrow('Agent not found');+ expect(await serverDB.select().from(agentShareGrants)).toEqual([]);+ });++ it('adds a link share from anyone’s card without granting it', async () => {+ await serverDB+ .update(agentShares)+ .set({ visibility: 'link' })+ .where(eq(agentShares.agentId, bobAgent));+ await serverDB+ .insert(channelMembers)+ .values({ actorType: 'user', channelId, role: 'member', userId: carol });++ await carolModel.addAgentFromCard(await postCard(alice));++ expect(await carolModel.findAgentAccess(bobAgent)).toMatchObject({ shareId: bobShareId });+ expect(await serverDB.select().from(agentShareGrants)).toEqual([]);+ });++ it('lets the owner list and revoke grants', async () => {+ await aliceModel.addAgentFromCard(await postCard(bob));+ const shares = new AgentShareModel(serverDB, bob);++ expect(await shares.listGrants(bobAgent)).toEqual([+ expect.objectContaining({ user: expect.objectContaining({ id: alice }) }),+ ]);+ expect(await new AgentShareModel(serverDB, alice).listGrants(bobAgent)).toEqual([]);++ expect(await shares.revokeGrant(bobAgent, alice)).toBe(true);+ expect(await aliceModel.findAgentAccess(bobAgent)).toBeUndefined();+ expect(await shares.revokeGrant(bobAgent, alice)).toBe(false);+ });++ it('keeps a revoke: an earlier card cannot restore it, a later one from the owner does', async () => {+ const earlier = await postCard(bob, 1);+ await aliceModel.addAgentFromCard(earlier);+ const shares = new AgentShareModel(serverDB, bob);+ await shares.revokeGrant(bobAgent, alice);++ await expect(aliceModel.addAgentFromCard(earlier)).rejects.toThrow('Agent not found');+ expect(await aliceModel.findAgentAccess(bobAgent)).toBeUndefined();+ expect(await shares.listGrants(bobAgent)).toEqual([]);++ const later = await postCard(bob, 2);+ await serverDB+ .update(channelMessages)+ .set({ createdAt: new Date(Date.now() + 60_000) })+ .where(eq(channelMessages.id, later));+ await aliceModel.addAgentFromCard(later);+ expect(await aliceModel.findAgentAccess(bobAgent)).toMatchObject({ shareId: bobShareId });+ const [grant] = await serverDB.select().from(agentShareGrants);+ expect(grant).toMatchObject({ revokedAt: null, source: { messageId: later } });+ });+});+describe('a contact request from a card', () => {let channelId: string;let cardMessageId: string;diff --git a/packages/database/src/models/agentShare.ts b/packages/database/src/models/agentShare.tsindex fa8b98f13cf..36e53628d2b 100644--- a/packages/database/src/models/agentShare.ts+++ b/packages/database/src/models/agentShare.ts@@ -5,9 +5,13 @@ import {AGENT_SHARE_SLUG_PATTERN,RESERVED_AGENT_SHARE_SLUGS,} from '@lobechat/const';-import type { ShareVisibility } from '@lobechat/types';+import type {+ AgentShareGrantItem,+ AgentShareGrantSource,+ AgentShareVisibility,+} from '@lobechat/types';import { TRPCError } from '@trpc/server';-import { and, eq, exists, isNull, ne, sql } from 'drizzle-orm';+import { and, desc, eq, exists, isNotNull, isNull, lt, ne, sql } from 'drizzle-orm';import type {AgentShareConfig,@@ -15,8 +19,9 @@ import type {AgentShareItem,NormalizedAgentShareConfig,} from '../schemas';-import { agents, agentShares, users, workspaces } from '../schemas';+import { agents, agentShareGrants, agentShares, users, workspaces } from '../schemas';import type { LobeChatDatabase } from '../type';+import { agentShareAdmits } from '../utils/agentShareAdmits';import { normalizeInboxAgentAvatar, normalizeInboxAgentTitle } from '../utils/inboxAgent';import { notTrashed } from '../utils/softDelete';import { isUuid } from '../utils/uuid';@@ -253,7 +258,7 @@ export class AgentShareModel {});/** Create a private share by default, or return the existing share for the agent. */- create = async (agentId: string, visibility: ShareVisibility = 'private') => {+ create = async (agentId: string, visibility: AgentShareVisibility = 'private') => {const share = await this.withScopedAgentLock(agentId, async (tx, agent) => {// One row per agent, forever: `onConflictDoNothing` on `agentId` makes a// re-enable fall back to the SELECT below, returning the existing row@@ -432,7 +437,7 @@ export class AgentShareModel {*/updateVisibility = async (agentId: string,- visibility: ShareVisibility,+ visibility: AgentShareVisibility,): Promise<NormalizedAgentShareItem | null> =>this.withScopedAgentLock(agentId, async (tx) => {const [updated] = await tx@@ -587,7 +592,8 @@ export class AgentShareModel {/*** Whether an in-flight visitor run is STILL authorized to continue: the* agent's share row must exist, still be the SAME instance the run was- * authorized against (`shareId`), and still be `link`.+ * authorized against (`shareId`), and still admit the visitor ({@link admits}):+ * `link`, or `card` with the visitor's grant.** Turning sharing off flips `visibility` to `private` and KEEPS the row, so* a disable → re-enable cycle deliberately resumes the same link and must@@ -606,18 +612,136 @@ export class AgentShareModel {*/static isRunStillAuthorized = async (db: LobeChatDatabase,- params: { agentId: string; shareId: string },+ params: { agentId: string; shareId: string; visitorUserId?: string },): Promise<boolean> => {const [share] = await db- .select({ id: agentShares.id, visibility: agentShares.visibility })+ .select({ id: agentShares.id }).from(agentShares).innerJoin(agents, eq(agentShares.agentId, agents.id))- .where(and(eq(agentShares.agentId, params.agentId), notTrashed(agents.isDeleted)))+ .where(+ and(+ eq(agentShares.agentId, params.agentId),+ notTrashed(agents.isDeleted),+ AgentShareModel.admits(params.visitorUserId),+ ),+ )+ .limit(1);++ return !!share && share.id === params.shareId;+ };++ /** See {@link agentShareAdmits}. */+ static admits = agentShareAdmits;++ /** {@link admits} for a share already read: one grant lookup when it is a `card` share. */+ static admitsVisitor = async (+ db: LobeChatDatabase,+ share: { shareId: string; visibility: string },+ visitorUserId: string,+ ): Promise<boolean> => {+ if (share.visibility === 'link') return true;+ if (share.visibility !== 'card') return false;+ const [grant] = await db+ .select({ id: agentShareGrants.id })+ .from(agentShareGrants)+ .where(+ and(+ eq(agentShareGrants.shareId, share.shareId),+ eq(agentShareGrants.userId, visitorUserId),+ isNull(agentShareGrants.revokedAt),+ ),+ )+ .limit(1);+ return !!grant;+ };++ /**+ * Admit a person to a share through the owner's card they added the Agent from, sent at+ * `issuedAt`. Idempotent: a live grant keeps its first source. A revoked grant is restored+ * only by a card the owner sent after revoking it, so redeeming an older card again does not+ * undo the withdrawal. Returns whether the person holds a live grant afterwards.+ */+ static grant = async (+ db: Pick<LobeChatDatabase, 'insert'>,+ params: { issuedAt: Date; shareId: string; source: AgentShareGrantSource; userId: string },+ ): Promise<boolean> => {+ const { issuedAt, ...values } = params;+ const [row] = await db+ .insert(agentShareGrants)+ .values(values)+ .onConflictDoUpdate({+ set: { createdAt: sql`now()`, revokedAt: null, source: values.source },+ setWhere: and(+ isNotNull(agentShareGrants.revokedAt),+ lt(agentShareGrants.revokedAt, issuedAt),+ ),+ target: [agentShareGrants.shareId, agentShareGrants.userId],+ })+ .returning({ id: agentShareGrants.id });+ if (row) return true;+ // Neither inserted nor restored: the grant is either already live or revoked after this card.+ const [live] = await (db as LobeChatDatabase)+ .select({ id: agentShareGrants.id })+ .from(agentShareGrants)+ .where(+ and(+ eq(agentShareGrants.shareId, values.shareId),+ eq(agentShareGrants.userId, values.userId),+ isNull(agentShareGrants.revokedAt),+ ),+ ).limit(1);+ return !!live;+ };- return !!share && share.id === params.shareId && share.visibility === 'link';+ /** The people this Agent's share admits by card, newest first, for its owner. */+ listGrants = async (agentId: string): Promise<AgentShareGrantItem[]> => {+ const share = await this.getByAgentId(agentId);+ if (!share) return [];+ return this.db+ .select({+ createdAt: agentShareGrants.createdAt,+ user: {+ avatar: users.avatar,+ fullName: users.fullName,+ id: users.id,+ username: users.username,+ },+ })+ .from(agentShareGrants)+ .innerJoin(users, eq(users.id, agentShareGrants.userId))+ .where(and(eq(agentShareGrants.shareId, share.id), isNull(agentShareGrants.revokedAt)))+ .orderBy(desc(agentShareGrants.createdAt));};+ /**+ * Withdraw a person's card grant. The row stays, marked revoked, so the cards they already hold+ * cannot restore it; only a card the owner sends afterwards can. Under the same Agent row lock+ * as every share mutation, so a run admitted before the revoke is stopped at its next step by+ * `isRunStillAuthorized`.+ */+ revokeGrant = async (agentId: string, userId: string): Promise<boolean> =>+ !!(await this.withScopedAgentLock(agentId, async (tx) => {+ const [share] = await tx+ .select({ id: agentShares.id })+ .from(agentShares)+ .where(eq(agentShares.agentId, agentId))+ .limit(1);+ if (!share) return false;+ const removed = await tx+ .update(agentShareGrants)+ .set({ revokedAt: new Date() })+ .where(+ and(+ eq(agentShareGrants.shareId, share.id),+ eq(agentShareGrants.userId, userId),+ isNull(agentShareGrants.revokedAt),+ ),+ )+ .returning({ id: agentShareGrants.id });+ return removed.length > 0;+ }));+/*** Resolve public share metadata and derive ownership and billing scope from* the Agent. Sharing prevents transfers, so no separate tenancy snapshot is needed.@@ -732,7 +856,8 @@ export class AgentShareModel {// indistinguishable from a share that never existed, otherwise a// stranger can probe custom slugs / ids to learn which private shares// exist. Only the owner ever sees the private row.- if (!isOwner && share.visibility === 'private') {+ // A `card` share admits its grantees in their Channels only, never through its link page.+ if (!isOwner && share.visibility !== 'link') {throw new TRPCError({ code: 'NOT_FOUND', message: 'Share not found' });}};diff --git a/packages/database/src/models/contact.ts b/packages/database/src/models/contact.tsindex 8daee19fac8..91982ae6a5a 100644--- a/packages/database/src/models/contact.ts+++ b/packages/database/src/models/contact.ts@@ -30,10 +30,12 @@ import {workspaces,} from '../schemas';import type { LobeChatDatabase } from '../type';+import { agentShareAdmits } from '../utils/agentShareAdmits';import { normalizeInboxAgentAvatar, normalizeInboxAgentTitle } from '../utils/inboxAgent';import { ilikeContains } from '../utils/like';import { notTrashed } from '../utils/softDelete';import { isUuid } from '../utils/uuid';+import { AgentShareModel } from './agentShare';const userProfileColumns = {avatar: users.avatar,@@ -207,7 +209,11 @@ export class ContactModel {role === 'external'? []: this.db- .select({ createdAt: userContacts.createdAt, ...agentProfileColumns })+ .select({+ admitted: sql<boolean>`${agentShareAdmits(this.userId)}`,+ createdAt: userContacts.createdAt,+ ...agentProfileColumns,+ }).from(userContacts).innerJoin(agents, eq(agents.id, userContacts.agentId)).innerJoin(agentShares, eq(agentShares.agentId, agents.id))@@ -218,7 +224,8 @@ export class ContactModel {const agentItems: ContactAgentItem[] = sharedAgents.map((row) => ({agent: toAgentProfile(row),- available: row.visibility === 'link' && !row.isDeleted,+ // A workspace's Agent entries are shared, but a card share admits each person on their own.+ available: row.admitted && !row.isDeleted,createdAt: row.createdAt,type: 'agent',}));@@ -825,10 +832,18 @@ export class ContactModel {messageId: string,addresseeId: string,): Promise<ContactRequestSource | undefined> => {+ const found = await this.findCardMessage(tx, messageId);+ if (found?.card.type !== 'user' || found.card.userId !== addresseeId) return;+ return { channelId: found.channelId, messageId, referrerId: found.senderId, type: 'card' };+ };++ /** A live card message in a Channel I am an active member of, with its card. */+ private findCardMessage = async (tx: Pick<LobeChatDatabase, 'select'>, messageId: string) => {if (!isUuid(messageId)) return;const [row] = await tx.select({channelId: channelMessages.channelId,+ createdAt: channelMessages.createdAt,metadata: channelMessages.metadata,senderId: channelMessages.userId,})@@ -844,21 +859,17 @@ export class ContactModel {.where(eq(channelMessages.id, messageId)).limit(1);const card = contactCardOf(row?.metadata);- if (- !row ||- channelMessageDeletedAt(row.metadata) ||- card?.type !== 'user' ||- card.userId !== addresseeId- )- return;- return { channelId: row.channelId, messageId, referrerId: row.senderId, type: 'card' };+ if (!row || !card || channelMessageDeletedAt(row.metadata)) return;+ return { ...row, card };};/*** A contact the caller may share as a card, with its snapshot. A person: the caller, one of- * their contacts, or a fellow member of the workspace. An Agent: any Agent whose link share is- * on, since anyone signed in can add it anyway; the caller's own Agent with sharing off is- * refused so sharing it never publishes it by surprise.+ * their contacts, or a fellow member of the workspace. An Agent: its owner may share it while+ * its share is `card` or `link`, and anyone may pass on a `link` share, since anyone signed in+ * can add it anyway. Only the owner's card admits people to a `card` share. An owner whose+ * share is off is told to turn card sharing on (`agentShare.enableCardShare`), never refused+ * outright, so a client can do that and send in one step.*/resolveCard = async (input: ContactCardInput): Promise<ContactCard> => {if ((await this.scopeRole()) === 'external')@@ -882,19 +893,19 @@ export class ContactModel {const [row] = await this.db.select(agentProfileColumns).from(agents)- .leftJoin(- agentShares,- and(eq(agentShares.agentId, agents.id), eq(agentShares.visibility, 'link')),- )+ .leftJoin(agentShares, eq(agentShares.agentId, agents.id)).leftJoin(owners, eq(owners.id, agents.userId)).where(and(eq(agents.id, input.agentId), notTrashed(agents.isDeleted))).limit(1);- if (!row?.shareId) {- if (row?.ownerId === this.userId)+ const isOwner = !!row && row.ownerId === this.userId;+ const shareable =+ row?.shareId && (row.visibility === 'link' || (row.visibility === 'card' && isOwner));+ if (!shareable) {+ if (isOwner)throw new TRPCError({ code: 'PRECONDITION_FAILED', message: 'Turn on sharing first' });throw new TRPCError({ code: 'NOT_FOUND', message: 'Agent not found' });}- const profile = toAgentProfile({ ...row, shareId: row.shareId });+ const profile = toAgentProfile({ ...row, shareId: row.shareId! });return {agentId: profile.agentId,avatar: profile.avatar,@@ -928,6 +939,64 @@ export class ContactModel {return toAgentProfile(share);};+ /**+ * Add another person's Agent from its card in a Channel I am an active member of. A card its+ * owner sent also grants me its share, which is what admits me to a `card` share and keeps me+ * admitted if a `link` share later becomes `card`; a card anyone else passed on only works while+ * the share is `link`, like the link itself.+ */+ addAgentFromCard = async (messageId: string): Promise<ContactAgentProfile> => {+ if ((await this.scopeRole()) === 'external')+ throw new TRPCError({ code: 'FORBIDDEN', message: 'Only members add Agents here' });+ const notFound = () => new TRPCError({ code: 'NOT_FOUND', message: 'Agent not found' });+ const message = await this.findCardMessage(this.db, messageId);+ const card = message?.card;+ if (!message || card?.type !== 'agent') throw notFound();++ const [share] = await this.db+ .select(agentProfileColumns)+ .from(agentShares)+ .innerJoin(agents, eq(agents.id, agentShares.agentId))+ .leftJoin(owners, eq(owners.id, agents.userId))+ .where(+ and(+ eq(agentShares.id, card.shareId),+ eq(agents.id, card.agentId),+ notTrashed(agents.isDeleted),+ ),+ )+ .limit(1);+ if (!share?.ownerId) throw notFound();+ if (share.ownerId === this.userId)+ throw new TRPCError({ code: 'BAD_REQUEST', message: 'This Agent is already yours' });+ const fromOwner = message.senderId === share.ownerId;+ if (!(share.visibility === 'link' || (share.visibility === 'card' && fromOwner)))+ throw notFound();++ await this.db.transaction(async (tx) => {+ const granted =+ fromOwner &&+ (await AgentShareModel.grant(tx, {+ issuedAt: message.createdAt,+ shareId: share.shareId,+ source: { channelId: message.channelId, messageId, type: 'card' },+ userId: this.userId,+ }));+ // The owner revoked me after sending this card: it no longer admits me to a `card` share.+ if (share.visibility === 'card' && !granted) throw notFound();+ await tx+ .insert(userContacts)+ .values({+ agentId: share.agentId,+ type: 'agent',+ userId: this.userId,+ workspaceId: this.workspaceId,+ })+ .onConflictDoNothing();+ });+ return toAgentProfile(share);+ };+removeAgent = async (agentId: string) => {await this.db.delete(userContacts)@@ -957,7 +1026,7 @@ export class ContactModel {and(this.agentEntryWhere(),eq(userContacts.agentId, agentId),- eq(agentShares.visibility, 'link'),+ agentShareAdmits(this.userId),notTrashed(agents.isDeleted),),)diff --git a/packages/database/src/repositories/channel/agent.ts b/packages/database/src/repositories/channel/agent.tsindex 76de7ba2cfc..74f334afafb 100644--- a/packages/database/src/repositories/channel/agent.ts+++ b/packages/database/src/repositories/channel/agent.ts@@ -17,6 +17,7 @@ import { agents, agentShares, channelMembers, users, userSettings } from '../../import type { LobeChatDatabase, Transaction } from '../../type';import { agentUsableByWhere } from '../../utils/agent-access';import { mergeAgentDefaultConfig } from '../../utils/agentConfig';+import { agentShareAdmits } from '../../utils/agentShareAdmits';import { normalizeInboxAgentTitle } from '../../utils/inboxAgent';import { notTrashed } from '../../utils/softDelete';import { ChannelError } from './error';@@ -117,8 +118,8 @@ export interface ChannelAddAgentInput {}/**- * Another person's Agent that `userId` may talk to through its live link share. A link share is- * open to anyone signed in, so no contact entry is needed; only a direct conversation (personal+ * Another person's Agent that `userId` may talk to through its live share: a link share, open to+ * anyone signed in, or a card share its owner granted them. No contact entry is needed; only a direct conversation (personal* or in a workspace) can hold one, because the share admits one person at a time and counts its* limits per person.*/@@ -143,7 +144,7 @@ export const findSharedChannelAgent = async (.where(and(eq(agents.id, agentId),- eq(agentShares.visibility, 'link'),+ agentShareAdmits(userId),notTrashed(agents.isDeleted),ne(agents.userId, userId),),diff --git a/packages/database/src/schemas/agentShare.ts b/packages/database/src/schemas/agentShare.tsindex 1b03c060cba..04b80fd10dd 100644--- a/packages/database/src/schemas/agentShare.ts+++ b/packages/database/src/schemas/agentShare.ts@@ -1,8 +1,14 @@-import type { AgentShareDemoCase, AgentShareToolGrant } from '@lobechat/types';+import type {+ AgentShareDemoCase,+ AgentShareGrantSource,+ AgentShareToolGrant,+ AgentShareVisibility,+} from '@lobechat/types';import { index, integer, jsonb, pgTable, text, uniqueIndex, uuid } from 'drizzle-orm/pg-core';-import { timestamps } from './_helpers';+import { createdAt, timestamps, timestamptz } from './_helpers';import { agents } from './agent';+import { users } from './user';export type AgentShareDeviceAccess = 'allowlist' | 'contacts' | 'none';@@ -164,7 +170,7 @@ export const agentShares = pgTable(.notNull().references(() => agents.id, { onDelete: 'cascade' }),- visibility: text('visibility').default('private').notNull(), // 'private' | 'link'+ visibility: text('visibility').$type<AgentShareVisibility>().default('private').notNull(),shareConfig: jsonb('share_config').$type<AgentShareConfig>(),@@ -187,3 +193,40 @@ export const agentShares = pgTable(export type NewAgentShare = typeof agentShares.$inferInsert;export type AgentShareItem = typeof agentShares.$inferSelect;++/**+ * The people a share admits besides its link: each added the Agent from a card its owner shared+ * into a Channel they are in, until the owner revokes them. A `card` share admits only them;+ * pausing the share pauses them too,+ * and a replaced share (deleted, or its Agent recreated) starts with none.+ */+export const agentShareGrants = pgTable(+ 'agent_share_grants',+ {+ // Only ever addressed through the share and the person, so no id prefix.+ id: uuid('id').defaultRandom().primaryKey().notNull(),+ shareId: uuid('share_id')+ .references(() => agentShares.id, { onDelete: 'cascade' })+ .notNull(),++ userId: text('user_id')+ .references(() => users.id, { onDelete: 'cascade' })+ .notNull(),++ source: jsonb('source').$type<AgentShareGrantSource>().notNull(),+ /**+ * Set when the owner withdrew the grant. The row is kept so a card sent before the withdrawal+ * cannot restore it; only a card the owner sends afterwards does.+ */+ revokedAt: timestamptz('revoked_at'),++ createdAt: createdAt(),+ },+ (t) => [+ uniqueIndex('agent_share_grants_share_user_unique').on(t.shareId, t.userId),+ // Serves the cascade from users.+ index('agent_share_grants_user_id_idx').on(t.userId),+ ],+);++export type AgentShareGrantRow = typeof agentShareGrants.$inferSelect;diff --git a/packages/database/src/utils/agentShareAdmits.ts b/packages/database/src/utils/agentShareAdmits.tsnew file mode 100644index 00000000000..906a530222e--- /dev/null+++ b/packages/database/src/utils/agentShareAdmits.ts@@ -0,0 +1,22 @@+import type { SQL } from 'drizzle-orm';+import { and, eq, exists, or, sql } from 'drizzle-orm';++import { agentShareGrants, agentShares } from '../schemas';++/**+ * Whether the joined `agent_shares` row admits a visitor: a `link` share admits anyone signed in,+ * a `card` share only the people its owner granted it to by card and has not revoked. Without a visitor only a `link`+ * share does, so a caller that cannot name one fails closed on a `card` share.+ */+export const agentShareAdmits = (visitorUserId: string | undefined): SQL =>+ visitorUserId+ ? or(+ eq(agentShares.visibility, 'link'),+ and(+ eq(agentShares.visibility, 'card'),+ exists(+ sql`(SELECT 1 FROM ${agentShareGrants} WHERE ${agentShareGrants.shareId} = ${agentShares.id} AND ${agentShareGrants.userId} = ${visitorUserId} AND ${agentShareGrants.revokedAt} IS NULL)`,+ ),+ ),+ )!+ : eq(agentShares.visibility, 'link');diff --git a/packages/types/src/agent/share.ts b/packages/types/src/agent/share.tsindex 76122a98ea8..53917973a46 100644--- a/packages/types/src/agent/share.ts+++ b/packages/types/src/agent/share.ts@@ -1,6 +1,35 @@import type { ShareVisibility } from '../topic';import type { CollectionWorkVersionMetadata, WorkItem } from '../work';+/**+ * An Agent share's reach. `private` pauses it for everyone but the owner. `card` admits only the+ * people the owner granted it to by sharing the Agent's card into a Channel; its link page stays+ * closed. `link` opens it to anyone signed in with the link, card grantees included.+ */+export type AgentShareVisibility = ShareVisibility | 'card';++/** A share that admits someone besides its owner: by link, or by an owner's card. */+export const isLiveAgentShareVisibility = (visibility: string | null | undefined) =>+ visibility === 'link' || visibility === 'card';++/** Where an Agent share grant came from: the owner's card message the grantee added it from. */+export interface AgentShareGrantSource {+ channelId: string;+ messageId: string;+ type: 'card';+}++/** A person the owner granted a `card` share to, for the owner's share settings. */+export interface AgentShareGrantItem {+ createdAt: Date;+ user: {+ avatar: string | null;+ fullName: string | null;+ id: string;+ username: string | null;+ };+}+/** A creator-authored visitor task, independent of the agent's opening questions. */export interface AgentShareDemoCase {description: string;@@ -130,7 +159,7 @@ export interface SharedAgentData {* direct media input.*/uploadAbility: SharedAgentUploadAbility;- visibility: ShareVisibility;+ visibility: AgentShareVisibility;}/**