🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(goal): workspace visibility for goals (#22027)
Arvin Xu4cf8dc1c9ca9
diff --git a/apps/cli/src/commands/goal/access.ts b/apps/cli/src/commands/goal/access.tsnew file mode 100644index 00000000000..0c4a117256d--- /dev/null+++ b/apps/cli/src/commands/goal/access.ts@@ -0,0 +1,50 @@+import type { Command } from 'commander';++import { getTrpcClient } from '../../api/client';+import { log } from '../../utils/logger';++/** Who runs a goal and who can see it: its agents and its workspace visibility. */+export function registerGoalAccessCommands(goal: Command) {+ goal+ .command('set-agent <id> <agent>')+ .description(+ 'Hand the goal to a different supervising agent (its unfinished tasks follow unless the goal has a task agent)',+ )+ .option('--goal-only', 'Only change the goal-level agent; leave existing tasks as assigned')+ .action(async (id: string, agentId: string, options: { goalOnly?: boolean }) => {+ const result = await (+ await getTrpcClient()+ ).goal.setAgent.mutate({ agentId, goalOnly: options.goalOnly, id });+ log.info(result.message);+ });++ goal+ .command('set-task-agent <id> <agent>')+ .description(+ 'Route the goal\'s tasks to a dedicated executor; "none" hands them back to the goal agent',+ )+ .option('--goal-only', 'Only change future tasks; leave existing tasks as assigned')+ .action(async (id: string, agent: string, options: { goalOnly?: boolean }) => {+ const result = await (+ await getTrpcClient()+ ).goal.setTaskAgent.mutate({+ agentId: agent === 'none' ? null : agent,+ goalOnly: options.goalOnly,+ id,+ });+ log.info(result.message);+ });++ goal+ .command('set-visibility <id> <visibility>')+ .description(+ 'Make a workspace goal private (only you see it) or public (every member does); its tasks follow. A public goal needs public agents',+ )+ .action(async (id: string, visibility: string) => {+ if (visibility !== 'private' && visibility !== 'public')+ throw new Error('visibility must be one of: private, public');+ const result = await (await getTrpcClient()).goal.setVisibility.mutate({ id, visibility });+ const moved = result.data.taskIds.length;+ log.info(moved ? `${result.message}; ${moved} task(s) moved with it` : result.message);+ });+}diff --git a/apps/cli/src/commands/goal/index.ts b/apps/cli/src/commands/goal/index.tsindex 897293e21d4..853cd41e586 100644--- a/apps/cli/src/commands/goal/index.ts+++ b/apps/cli/src/commands/goal/index.ts@@ -19,6 +19,7 @@ import { getTrpcClient } from '../../api/client';import { confirm, outputJson, printTable, truncate } from '../../utils/format';import { log } from '../../utils/logger';import { resolveAppUrlBuilder } from '../task/url';+import { registerGoalAccessCommands } from './access';import { registerGoalGraphEditCommands } from './graphEdit';import {type GoalMetricState,@@ -159,6 +160,9 @@ function printGraph(graph: GoalGraphSnapshot, metrics?: GoalMetricState) {goal.config?.pausedBy ? ` · paused by ${goal.config.pausedBy}` : ''}]`,);+ // Older servers do not send it; personal goals are private whatever the column says.+ if (goal.workspaceId && goal.visibility)+ console.log(`${pc.dim('Visibility:')} ${goal.visibility}`);if (goal.subjectType)console.log(`${pc.dim('Subject:')} ${`${goal.subjectType} ${goal.subjectId ?? ''}`.trim()}`);if (goal.requirement) console.log(`${pc.dim('Requirement:')} ${goal.requirement}`);@@ -588,6 +592,10 @@ export function registerGoalCommand(program: Command) {"Dedicated executor for the goal's tasks (defaults to the goal agent)",).option('--project <id>', 'Project ID')+ .option(+ '--visibility <visibility>',+ 'Workspace visibility: private (only you) or public (every member). Defaults to private when the goal or task agent is private, else public',+ ).option('--explore <instruction>', 'Explore alternatives using completed experiment results').option('--max-experiments <n>', 'Maximum experiment nodes (requires --explore, default 10)').option(@@ -628,6 +636,9 @@ export function registerGoalCommand(program: Command) {if (options.rollout && !['canary', 'full', 'off'].includes(options.rollout)) {throw new Error('--rollout must be one of: canary, full, off');}+ if (options.visibility && !['private', 'public'].includes(options.visibility)) {+ throw new Error('--visibility must be one of: private, public');+ }const seedTasks = [...((options.task as string[] | undefined) ?? []),...(options.taskFile ? parseTaskFile(await readFile(options.taskFile, 'utf8')) : []),@@ -701,6 +712,7 @@ export function registerGoalCommand(program: Command) {requirement: options.requirement,title,tasks: seedTasks.length ? seedTasks : undefined,+ visibility: options.visibility,};// A topic goal takes its agent and topic from the running// operation on the server; the CLI only names the run. Device and gateway@@ -1159,35 +1171,7 @@ export function registerGoalCommand(program: Command) {},);- goal- .command('set-agent <id> <agent>')- .description(- 'Hand the goal to a different supervising agent (its unfinished tasks follow unless the goal has a task agent)',- )- .option('--goal-only', 'Only change the goal-level agent; leave existing tasks as assigned')- .action(async (id: string, agentId: string, options: { goalOnly?: boolean }) => {- const result = await (- await getTrpcClient()- ).goal.setAgent.mutate({ agentId, goalOnly: options.goalOnly, id });- log.info(result.message);- });-- goal- .command('set-task-agent <id> <agent>')- .description(- 'Route the goal\'s tasks to a dedicated executor; "none" hands them back to the goal agent',- )- .option('--goal-only', 'Only change future tasks; leave existing tasks as assigned')- .action(async (id: string, agent: string, options: { goalOnly?: boolean }) => {- const result = await (- await getTrpcClient()- ).goal.setTaskAgent.mutate({- agentId: agent === 'none' ? null : agent,- goalOnly: options.goalOnly,- id,- });- log.info(result.message);- });+ registerGoalAccessCommands(goal);goal.command('bind-topic <id>')diff --git a/apps/server/src/routers/lambda/goal/configuration.ts b/apps/server/src/routers/lambda/goal/configuration.tsindex 906aafc9cc5..8bfbd8978ce 100644--- a/apps/server/src/routers/lambda/goal/configuration.ts+++ b/apps/server/src/routers/lambda/goal/configuration.ts@@ -1,5 +1,5 @@import { GOAL_TITLE_MAX_LENGTH } from '@lobechat/const/goal';-import { MAX_GOAL_METRIC_CRITERIA } from '@lobechat/types';+import { GOAL_VISIBILITIES, MAX_GOAL_METRIC_CRITERIA } from '@lobechat/types';import { TRPCError } from '@trpc/server';import { z } from 'zod';@@ -174,6 +174,20 @@ export const configurationRouter = router({mapGoalError(error, 'setTaskAgent');}}),+ /**+ * Make a workspace goal private (only its creator sees it) or public. Its+ * own Tasks follow; a public goal needs public agents.+ */+ setVisibility: goalWriteProcedure+ .input(idInput.extend({ visibility: z.enum(GOAL_VISIBILITIES) }))+ .mutation(async ({ ctx, input: { id, visibility } }) => {+ try {+ const data = await ctx.goalService.setVisibility(id, visibility);+ return { data, message: 'Goal visibility updated', success: true };+ } catch (error) {+ mapGoalError(error, 'setVisibility');+ }+ }),/*** Pick the model the goal agent plans with (`null` falls back to the agent's* own). Tasks keep their own model.diff --git a/apps/server/src/routers/lambda/goal/creation.ts b/apps/server/src/routers/lambda/goal/creation.tsindex 48b34510bbb..b93088260c6 100644--- a/apps/server/src/routers/lambda/goal/creation.ts+++ b/apps/server/src/routers/lambda/goal/creation.ts@@ -1,5 +1,5 @@import { ROLLOUT_MAX_CANARY_SIZE } from '@lobechat/const/goal';-import { MAX_GOAL_METRIC_CRITERIA } from '@lobechat/types';+import { GOAL_VISIBILITIES, MAX_GOAL_METRIC_CRITERIA } from '@lobechat/types';import { TRPCError } from '@trpc/server';import { z } from 'zod';@@ -121,6 +121,8 @@ const conversationGoalInput = z.object({]),).optional(),+ /** Workspace visibility; omitted, a private goal or task agent makes it private. */+ visibility: z.enum(GOAL_VISIBILITIES).optional(),});const createGoalInput = conversationGoalInput.extend({diff --git a/apps/server/src/routers/lambda/goal/index.procedures.test.ts b/apps/server/src/routers/lambda/goal/index.procedures.test.tsindex 31bd0d9b7ad..041eee6459c 100644--- a/apps/server/src/routers/lambda/goal/index.procedures.test.ts+++ b/apps/server/src/routers/lambda/goal/index.procedures.test.ts@@ -67,6 +67,7 @@ function expected(): Array<['setModel', 'mutation', 13],['setTaskAgent', 'mutation', 13],['setTaskModel', 'mutation', 13],+ ['setVisibility', 'mutation', 13],['start', 'mutation', 13],['startOperation', 'mutation', 8],['submitOperationPlan', 'mutation', 8],diff --git a/apps/server/src/routers/lambda/project.ts b/apps/server/src/routers/lambda/project.tsindex 7f5b8a6d7f5..0ec357677d4 100644--- a/apps/server/src/routers/lambda/project.ts+++ b/apps/server/src/routers/lambda/project.ts@@ -13,6 +13,7 @@ import type { LobeChatDatabase } from '@/database/type';import { router } from '@/libs/trpc/lambda';import { serverDatabase } from '@/libs/trpc/lambda/middleware';import { createDefaultChannel } from '@/server/services/channel/defaultChannel';+import { GoalService } from '@/server/services/goal';import { assertCanPerformResourceAction } from '@/server/services/resourcePermission';/**@@ -432,6 +433,7 @@ export const projectRouter = router({).mutation(async ({ ctx, input: { id, ...input } }) => {try {+ let previousVisibility: string | undefined;if (input.visibility !== undefined) {const project = requireResult(await ctx.projectModel.findById(id));if (project.userId !== ctx.userId) {@@ -440,12 +442,18 @@ export const projectRouter = router({message: 'Only the project creator can change its visibility',});}+ previousVisibility = project.visibility;}+ const updated = requireResult(await ctx.projectModel.update(id, input));+ // Members can no longer see the project, so they must not keep opening its goals.+ if (input.visibility === 'private' && previousVisibility === 'public')+ await new GoalService(+ ctx.serverDB,+ ctx.userId,+ ctx.workspaceId ?? undefined,+ ).privatizeProjectGoals(id);return {- data: await withMainAgent(- ctx.projectModel,- requireResult(await ctx.projectModel.update(id, input)),- ),+ data: await withMainAgent(ctx.projectModel, updated),message: 'Project updated',success: true,};diff --git a/apps/server/src/services/goal/GoalService/__tests__/surface.test.ts b/apps/server/src/services/goal/GoalService/__tests__/surface.test.tsindex 33c6ae460b2..1ba48785b4a 100644--- a/apps/server/src/services/goal/GoalService/__tests__/surface.test.ts+++ b/apps/server/src/services/goal/GoalService/__tests__/surface.test.ts@@ -83,6 +83,7 @@ const METHODS = ['pendingForIsland','planDecomposition','planMachineRecoveryFor',+ 'privatizeProjectGoals','readRunDevicePresence','reassignUnfinishedTasks','recordObservation',@@ -110,6 +111,7 @@ const METHODS = ['setPauseReason','setTaskAgent','setTaskModel',+ 'setVisibility','settleTerminalAcceptance','status','stopFencedTasks',diff --git a/apps/server/src/services/goal/GoalService/creation.ts b/apps/server/src/services/goal/GoalService/creation.tsindex f2c0155ba68..77147d5efac 100644--- a/apps/server/src/services/goal/GoalService/creation.ts+++ b/apps/server/src/services/goal/GoalService/creation.ts@@ -13,6 +13,7 @@ import { GoalAssignmentService, staleModelSlots } from '../assignment';import { GoalManagerService } from '../manager';import { DEFAULT_MANAGER_MAX_TURNS } from '../recoveryPolicy';import { seedGoalTasks } from '../seedTasks';+import { assertGoalAgentVisibilityCompat, resolveGoalVisibility } from '../visibility';import type { CreateGoalGraphInput, GoalServiceContext } from './types';/**@@ -138,6 +139,10 @@ export const bindTopic = async (userId: ctx.userId,workspaceId: ctx.workspaceId,});+ // Only a change of agent can break visibility; re-binding the same agent is a no-op here.+ const current = await ctx.goalModel.findById(goalId);+ if (current && current.agentId !== agentId)+ await assertGoalAgentVisibilityCompat(ctx.db, current, [agentId]);// One transaction: the agent change and the Task moves it implies commit// together. Committed apart, a failed move left the goal already on the new@@ -279,6 +284,14 @@ export const create = async (}config = { ...config, exploration: { maxExperiments, instruction } };}+ // Resolved before any write: a refused visibility must not leave criteria behind.+ const visibility = await resolveGoalVisibility(+ ctx.db,+ input.visibility,+ [goalAgentId, config?.taskAgentId],+ input.projectId,+ );+if (input.criteria?.length) {const criteriaIds = await new VerifyPlanGeneratorService(ctx.db,@@ -312,6 +325,7 @@ export const create = async (? { subjectId: input.topicId, subjectType: 'topic' as const }: { subjectType: 'standalone' as const }),title: input.title,+ visibility,});// `/goal` is an agent making the call. Seeding through the user-attributed// model would file the whole opening graph under the goal's owner, which isdiff --git a/apps/server/src/services/goal/GoalService/dispatch.ts b/apps/server/src/services/goal/GoalService/dispatch.tsindex b923c7af9bf..b70342a8339 100644--- a/apps/server/src/services/goal/GoalService/dispatch.ts+++ b/apps/server/src/services/goal/GoalService/dispatch.ts@@ -93,6 +93,9 @@ export const createResponsibleTask = async (instruction: ctx.buildTaskInstruction(graph, frontier.title, description),name: frontier.title,projectId: graph.goal.projectId ?? undefined,+ // A private goal's Tasks stay with it: a public executor would otherwise+ // publish them. A public goal leaves it to the agent, as any Task does.+ ...(graph.goal.visibility === 'private' ? { visibility: 'private' as const } : {}),});// The terminal Goal-acceptance Task is gated on the goal's structured// criteria when it has them: the verify plan materializes exactly thosediff --git a/apps/server/src/services/goal/GoalService/editing.ts b/apps/server/src/services/goal/GoalService/editing.tsindex 74efce60c57..84c894c1d6e 100644--- a/apps/server/src/services/goal/GoalService/editing.ts+++ b/apps/server/src/services/goal/GoalService/editing.ts@@ -1,11 +1,14 @@-import type { GoalEdgeKind, GoalItem } from '@lobechat/types';+import type { GoalEdgeKind, GoalItem, GoalVisibility } from '@lobechat/types';import { TRPCError } from '@trpc/server';+import { and, eq, inArray } from 'drizzle-orm';import { GoalModel } from '@/database/models/goal';import { GoalGraphModel } from '@/database/models/goalGraph';import { TaskModel } from '@/database/models/task';import { TaskTopicModel } from '@/database/models/taskTopic';import { TopicModel } from '@/database/models/topic';+import { TaskSubtreeRepository } from '@/database/repositories/taskSubtree';+import { goals } from '@/database/schemas';import { TaskService } from '../../task';import { GoalAssignmentService } from '../assignment';@@ -16,6 +19,11 @@ import {} from '../decideNextMove';import { managerTurnsSpent } from '../recoveryPolicy';import { isGoalReportNode } from '../report';+import {+ assertGoalAgentVisibilityCompat,+ assertGoalProjectVisibilityCompat,+ goalTasksToCascade,+} from '../visibility';import type { CreateGoalNodeInput, GoalServiceContext } from './types';/**@@ -122,6 +130,88 @@ export const setTaskAgent = (...args: Parameters<GoalAssignmentService['setTaskAgent']>) => assignmentFor(ctx).setTaskAgent(...args);+/**+ * Move a workspace goal to a new visibility; its own Tasks follow (see+ * `goalTasksToCascade`). Only the creator may: a private goal is invisible to+ * everyone else, and making someone's public goal private would take it out+ * of their hands. A public goal needs public agents, as a public Task does.+ */+export const setVisibility = async (+ ctx: GoalServiceContext,+ goalId: string,+ visibility: GoalVisibility,+): Promise<{ goal: GoalItem; taskIds: string[] }> => {+ if (!ctx.workspaceId)+ throw new TRPCError({+ code: 'BAD_REQUEST',+ message: 'Visibility only applies to workspace goals',+ });+ const goal = await ctx.goalModel.findById(goalId);+ if (!goal) throw new TRPCError({ code: 'NOT_FOUND', message: 'Goal not found' });+ if (goal.userId !== ctx.userId)+ throw new TRPCError({+ code: 'FORBIDDEN',+ message: 'Only the goal creator can change its visibility',+ });+ if (goal.visibility === visibility) return { goal, taskIds: [] };+ await assertGoalAgentVisibilityCompat(ctx.db, { ...goal, visibility }, [+ goal.agentId,+ goal.config?.taskAgentId,+ ]);+ await assertGoalProjectVisibilityCompat(ctx.db, { ...goal, visibility });++ // The goal first: on the way to private, a failure partway through the+ // Tasks leaves the goal already hidden rather than a public goal over+ // half-private work. A retry picks up the Tasks that did not move.+ const updated = await ctx.goalModel.update(goalId, { visibility });+ if (!updated) throw new TRPCError({ code: 'NOT_FOUND', message: 'Goal not found' });+ const subtree = new TaskSubtreeRepository(ctx.db, ctx.userId, ctx.workspaceId);+ const taskIds = await goalTasksToCascade(ctx.db, goal, visibility);+ for (const taskId of taskIds) await subtree.updateVisibility(taskId, visibility);+ return { goal: updated, taskIds };+};++/**+ * A project went private, so its public goals follow: members could otherwise+ * still open goals of a project they can no longer see. The caller's own goals+ * move with their Tasks (`setVisibility`). Another member's goal is only+ * hidden: the project's creator cannot act on that member's Tasks, just as a+ * project's own Tasks do not cascade when it goes private.+ */+export const privatizeProjectGoals = async (+ ctx: GoalServiceContext,+ projectId: string,+): Promise<string[]> => {+ if (!ctx.workspaceId) return [];+ const rows = await ctx.db+ .select({ id: goals.id, isDeleted: goals.isDeleted, userId: goals.userId })+ .from(goals)+ .where(+ and(+ eq(goals.projectId, projectId),+ eq(goals.workspaceId, ctx.workspaceId),+ eq(goals.visibility, 'public'),+ ),+ );+ if (rows.length === 0) return [];+ for (const row of rows)+ if (row.userId === ctx.userId && !row.isDeleted) await setVisibility(ctx, row.id, 'private');+ // Everything left — other members' goals, and trashed ones `findById` cannot reach.+ await ctx.db+ .update(goals)+ .set({ updatedAt: new Date(), visibility: 'private' })+ .where(+ and(+ inArray(+ goals.id,+ rows.map((row) => row.id),+ ),+ eq(goals.visibility, 'public'),+ ),+ );+ return rows.map((row) => row.id);+};+/** The model planning turns run on; see `GoalAssignmentService.setModel`. */export const setModel = (ctx: GoalServiceContext,diff --git a/apps/server/src/services/goal/GoalService/index.ts b/apps/server/src/services/goal/GoalService/index.tsindex 0fa256f0bd0..d41921e996c 100644--- a/apps/server/src/services/goal/GoalService/index.ts+++ b/apps/server/src/services/goal/GoalService/index.ts@@ -40,6 +40,7 @@ import {followGoalAgent,goalOwnerTaskScope,graphAs,+ privatizeProjectGoals,reassignUnfinishedTasks,resolveTaskAssignee,retireNodes,@@ -48,6 +49,7 @@ import {setModel,setTaskAgent,setTaskModel,+ setVisibility,stopFencedTasks,updateRequirement,updateTitle,@@ -400,6 +402,10 @@ export class GoalService {setModel = (...args: MethodArgs<typeof setModel>) => setModel(this.context, ...args);setTaskModel = (...args: MethodArgs<typeof setTaskModel>) => setTaskModel(this.context, ...args);+ setVisibility = (...args: MethodArgs<typeof setVisibility>) =>+ setVisibility(this.context, ...args);+ privatizeProjectGoals = (...args: MethodArgs<typeof privatizeProjectGoals>) =>+ privatizeProjectGoals(this.context, ...args);private resolveTaskAssignee = (...args: MethodArgs<typeof resolveTaskAssignee>) =>resolveTaskAssignee(this.context, ...args);diff --git a/apps/server/src/services/goal/GoalService/types.ts b/apps/server/src/services/goal/GoalService/types.tsindex 377aca6dd42..bf51d3d9555 100644--- a/apps/server/src/services/goal/GoalService/types.ts+++ b/apps/server/src/services/goal/GoalService/types.ts@@ -1,4 +1,9 @@-import type { GoalCreateConfig, GoalNodeKind, GoalNodeStatus } from '@lobechat/types';+import type {+ GoalCreateConfig,+ GoalNodeKind,+ GoalNodeStatus,+ GoalVisibility,+} from '@lobechat/types';import type { GoalSeedTask } from '@lobechat/utils/goalSeeds';import type { AgentModel } from '@/database/models/agent';@@ -157,6 +162,12 @@ export interface CreateGoalGraphInput {* `topic` subject so the conversation can find and show it.*/topicId?: string;+ /**+ * Workspace visibility. Omitted, it follows the agents: a private goal or+ * task agent makes the goal private, otherwise it is public. An explicit+ * 'public' with a private agent is rejected.+ */+ visibility?: GoalVisibility;}export interface CreateGoalNodeInput {diff --git a/apps/server/src/services/goal/assignment.modelPolicy.test.ts b/apps/server/src/services/goal/assignment.modelPolicy.test.tsindex f013105380b..ff6eb29377a 100644--- a/apps/server/src/services/goal/assignment.modelPolicy.test.ts+++ b/apps/server/src/services/goal/assignment.modelPolicy.test.ts@@ -137,6 +137,8 @@ describe('goal model overrides on a fixed-model Agent', () => {const { taskId } = await memberGoals.tick(graph.goal.id);const ownTask = () => new TaskModel(db, memberId, workspaceId).findById(taskId!);expect((await ownTask())?.visibility).toBe('private');+ // A goal from before goal visibility: public, over the member's private work.+ await db.update(goals).set({ visibility: 'public' }).where(eq(goals.id, graph.goal.id));// The Workspace owner acts on the member's goal; the Task is still the member's.await new GoalAssignmentService(db, authorId, workspaceId).setTaskModel(graph.goal.id, gemini);@@ -165,6 +167,8 @@ describe('goal model overrides on a fixed-model Agent', () => {const { taskId } = await memberGoals.tick(graph.goal.id);const ownTask = () => new TaskModel(db, memberId, workspaceId).findById(taskId!);expect((await ownTask())?.assigneeAgentId).toBe(privateExecutorId);+ // A goal from before goal visibility: public, over a private executor.+ await db.update(goals).set({ visibility: 'public' }).where(eq(goals.id, graph.goal.id));const admin = new GoalAssignmentService(db, authorId, workspaceId);await admin.setTaskModel(graph.goal.id, gemini);diff --git a/apps/server/src/services/goal/assignment.ts b/apps/server/src/services/goal/assignment.tsindex 8cbcc968d55..942d1a10a32 100644--- a/apps/server/src/services/goal/assignment.ts+++ b/apps/server/src/services/goal/assignment.ts@@ -16,6 +16,7 @@ import { resolveMissingTaskModelConfig } from '../task/modelSnapshot';import { goalTaskAgentId } from './GoalService/utils';import { GoalManagerService } from './manager';import { assertGoalModelRunnable, goalTaskModelOverride } from './modelConfig';+import { assertGoalAgentVisibilityCompat } from './visibility';const goalNotFound = () => new TRPCError({ code: 'NOT_FOUND', message: 'Goal not found' });@@ -90,21 +91,24 @@ export class GoalAssignmentService {* an admin acting on someone else's goal would be unreachable to every later* planning turn, or silently skipped as a missing executor.*/- assertUsableForGoal = async (goal: Pick<GoalItem, 'userId'> | string, agentId: string) => {+ assertUsableForGoal = async (+ goal: Pick<GoalItem, 'userId' | 'visibility' | 'workspaceId'> | string,+ agentId: string,+ ) => {await this.assertUsable(agentId);- const ownerId =- typeof goal === 'string' ? (await this.goalModel.findById(goal))?.userId : goal.userId;- if (!ownerId) throw goalNotFound();- if (ownerId === this.userId) return;- await assertAgentUsableBy(this.db, agentId, {- userId: ownerId,- workspaceId: this.workspaceId,- }).catch(() => {- throw new TRPCError({- code: 'FORBIDDEN',- message: "The goal's owner cannot use this Agent; pick one they have access to",+ const row = typeof goal === 'string' ? await this.goalModel.findById(goal) : goal;+ if (!row) throw goalNotFound();+ if (row.userId !== this.userId)+ await assertAgentUsableBy(this.db, agentId, {+ userId: row.userId,+ workspaceId: this.workspaceId,+ }).catch(() => {+ throw new TRPCError({+ code: 'FORBIDDEN',+ message: "The goal's owner cannot use this Agent; pick one they have access to",+ });});- });+ await assertGoalAgentVisibilityCompat(this.db, row, [agentId]);};/**diff --git a/apps/server/src/services/goal/visibility.test.ts b/apps/server/src/services/goal/visibility.test.tsnew file mode 100644index 00000000000..6ae3fc668e0--- /dev/null+++ b/apps/server/src/services/goal/visibility.test.ts@@ -0,0 +1,329 @@+// @vitest-environment node+import { randomUUID } from 'node:crypto';++import { eq } from 'drizzle-orm';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import { getTestDB } from '@/database/core/getTestDB';+import { AgentOperationModel } from '@/database/models/agentOperation';+import { GoalModel } from '@/database/models/goal';+import { TaskModel } from '@/database/models/task';+import {+ agentOperations,+ agents,+ goalEdges,+ goalEvents,+ goalNodeDecisions,+ goalNodes,+ goals,+ messages,+ projects,+ tasks,+ taskTopics,+ topics,+ users,+ workspaceMembers,+ workspaces,+} from '@/database/schemas';+import { AiAgentService } from '@/server/services/aiAgent';++import { GoalService } from './index';+import * as scheduler from './scheduler';++const db = await getTestDB();+const ownerId = `goal-vis-owner-${randomUUID()}`;+const memberId = `goal-vis-member-${randomUUID()}`;+const publicAgentId = `goal-vis-public-${randomUUID()}`;+const privateAgentId = `goal-vis-private-${randomUUID()}`;+let workspaceId: string;+let seq = 0;++const ownerGoals = () => new GoalService(db, ownerId, workspaceId);+const memberGoals = () => new GoalService(db, memberId, workspaceId);+const memberSees = async (goalId: string) =>+ !!(await new GoalModel(db, memberId, workspaceId).findById(goalId));+const taskVisibility = async (taskId: string) =>+ (await new TaskModel(db, ownerId, workspaceId).findById(taskId))?.visibility;++beforeEach(async () => {+ vi.spyOn(scheduler, 'scheduleGoalAdvance').mockResolvedValue();+ vi.spyOn(AiAgentService.prototype, 'execAgent').mockImplementation(async (params) => {+ const operationId = `op-goal-vis-${++seq}`;+ const topicId = params.appContext!.topicId!;+ await new AgentOperationModel(db, ownerId, workspaceId).recordStart({+ agentId: params.agentId,+ appContext: { sourceMessageId: params.clientIds?.userMessageId },+ operationId,+ topicId,+ });+ return {+ agentId: params.agentId!,+ assistantMessageId: 'm',+ autoStarted: true,+ createdAt: new Date().toISOString(),+ message: 'started',+ operationId,+ status: 'running',+ success: true,+ timestamp: new Date().toISOString(),+ topicId,+ userMessageId: 'u',+ };+ });+ await db.insert(users).values([{ id: ownerId }, { id: memberId }]);+ const [workspace] = await db+ .insert(workspaces)+ .values({ name: 'ws', primaryOwnerId: ownerId, slug: `ws-${randomUUID()}` })+ .returning();+ workspaceId = workspace.id;+ await db.insert(workspaceMembers).values([+ { role: 'owner', userId: ownerId, workspaceId },+ { role: 'member', userId: memberId, workspaceId },+ ]);+ await db.insert(agents).values([+ {+ id: publicAgentId,+ model: 'gpt-4o-mini',+ provider: 'openai',+ slug: `public-${randomUUID()}`,+ userId: ownerId,+ visibility: 'public',+ workspaceId,+ },+ {+ id: privateAgentId,+ model: 'gpt-4o-mini',+ provider: 'openai',+ slug: `private-${randomUUID()}`,+ userId: ownerId,+ visibility: 'private',+ workspaceId,+ },+ ]);+});++afterEach(async () => {+ vi.restoreAllMocks();+ for (const table of [+ goalNodeDecisions,+ goalEdges,+ goalEvents,+ goalNodes,+ goals,+ agentOperations,+ messages,+ taskTopics,+ topics,+ tasks,+ projects,+ agents,+ workspaceMembers,+ workspaces,+ users,+ ])+ await db.delete(table);+});++describe('goal visibility on create', () => {+ it('follows a private agent and hides the goal from other members', async () => {+ const graph = await ownerGoals().create({ agentId: privateAgentId, title: 'Mine' });++ expect(graph.goal.visibility).toBe('private');+ expect(await memberSees(graph.goal.id)).toBe(false);+ const listed = await new GoalModel(db, memberId, workspaceId).list();+ expect(listed.goals.map((row) => row.goal.id)).not.toContain(graph.goal.id);+ const ownerList = await new GoalModel(db, ownerId, workspaceId).list();+ expect(ownerList.goals.map((row) => row.goal.id)).toContain(graph.goal.id);+ });++ it("hides a member's private goal from the workspace owner too", async () => {+ await db.insert(agents).values({+ id: `${privateAgentId}-member`,+ slug: `member-private-${randomUUID()}`,+ userId: memberId,+ visibility: 'private',+ workspaceId,+ });+ const graph = await memberGoals().create({+ agentId: `${privateAgentId}-member`,+ title: 'Member goal',+ });++ expect(await new GoalModel(db, ownerId, workspaceId).findById(graph.goal.id)).toBeUndefined();+ });++ it('is public on a public agent, and private when asked', async () => {+ const shared = await ownerGoals().create({ agentId: publicAgentId, title: 'Shared' });+ const kept = await ownerGoals().create({+ agentId: publicAgentId,+ title: 'Kept',+ visibility: 'private',+ });++ expect(shared.goal.visibility).toBe('public');+ expect(await memberSees(shared.goal.id)).toBe(true);+ expect(kept.goal.visibility).toBe('private');+ expect(await memberSees(kept.goal.id)).toBe(false);+ });++ it('refuses a public goal on a private agent or executor', async () => {+ await expect(+ ownerGoals().create({ agentId: privateAgentId, title: 'Leak', visibility: 'public' }),+ ).rejects.toMatchObject({ code: 'BAD_REQUEST' });+ await expect(+ ownerGoals().create({+ agentId: publicAgentId,+ config: { taskAgentId: privateAgentId },+ title: 'Leak',+ visibility: 'public',+ }),+ ).rejects.toMatchObject({ code: 'BAD_REQUEST' });+ });++ it("keeps a private goal's Tasks private even on a public agent", async () => {+ const graph = await ownerGoals().create({+ agentId: publicAgentId,+ tasks: ['Only task'],+ title: 'Kept',+ visibility: 'private',+ });+ const { taskId } = await ownerGoals().tick(graph.goal.id);++ expect(await taskVisibility(taskId!)).toBe('private');+ });+});++describe('setVisibility', () => {+ it('moves the goal and its Tasks both ways', async () => {+ const graph = await ownerGoals().create({+ agentId: publicAgentId,+ tasks: ['Only task'],+ title: 'Shared',+ });+ const { taskId } = await ownerGoals().tick(graph.goal.id);+ expect(await taskVisibility(taskId!)).toBe('public');++ const hidden = await ownerGoals().setVisibility(graph.goal.id, 'private');+ expect(hidden.goal.visibility).toBe('private');+ expect(hidden.taskIds).toEqual([taskId]);+ expect(await taskVisibility(taskId!)).toBe('private');+ expect(await memberSees(graph.goal.id)).toBe(false);++ const shown = await ownerGoals().setVisibility(graph.goal.id, 'public');+ expect(shown.goal.visibility).toBe('public');+ expect(await taskVisibility(taskId!)).toBe('public');+ expect(await memberSees(graph.goal.id)).toBe(true);+ });++ it('refuses to publish a goal run by a private agent', async () => {+ const graph = await ownerGoals().create({ agentId: privateAgentId, title: 'Mine' });++ await expect(ownerGoals().setVisibility(graph.goal.id, 'public')).rejects.toMatchObject({+ code: 'BAD_REQUEST',+ });+ });++ it("refuses a member changing another member's goal", async () => {+ const graph = await ownerGoals().create({ agentId: publicAgentId, title: 'Shared' });++ await expect(memberGoals().setVisibility(graph.goal.id, 'private')).rejects.toMatchObject({+ code: 'FORBIDDEN',+ });+ });++ it('refuses personal goals, where visibility does not apply', async () => {+ const personalAgentId = `goal-vis-personal-${randomUUID()}`;+ await db.insert(agents).values({ id: personalAgentId, slug: personalAgentId, userId: ownerId });+ const graph = await new GoalService(db, ownerId).create({+ agentId: personalAgentId,+ title: 'Personal',+ });++ await expect(+ new GoalService(db, ownerId).setVisibility(graph.goal.id, 'private'),+ ).rejects.toMatchObject({ code: 'BAD_REQUEST' });+ });+});++describe('agent handoff', () => {+ it('refuses handing a public goal to a private agent', async () => {+ const graph = await ownerGoals().create({ agentId: publicAgentId, title: 'Shared' });++ await expect(ownerGoals().setAgent(graph.goal.id, privateAgentId)).rejects.toMatchObject({+ code: 'BAD_REQUEST',+ });+ await expect(ownerGoals().setTaskAgent(graph.goal.id, privateAgentId)).rejects.toMatchObject({+ code: 'BAD_REQUEST',+ });+ });++ it('lets a private goal move to a private agent', async () => {+ const graph = await ownerGoals().create({+ agentId: publicAgentId,+ title: 'Kept',+ visibility: 'private',+ });++ await expect(ownerGoals().setAgent(graph.goal.id, privateAgentId)).resolves.toBeTruthy();+ });+});++describe('project visibility', () => {+ const projectFor = async (visibility: 'private' | 'public') => {+ const id = `gvp-${randomUUID().slice(0, 8)}`;+ await db.insert(projects).values({+ id,+ identifier: 'PRJ',+ name: 'Project',+ userId: ownerId,+ visibility,+ workspaceId,+ });+ return id;+ };++ it('makes a goal in a private project private, and refuses a public one', async () => {+ const projectId = await projectFor('private');++ const graph = await ownerGoals().create({ agentId: publicAgentId, projectId, title: 'In it' });+ expect(graph.goal.visibility).toBe('private');+ await expect(+ ownerGoals().create({+ agentId: publicAgentId,+ projectId,+ title: 'Leak',+ visibility: 'public',+ }),+ ).rejects.toMatchObject({ code: 'BAD_REQUEST' });+ await expect(ownerGoals().setVisibility(graph.goal.id, 'public')).rejects.toMatchObject({+ code: 'BAD_REQUEST',+ });+ });++ it("privatizes a project's public goals when it goes private", async () => {+ const projectId = await projectFor('public');+ const own = await ownerGoals().create({+ agentId: publicAgentId,+ projectId,+ tasks: ['Only task'],+ title: 'Own',+ });+ const { taskId } = await ownerGoals().tick(own.goal.id);+ // A member's goal in the same project.+ const theirs = await memberGoals().create({+ agentId: publicAgentId,+ projectId,+ title: 'Theirs',+ });++ await db.update(projects).set({ visibility: 'private' }).where(eq(projects.id, projectId));+ const moved = await ownerGoals().privatizeProjectGoals(projectId);++ expect(moved.sort()).toEqual([own.goal.id, theirs.goal.id].sort());+ expect(await taskVisibility(taskId!)).toBe('private');+ expect(await memberSees(own.goal.id)).toBe(false);+ // The member still has their own goal, now private to them.+ const kept = await new GoalModel(db, memberId, workspaceId).findById(theirs.goal.id);+ expect(kept?.visibility).toBe('private');+ });+});diff --git a/apps/server/src/services/goal/visibility.ts b/apps/server/src/services/goal/visibility.tsnew file mode 100644index 00000000000..8be12281645--- /dev/null+++ b/apps/server/src/services/goal/visibility.ts@@ -0,0 +1,121 @@+import type { GoalVisibility } from '@lobechat/types';+import { TRPCError } from '@trpc/server';+import { and, eq, inArray, ne } from 'drizzle-orm';++import { agents, goalNodes, projects, tasks } from '@/database/schemas';+import type { LobeChatDatabase, Transaction } from '@/database/type';++/**+ * Whether any of the goal's agents (supervisor, dedicated executor) is private.+ * Callers have already checked each agent is usable by them; this only reads+ * the flag, so it does not repeat the ownership filter.+ */+const hasPrivateAgent = async (+ db: LobeChatDatabase | Transaction,+ agentIds: (string | null | undefined)[],+) => {+ const ids = [...new Set(agentIds.filter((id): id is string => !!id))];+ if (ids.length === 0) return false;+ const rows = await db+ .select({ visibility: agents.visibility })+ .from(agents)+ .where(inArray(agents.id, ids));+ return rows.some((row) => row.visibility === 'private');+};++const PUBLIC_WITH_PRIVATE_AGENT =+ 'A public goal cannot be run by a private agent; make the goal private or pick a public agent';++const PUBLIC_IN_PRIVATE_PROJECT =+ 'A goal in a private project must be private; members cannot see the project';++/** Whether the goal's project is a private workspace project. */+const isPrivateProject = async (+ db: LobeChatDatabase | Transaction,+ projectId: string | null | undefined,+) => {+ if (!projectId) return false;+ const [row] = await db+ .select({ visibility: projects.visibility, workspaceId: projects.workspaceId })+ .from(projects)+ .where(eq(projects.id, projectId))+ .limit(1);+ return !!row?.workspaceId && row.visibility === 'private';+};++/**+ * The visibility a goal is created with. Mirrors `TaskService.createTask`:+ * an explicit value wins, a private agent or project makes the goal private,+ * else the column default ('public'). A public goal on a private agent or in+ * a private project is refused — members would see a goal whose agent, tasks,+ * runs or project they cannot open.+ */+export const resolveGoalVisibility = async (+ db: LobeChatDatabase | Transaction,+ requested: GoalVisibility | undefined,+ agentIds: (string | null | undefined)[],+ projectId?: string | null,+): Promise<GoalVisibility> => {+ const [privateAgent, privateProject] = await Promise.all([+ hasPrivateAgent(db, agentIds),+ isPrivateProject(db, projectId),+ ]);+ if (requested === 'public' && privateAgent)+ throw new TRPCError({ code: 'BAD_REQUEST', message: PUBLIC_WITH_PRIVATE_AGENT });+ if (requested === 'public' && privateProject)+ throw new TRPCError({ code: 'BAD_REQUEST', message: PUBLIC_IN_PRIVATE_PROJECT });+ return requested ?? (privateAgent || privateProject ? 'private' : 'public');+};++/** Refuse publishing a goal that sits in a private project. */+export const assertGoalProjectVisibilityCompat = async (+ db: LobeChatDatabase | Transaction,+ goal: { projectId: string | null; visibility: GoalVisibility; workspaceId: string | null },+) => {+ if (!goal.workspaceId || goal.visibility !== 'public') return;+ if (await isPrivateProject(db, goal.projectId))+ throw new TRPCError({ code: 'BAD_REQUEST', message: PUBLIC_IN_PRIVATE_PROJECT });+};++/** Refuse handing a public goal to a private agent (set-agent / set-task-agent / bind-topic). */+export const assertGoalAgentVisibilityCompat = async (+ db: LobeChatDatabase | Transaction,+ goal: { visibility: GoalVisibility; workspaceId: string | null },+ agentIds: (string | null | undefined)[],+) => {+ // Personal goals are private to their owner whatever the column says.+ if (!goal.workspaceId || goal.visibility !== 'public') return;+ if (await hasPrivateAgent(db, agentIds))+ throw new TRPCError({ code: 'BAD_REQUEST', message: PUBLIC_WITH_PRIVATE_AGENT });+};++/**+ * The goal's own Tasks that move with it: the ones its owner created (the+ * coordinator files them under the owner). A Task another member created stays+ * theirs — demoting it would hand it to them privately and hide it from the+ * goal's owner.+ */+export const goalTasksToCascade = async (+ db: LobeChatDatabase | Transaction,+ goal: { id: string; userId: string },+ visibility: GoalVisibility,+) => {+ const rows = await db+ .select({ agentVisibility: agents.visibility, id: tasks.id })+ .from(goalNodes)+ .innerJoin(tasks, eq(goalNodes.taskId, tasks.id))+ .leftJoin(agents, eq(agents.id, tasks.assigneeAgentId))+ .where(+ and(+ eq(goalNodes.goalId, goal.id),+ eq(tasks.createdByUserId, goal.userId),+ ne(tasks.visibility, visibility),+ ),+ );+ return (+ rows+ // A Task on a private agent stays private: a public Task never runs on one.+ .filter((row) => visibility === 'private' || row.agentVisibility !== 'private')+ .map((row) => row.id)+ );+};diff --git a/docs/development/database-schema.dbml b/docs/development/database-schema.dbmlindex 3a5ec36ade0..1038a7cd1aa 100644--- a/docs/development/database-schema.dbml+++ b/docs/development/database-schema.dbml@@ -2370,6 +2370,7 @@ table goals {subject_id textstarted_at "timestamp with time zone"completed_at "timestamp with time zone"+ visibility text [not null, default: 'public']deleted_at "timestamp with time zone"is_deleted booleancreated_at "timestamp with time zone" [not null, default: `now()`]@@ -2378,6 +2379,7 @@ table goals {indexes {user_id [name: 'goals_user_id_idx']workspace_id [name: 'goals_workspace_id_idx']+ (workspace_id, visibility, user_id) [name: 'goals_workspace_visibility_idx']agent_id [name: 'goals_agent_id_idx']project_id [name: 'goals_project_id_idx']status [name: 'goals_status_idx']diff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex ad419bd0416..31572484908 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -657,6 +657,10 @@"goalDetail.unnamedRun": "Untitled run","goalDetail.viewOriginalTask": "View task","goalDetail.viewPlan": "View execution plan",+ "goalDetail.visibility.changeFailed": "Failed to change goal visibility",+ "goalDetail.visibility.creatorOnly": "Only the goal's creator can change its visibility",+ "goalDetail.visibility.privateAgentLocked": "Private agents can only run private goals.",+ "goalDetail.visibility.privateProjectLocked": "Goals in a private project stay private.","goalEmpty.create": "Create your first goal","goalEmpty.examples.backlog.requirement": "Tag each item with a type and priority, dedupe into one table, and list the 10 most frequent issues.","goalEmpty.examples.backlog.tag": "One-off cleanup",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex 4eb8928bdfc..a36de061b7e 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -657,6 +657,10 @@"goalDetail.unnamedRun": "未命名运行","goalDetail.viewOriginalTask": "查看原始任务","goalDetail.viewPlan": "查看执行计划",+ "goalDetail.visibility.changeFailed": "切换目标可见性失败",+ "goalDetail.visibility.creatorOnly": "只有目标创建者可以修改可见性",+ "goalDetail.visibility.privateAgentLocked": "私人助理只能执行私人目标。",+ "goalDetail.visibility.privateProjectLocked": "私人项目里的目标只能是私人的。","goalEmpty.create": "创建第一个目标","goalEmpty.examples.backlog.requirement": "逐条标注类型与优先级,去重后汇总成一张表,并附出现最多的 10 个问题。","goalEmpty.examples.backlog.tag": "一次性整理",diff --git a/packages/database/migrations/0198_goal_visibility.sql b/packages/database/migrations/0198_goal_visibility.sqlnew file mode 100644index 00000000000..1dc90732884--- /dev/null+++ b/packages/database/migrations/0198_goal_visibility.sql@@ -0,0 +1,5 @@+-- Workspace visibility for goals, mirroring agents / tasks. A constant default keeps the ADD COLUMN+-- metadata-only; goals is small (hundreds of rows), so the index builds inline. Existing goals that a+-- private agent supervises are privatized by hand after deploy.+ALTER TABLE "goals" ADD COLUMN IF NOT EXISTS "visibility" text DEFAULT 'public' NOT NULL;--> statement-breakpoint+CREATE INDEX IF NOT EXISTS "goals_workspace_visibility_idx" ON "goals" USING btree ("workspace_id","visibility","user_id");diff --git a/packages/database/migrations/meta/0188_snapshot.json b/packages/database/migrations/meta/0198_snapshot.jsonsimilarity index 93%rename from packages/database/migrations/meta/0188_snapshot.jsonrename to packages/database/migrations/meta/0198_snapshot.jsonindex e15f40870f6..1a22455097f 100644--- a/packages/database/migrations/meta/0188_snapshot.json+++ b/packages/database/migrations/meta/0198_snapshot.json@@ -6,9 +6,9 @@},"dialect": "postgresql","enums": {},- "id": "c5c00e30-513b-4e9c-a0b1-6b40e986f12b",+ "id": "2abb741e-cd71-49d5-baa4-0563f57e3a75","policies": {},- "prevId": "7c8b5944-a341-485c-a9f6-514a3a55e780",+ "prevId": "c74b5a61-73c0-412c-b4eb-7631ef66db26","roles": {},"schemas": {},"sequences": {@@ -7162,6 +7162,388 @@"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": "",@@ -7185,6 +7567,13 @@"primaryKey": false,"notNull": false},+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },"provider": {"name": "provider","type": "text",@@ -7337,6 +7726,33 @@"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": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },"agent_provider_accounts_token_expires_at_idx": {"name": "agent_provider_accounts_token_expires_at_idx","columns": [@@ -10343,13 +10759,6 @@"primaryKey": false,"notNull": true},- "delivery_key": {- "name": "delivery_key",- "type": "text",- "primaryKey": false,- "notNull": true,- "default": "'initial'"- },"status": {"name": "status","type": "text",@@ -10491,12 +10900,6 @@"isExpression": false,"asc": true,"nulls": "last"- },- {- "expression": "delivery_key",- "isExpression": false,- "asc": true,- "nulls": "last"}],"isUnique": true,@@ -10992,12 +11395,12 @@"notNull": false,"default": "'{}'::jsonb"},- "active": {- "name": "active",- "type": "boolean",+ "status": {+ "name": "status",+ "type": "text","primaryKey": false,"notNull": true,- "default": true+ "default": "'active'"},"created_at": {"name": "created_at",@@ -11549,6 +11952,13 @@"notNull": true,"default": "'[]'::jsonb"},+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },"metadata": {"name": "metadata","type": "jsonb",@@ -11556,6 +11966,18 @@"notNull": false,"default": "'{}'::jsonb"},+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_deleted": {+ "name": "is_deleted",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },"created_at": {"name": "created_at","type": "timestamp with time zone",@@ -11582,6 +12004,7 @@}],"isUnique": true,+ "where": "\"channel_threads\".\"is_deleted\" IS NOT TRUE","concurrently": false,"method": "btree","with": {}@@ -11666,12 +12089,12 @@"notNull": true,"default": 0},- "archived": {- "name": "archived",- "type": "boolean",+ "status": {+ "name": "status",+ "type": "text","primaryKey": false,"notNull": true,- "default": false+ "default": "'active'"},"visibility": {"name": "visibility",@@ -11687,6 +12110,18 @@"notNull": false,"default": "'{}'::jsonb"},+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_deleted": {+ "name": "is_deleted",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },"created_at": {"name": "created_at","type": "timestamp with time zone",@@ -14067,6 +14502,24 @@"primaryKey": false,"notNull": true},+ "editor_ids": {+ "name": "editor_ids",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "operation_id": {+ "name": "operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },"saved_at": {"name": "saved_at","type": "timestamp with time zone",@@ -17127,6 +17580,208 @@"checkConstraints": {},"isRLSEnabled": false},+ "public.user_favorites": {+ "name": "user_favorites",+ "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+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "target_id": {+ "name": "target_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "path": {+ "name": "path",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "sort_order": {+ "name": "sort_order",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_favorites_personal_target_unique": {+ "name": "user_favorites_personal_target_unique",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"user_favorites\".\"workspace_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_favorites_workspace_target_unique": {+ "name": "user_favorites_workspace_target_unique",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"user_favorites\".\"workspace_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_favorites_user_id_idx": {+ "name": "user_favorites_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_favorites_workspace_id_idx": {+ "name": "user_favorites_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_favorites_user_id_users_id_fk": {+ "name": "user_favorites_user_id_users_id_fk",+ "tableFrom": "user_favorites",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_favorites_workspace_id_workspaces_id_fk": {+ "name": "user_favorites_workspace_id_workspaces_id_fk",+ "tableFrom": "user_favorites",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },"public.documents": {"name": "documents","schema": "",@@ -18574,6 +19229,164 @@"checkConstraints": {},"isRLSEnabled": false},+ "public.file_shares": {+ "name": "file_shares",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "file_id": {+ "name": "file_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "page_view_count": {+ "name": "page_view_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'private'"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "file_shares_file_id_unique": {+ "name": "file_shares_file_id_unique",+ "columns": [+ {+ "expression": "file_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "file_shares_user_id_idx": {+ "name": "file_shares_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "file_shares_workspace_id_idx": {+ "name": "file_shares_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "file_shares_file_id_files_id_fk": {+ "name": "file_shares_file_id_files_id_fk",+ "tableFrom": "file_shares",+ "tableTo": "files",+ "columnsFrom": ["file_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "file_shares_user_id_users_id_fk": {+ "name": "file_shares_user_id_users_id_fk",+ "tableFrom": "file_shares",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "file_shares_workspace_id_workspaces_id_fk": {+ "name": "file_shares_workspace_id_workspaces_id_fk",+ "tableFrom": "file_shares",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },"public.fts_search_sync_capture_version": {"name": "fts_search_sync_capture_version","schema": "",@@ -19422,6 +20235,13 @@"primaryKey": false,"notNull": false},+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },"deleted_at": {"name": "deleted_at","type": "timestamp with time zone",@@ -19480,6 +20300,33 @@"method": "btree","with": {}},+ "goals_workspace_visibility_idx": {+ "name": "goals_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },"goals_agent_id_idx": {"name": "goals_agent_id_idx","columns": [@@ -20474,6 +21321,164 @@},"isRLSEnabled": false},+ "public.goal_shares": {+ "name": "goal_shares",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "goal_id": {+ "name": "goal_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+ },+ "page_view_count": {+ "name": "page_view_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'private'"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "goal_shares_goal_id_unique": {+ "name": "goal_shares_goal_id_unique",+ "columns": [+ {+ "expression": "goal_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goal_shares_user_id_idx": {+ "name": "goal_shares_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goal_shares_workspace_id_idx": {+ "name": "goal_shares_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "goal_shares_goal_id_goals_id_fk": {+ "name": "goal_shares_goal_id_goals_id_fk",+ "tableFrom": "goal_shares",+ "tableTo": "goals",+ "columnsFrom": ["goal_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "goal_shares_user_id_users_id_fk": {+ "name": "goal_shares_user_id_users_id_fk",+ "tableFrom": "goal_shares",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "goal_shares_workspace_id_workspaces_id_fk": {+ "name": "goal_shares_workspace_id_workspaces_id_fk",+ "tableFrom": "goal_shares",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },"public.goal_subscriptions": {"name": "goal_subscriptions","schema": "",@@ -21214,6 +22219,211 @@"checkConstraints": {},"isRLSEnabled": false},+ "public.linear_sync_rules": {+ "name": "linear_sync_rules",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "connection_id": {+ "name": "connection_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+ },+ "team_id": {+ "name": "team_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "team_name": {+ "name": "team_name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "linear_project_id": {+ "name": "linear_project_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "linear_project_name": {+ "name": "linear_project_name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "state_types": {+ "name": "state_types",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "last_run_at": {+ "name": "last_run_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_result": {+ "name": "last_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": {+ "linear_sync_rules_project_id_idx": {+ "name": "linear_sync_rules_project_id_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "linear_sync_rules_connection_id_idx": {+ "name": "linear_sync_rules_connection_id_idx",+ "columns": [+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "linear_sync_rules_user_id_idx": {+ "name": "linear_sync_rules_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "linear_sync_rules_workspace_id_idx": {+ "name": "linear_sync_rules_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "linear_sync_rules_project_id_projects_id_fk": {+ "name": "linear_sync_rules_project_id_projects_id_fk",+ "tableFrom": "linear_sync_rules",+ "tableTo": "projects",+ "columnsFrom": ["project_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "linear_sync_rules_connection_id_linear_connections_id_fk": {+ "name": "linear_sync_rules_connection_id_linear_connections_id_fk",+ "tableFrom": "linear_sync_rules",+ "tableTo": "linear_connections",+ "columnsFrom": ["connection_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "linear_sync_rules_user_id_users_id_fk": {+ "name": "linear_sync_rules_user_id_users_id_fk",+ "tableFrom": "linear_sync_rules",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "linear_sync_rules_workspace_id_workspaces_id_fk": {+ "name": "linear_sync_rules_workspace_id_workspaces_id_fk",+ "tableFrom": "linear_sync_rules",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },"public.llm_generation_tracing": {"name": "llm_generation_tracing","schema": "",@@ -35342,6 +36552,257 @@"checkConstraints": {},"isRLSEnabled": false},+ "public.task_external_links": {+ "name": "task_external_links",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "task_id": {+ "name": "task_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "external_id": {+ "name": "external_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "external_identifier": {+ "name": "external_identifier",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "external_url": {+ "name": "external_url",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "external_container_id": {+ "name": "external_container_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "external_updated_at": {+ "name": "external_updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "synced_hash": {+ "name": "synced_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "last_synced_at": {+ "name": "last_synced_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "metadata": {+ "name": "metadata",+ "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": {+ "task_external_links_task_id_unique": {+ "name": "task_external_links_task_id_unique",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_external_links_personal_unique": {+ "name": "task_external_links_personal_unique",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "external_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"task_external_links\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_external_links_workspace_unique": {+ "name": "task_external_links_workspace_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "external_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"task_external_links\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_external_links_container_idx": {+ "name": "task_external_links_container_idx",+ "columns": [+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "external_container_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_external_links_user_id_idx": {+ "name": "task_external_links_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "task_external_links_task_id_tasks_id_fk": {+ "name": "task_external_links_task_id_tasks_id_fk",+ "tableFrom": "task_external_links",+ "tableTo": "tasks",+ "columnsFrom": ["task_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_external_links_user_id_users_id_fk": {+ "name": "task_external_links_user_id_users_id_fk",+ "tableFrom": "task_external_links",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_external_links_workspace_id_workspaces_id_fk": {+ "name": "task_external_links_workspace_id_workspaces_id_fk",+ "tableFrom": "task_external_links",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },"public.threads": {"name": "threads","schema": "",@@ -37638,8 +39099,8 @@"checkConstraints": {},"isRLSEnabled": false},- "public.user_memories": {- "name": "user_memories",+ "public.user_memories_activities": {+ "name": "user_memories_activities","schema": "","columns": {"id": {@@ -37654,84 +39115,115 @@"primaryKey": false,"notNull": false},- "memory_category": {- "name": "memory_category",+ "user_memory_id": {+ "name": "user_memory_id","type": "varchar(255)","primaryKey": false,"notNull": false},- "memory_layer": {- "name": "memory_layer",- "type": "varchar(255)",+ "metadata": {+ "name": "metadata",+ "type": "jsonb","primaryKey": false,"notNull": false},- "memory_type": {- "name": "memory_type",+ "tags": {+ "name": "tags",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "timezone": {+ "name": "timezone","type": "varchar(255)","primaryKey": false,"notNull": false},- "metadata": {- "name": "metadata",+ "starts_at": {+ "name": "starts_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "ends_at": {+ "name": "ends_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "associated_objects": {+ "name": "associated_objects","type": "jsonb","primaryKey": false,"notNull": false},- "tags": {- "name": "tags",- "type": "text[]",+ "associated_subjects": {+ "name": "associated_subjects",+ "type": "jsonb","primaryKey": false,"notNull": false},- "title": {- "name": "title",- "type": "varchar(255)",+ "associated_locations": {+ "name": "associated_locations",+ "type": "jsonb","primaryKey": false,"notNull": false},- "summary": {- "name": "summary",+ "notes": {+ "name": "notes","type": "text","primaryKey": false,"notNull": false},- "summary_vector_1024": {- "name": "summary_vector_1024",+ "narrative": {+ "name": "narrative",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "narrative_vector": {+ "name": "narrative_vector","type": "vector(1024)","primaryKey": false,"notNull": false},- "details": {- "name": "details",+ "feedback": {+ "name": "feedback","type": "text","primaryKey": false,"notNull": false},- "details_vector_1024": {- "name": "details_vector_1024",+ "feedback_vector": {+ "name": "feedback_vector","type": "vector(1024)","primaryKey": false,"notNull": false},- "status": {- "name": "status",+ "dossier_id": {+ "name": "dossier_id","type": "varchar(255)","primaryKey": false,"notNull": false},- "accessed_count": {- "name": "accessed_count",- "type": "bigint",- "primaryKey": false,- "notNull": false,- "default": 0- },- "last_accessed_at": {- "name": "last_accessed_at",- "type": "timestamp with time zone",+ "injectable": {+ "name": "injectable",+ "type": "boolean","primaryKey": false,- "notNull": true+ "notNull": true,+ "default": true},"captured_at": {"name": "captured_at",@@ -37740,18 +39232,6 @@"notNull": true,"default": "now()"},- "deleted_at": {- "name": "deleted_at",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "is_deleted": {- "name": "is_deleted",- "type": "boolean",- "primaryKey": false,- "notNull": false- },"accessed_at": {"name": "accessed_at","type": "timestamp with time zone",@@ -37775,11 +39255,11 @@}},"indexes": {- "user_memories_summary_vector_1024_index": {- "name": "user_memories_summary_vector_1024_index",+ "user_memories_activities_narrative_vector_index": {+ "name": "user_memories_activities_narrative_vector_index","columns": [{- "expression": "summary_vector_1024",+ "expression": "narrative_vector","isExpression": false,"asc": true,"nulls": "last",@@ -37791,11 +39271,11 @@"method": "hnsw","with": {}},- "user_memories_details_vector_1024_index": {- "name": "user_memories_details_vector_1024_index",+ "user_memories_activities_feedback_vector_index": {+ "name": "user_memories_activities_feedback_vector_index","columns": [{- "expression": "details_vector_1024",+ "expression": "feedback_vector","isExpression": false,"asc": true,"nulls": "last",@@ -37807,8 +39287,23 @@"method": "hnsw","with": {}},- "user_memories_user_id_index": {- "name": "user_memories_user_id_index",+ "user_memories_activities_type_index": {+ "name": "user_memories_activities_type_index",+ "columns": [+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_activities_user_id_index": {+ "name": "user_memories_activities_user_id_index","columns": [{"expression": "user_id",@@ -37821,17 +39316,81 @@"concurrently": false,"method": "btree","with": {}+ },+ "user_memories_activities_user_memory_id_index": {+ "name": "user_memories_activities_user_memory_id_index",+ "columns": [+ {+ "expression": "user_memory_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_activities_status_index": {+ "name": "user_memories_activities_status_index",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_activities_dossier_id_index": {+ "name": "user_memories_activities_dossier_id_index",+ "columns": [+ {+ "expression": "dossier_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"user_memories_activities\".\"dossier_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}}},"foreignKeys": {- "user_memories_user_id_users_id_fk": {- "name": "user_memories_user_id_users_id_fk",- "tableFrom": "user_memories",+ "user_memories_activities_user_id_users_id_fk": {+ "name": "user_memories_activities_user_id_users_id_fk",+ "tableFrom": "user_memories_activities","tableTo": "users","columnsFrom": ["user_id"],"columnsTo": ["id"],"onDelete": "cascade","onUpdate": "no action"+ },+ "user_memories_activities_user_memory_id_user_memories_id_fk": {+ "name": "user_memories_activities_user_memory_id_user_memories_id_fk",+ "tableFrom": "user_memories_activities",+ "tableTo": "user_memories",+ "columnsFrom": ["user_memory_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_activities_dossier_id_user_memories_dossiers_id_fk": {+ "name": "user_memories_activities_dossier_id_user_memories_dossiers_id_fk",+ "tableFrom": "user_memories_activities",+ "tableTo": "user_memories_dossiers",+ "columnsFrom": ["dossier_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"}},"compositePrimaryKeys": {},@@ -37840,8 +39399,8 @@"checkConstraints": {},"isRLSEnabled": false},- "public.user_memories_activities": {- "name": "user_memories_activities",+ "public.user_memories": {+ "name": "user_memories","schema": "","columns": {"id": {@@ -37856,8 +39415,20 @@"primaryKey": false,"notNull": false},- "user_memory_id": {- "name": "user_memory_id",+ "memory_category": {+ "name": "memory_category",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "memory_layer": {+ "name": "memory_layer",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "memory_type": {+ "name": "memory_type","type": "varchar(255)","primaryKey": false,"notNull": false@@ -37874,84 +39445,67 @@"primaryKey": false,"notNull": false},- "type": {- "name": "type",- "type": "varchar(255)",- "primaryKey": false,- "notNull": true- },- "status": {- "name": "status",- "type": "varchar(255)",- "primaryKey": false,- "notNull": true,- "default": "'pending'"- },- "timezone": {- "name": "timezone",+ "title": {+ "name": "title","type": "varchar(255)","primaryKey": false,"notNull": false},- "starts_at": {- "name": "starts_at",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "ends_at": {- "name": "ends_at",- "type": "timestamp with time zone",+ "summary": {+ "name": "summary",+ "type": "text","primaryKey": false,"notNull": false},- "associated_objects": {- "name": "associated_objects",- "type": "jsonb",+ "summary_vector_1024": {+ "name": "summary_vector_1024",+ "type": "vector(1024)","primaryKey": false,"notNull": false},- "associated_subjects": {- "name": "associated_subjects",- "type": "jsonb",+ "details": {+ "name": "details",+ "type": "text","primaryKey": false,"notNull": false},- "associated_locations": {- "name": "associated_locations",- "type": "jsonb",+ "details_vector_1024": {+ "name": "details_vector_1024",+ "type": "vector(1024)","primaryKey": false,"notNull": false},- "notes": {- "name": "notes",- "type": "text",+ "status": {+ "name": "status",+ "type": "varchar(255)","primaryKey": false,"notNull": false},- "narrative": {- "name": "narrative",+ "state": {+ "name": "state","type": "text","primaryKey": false,"notNull": false},- "narrative_vector": {- "name": "narrative_vector",- "type": "vector(1024)",+ "user_locked": {+ "name": "user_locked",+ "type": "boolean","primaryKey": false,- "notNull": false+ "notNull": false,+ "default": false},- "feedback": {- "name": "feedback",- "type": "text",+ "accessed_count": {+ "name": "accessed_count",+ "type": "bigint","primaryKey": false,- "notNull": false+ "notNull": false,+ "default": 0},- "feedback_vector": {- "name": "feedback_vector",- "type": "vector(1024)",+ "last_accessed_at": {+ "name": "last_accessed_at",+ "type": "timestamp with time zone","primaryKey": false,- "notNull": false+ "notNull": true},"captured_at": {"name": "captured_at",@@ -37960,6 +39514,18 @@"notNull": true,"default": "now()"},+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_deleted": {+ "name": "is_deleted",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },"accessed_at": {"name": "accessed_at","type": "timestamp with time zone",@@ -37983,11 +39549,11 @@}},"indexes": {- "user_memories_activities_narrative_vector_index": {- "name": "user_memories_activities_narrative_vector_index",+ "user_memories_summary_vector_1024_index": {+ "name": "user_memories_summary_vector_1024_index","columns": [{- "expression": "narrative_vector",+ "expression": "summary_vector_1024","isExpression": false,"asc": true,"nulls": "last",@@ -37999,11 +39565,11 @@"method": "hnsw","with": {}},- "user_memories_activities_feedback_vector_index": {- "name": "user_memories_activities_feedback_vector_index",+ "user_memories_details_vector_1024_index": {+ "name": "user_memories_details_vector_1024_index","columns": [{- "expression": "feedback_vector",+ "expression": "details_vector_1024","isExpression": false,"asc": true,"nulls": "last",@@ -38015,11 +39581,11 @@"method": "hnsw","with": {}},- "user_memories_activities_type_index": {- "name": "user_memories_activities_type_index",+ "user_memories_user_id_index": {+ "name": "user_memories_user_id_index","columns": [{- "expression": "type",+ "expression": "user_id","isExpression": false,"asc": true,"nulls": "last"@@ -38029,27 +39595,129 @@"concurrently": false,"method": "btree","with": {}+ }+ },+ "foreignKeys": {+ "user_memories_user_id_users_id_fk": {+ "name": "user_memories_user_id_users_id_fk",+ "tableFrom": "user_memories",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_memories_context_projects": {+ "name": "user_memories_context_projects",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"},- "user_memories_activities_user_id_index": {- "name": "user_memories_activities_user_id_index",+ "context_id": {+ "name": "context_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "evidence_count": {+ "name": "evidence_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "is_primary": {+ "name": "is_primary",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_memories_context_projects_context_id_project_id_unique": {+ "name": "user_memories_context_projects_context_id_project_id_unique","columns": [{- "expression": "user_id",+ "expression": "context_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "project_id","isExpression": false,"asc": true,"nulls": "last"}],- "isUnique": false,+ "isUnique": true,"concurrently": false,"method": "btree","with": {}},- "user_memories_activities_user_memory_id_index": {- "name": "user_memories_activities_user_memory_id_index",+ "user_memories_context_projects_project_id_index": {+ "name": "user_memories_context_projects_project_id_index","columns": [{- "expression": "user_memory_id",+ "expression": "project_id","isExpression": false,"asc": true,"nulls": "last"@@ -38060,11 +39728,11 @@"method": "btree","with": {}},- "user_memories_activities_status_index": {- "name": "user_memories_activities_status_index",+ "user_memories_context_projects_user_id_index": {+ "name": "user_memories_context_projects_user_id_index","columns": [{- "expression": "status",+ "expression": "user_id","isExpression": false,"asc": true,"nulls": "last"@@ -38077,20 +39745,29 @@}},"foreignKeys": {- "user_memories_activities_user_id_users_id_fk": {- "name": "user_memories_activities_user_id_users_id_fk",- "tableFrom": "user_memories_activities",- "tableTo": "users",- "columnsFrom": ["user_id"],+ "user_memories_context_projects_context_id_user_memories_contexts_id_fk": {+ "name": "user_memories_context_projects_context_id_user_memories_contexts_id_fk",+ "tableFrom": "user_memories_context_projects",+ "tableTo": "user_memories_contexts",+ "columnsFrom": ["context_id"],"columnsTo": ["id"],"onDelete": "cascade","onUpdate": "no action"},- "user_memories_activities_user_memory_id_user_memories_id_fk": {- "name": "user_memories_activities_user_memory_id_user_memories_id_fk",- "tableFrom": "user_memories_activities",- "tableTo": "user_memories",- "columnsFrom": ["user_memory_id"],+ "user_memories_context_projects_project_id_projects_id_fk": {+ "name": "user_memories_context_projects_project_id_projects_id_fk",+ "tableFrom": "user_memories_context_projects",+ "tableTo": "projects",+ "columnsFrom": ["project_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_context_projects_user_id_users_id_fk": {+ "name": "user_memories_context_projects_user_id_users_id_fk",+ "tableFrom": "user_memories_context_projects",+ "tableTo": "users",+ "columnsFrom": ["user_id"],"columnsTo": ["id"],"onDelete": "cascade","onUpdate": "no action"@@ -38118,6 +39795,12 @@"primaryKey": false,"notNull": false},+ "user_memory_id": {+ "name": "user_memory_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },"user_memory_ids": {"name": "user_memory_ids","type": "jsonb",@@ -38192,6 +39875,42 @@"notNull": false,"default": 0},+ "now": {+ "name": "now",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "next_steps": {+ "name": "next_steps",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "open_questions": {+ "name": "open_questions",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "first_seen_at": {+ "name": "first_seen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_evidence_at": {+ "name": "last_evidence_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "synthesized_at": {+ "name": "synthesized_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },"captured_at": {"name": "captured_at","type": "timestamp with time zone",@@ -38282,6 +40001,42 @@"concurrently": false,"method": "gin","with": {}+ },+ "user_memories_contexts_user_memory_id_index": {+ "name": "user_memories_contexts_user_memory_id_index",+ "columns": [+ {+ "expression": "user_memory_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_contexts_user_id_last_evidence_at_index": {+ "name": "user_memories_contexts_user_id_last_evidence_at_index",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "last_evidence_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}}},"foreignKeys": {@@ -38293,6 +40048,1066 @@"columnsTo": ["id"],"onDelete": "cascade","onUpdate": "no action"+ },+ "user_memories_contexts_user_memory_id_user_memories_id_fk": {+ "name": "user_memories_contexts_user_memory_id_user_memories_id_fk",+ "tableFrom": "user_memories_contexts",+ "tableTo": "user_memories",+ "columnsFrom": ["user_memory_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_memories_dossiers": {+ "name": "user_memories_dossiers",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "context_id": {+ "name": "context_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_memory_id": {+ "name": "user_memory_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "summary": {+ "name": "summary",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "summary_vector": {+ "name": "summary_vector",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "now": {+ "name": "now",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "decisions": {+ "name": "decisions",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "first_seen_at": {+ "name": "first_seen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_evidence_at": {+ "name": "last_evidence_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "activity_count": {+ "name": "activity_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'private'"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_memories_dossiers_summary_vector_index": {+ "name": "user_memories_dossiers_summary_vector_index",+ "columns": [+ {+ "expression": "summary_vector",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "vector_cosine_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "hnsw",+ "with": {}+ },+ "user_memories_dossiers_context_id_index": {+ "name": "user_memories_dossiers_context_id_index",+ "columns": [+ {+ "expression": "context_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_dossiers_user_id_last_evidence_at_index": {+ "name": "user_memories_dossiers_user_id_last_evidence_at_index",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "last_evidence_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_dossiers_user_memory_id_index": {+ "name": "user_memories_dossiers_user_memory_id_index",+ "columns": [+ {+ "expression": "user_memory_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_dossiers_workspace_visibility_idx": {+ "name": "user_memories_dossiers_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_dossiers_agent_id_index": {+ "name": "user_memories_dossiers_agent_id_index",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_dossiers_project_id_index": {+ "name": "user_memories_dossiers_project_id_index",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_memories_dossiers_context_id_user_memories_contexts_id_fk": {+ "name": "user_memories_dossiers_context_id_user_memories_contexts_id_fk",+ "tableFrom": "user_memories_dossiers",+ "tableTo": "user_memories_contexts",+ "columnsFrom": ["context_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "user_memories_dossiers_user_id_users_id_fk": {+ "name": "user_memories_dossiers_user_id_users_id_fk",+ "tableFrom": "user_memories_dossiers",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_dossiers_workspace_id_workspaces_id_fk": {+ "name": "user_memories_dossiers_workspace_id_workspaces_id_fk",+ "tableFrom": "user_memories_dossiers",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_dossiers_agent_id_agents_id_fk": {+ "name": "user_memories_dossiers_agent_id_agents_id_fk",+ "tableFrom": "user_memories_dossiers",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_dossiers_project_id_projects_id_fk": {+ "name": "user_memories_dossiers_project_id_projects_id_fk",+ "tableFrom": "user_memories_dossiers",+ "tableTo": "projects",+ "columnsFrom": ["project_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_dossiers_user_memory_id_user_memories_id_fk": {+ "name": "user_memories_dossiers_user_memory_id_user_memories_id_fk",+ "tableFrom": "user_memories_dossiers",+ "tableTo": "user_memories",+ "columnsFrom": ["user_memory_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_memories_edges": {+ "name": "user_memories_edges",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "source_memory_id": {+ "name": "source_memory_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "target_memory_id": {+ "name": "target_memory_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "relation": {+ "name": "relation",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "evidence_count": {+ "name": "evidence_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_memories_edges_source_target_relation_unique": {+ "name": "user_memories_edges_source_target_relation_unique",+ "columns": [+ {+ "expression": "source_memory_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_memory_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "relation",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_edges_target_memory_id_relation_index": {+ "name": "user_memories_edges_target_memory_id_relation_index",+ "columns": [+ {+ "expression": "target_memory_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "relation",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_edges_user_id_relation_index": {+ "name": "user_memories_edges_user_id_relation_index",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "relation",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_edges_workspace_id_relation_index": {+ "name": "user_memories_edges_workspace_id_relation_index",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "relation",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_memories_edges_source_memory_id_user_memories_id_fk": {+ "name": "user_memories_edges_source_memory_id_user_memories_id_fk",+ "tableFrom": "user_memories_edges",+ "tableTo": "user_memories",+ "columnsFrom": ["source_memory_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_edges_target_memory_id_user_memories_id_fk": {+ "name": "user_memories_edges_target_memory_id_user_memories_id_fk",+ "tableFrom": "user_memories_edges",+ "tableTo": "user_memories",+ "columnsFrom": ["target_memory_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_edges_user_id_users_id_fk": {+ "name": "user_memories_edges_user_id_users_id_fk",+ "tableFrom": "user_memories_edges",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_edges_workspace_id_workspaces_id_fk": {+ "name": "user_memories_edges_workspace_id_workspaces_id_fk",+ "tableFrom": "user_memories_edges",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_memories_entities": {+ "name": "user_memories_entities",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "parent_entity_id": {+ "name": "parent_entity_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_memory_id": {+ "name": "user_memory_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'other'"+ },+ "relationship": {+ "name": "relationship",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description_vector": {+ "name": "description_vector",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "is_self": {+ "name": "is_self",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'private'"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_memories_entities_description_vector_index": {+ "name": "user_memories_entities_description_vector_index",+ "columns": [+ {+ "expression": "description_vector",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "vector_cosine_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "hnsw",+ "with": {}+ },+ "user_memories_entities_user_id_index": {+ "name": "user_memories_entities_user_id_index",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_entities_parent_entity_id_index": {+ "name": "user_memories_entities_parent_entity_id_index",+ "columns": [+ {+ "expression": "parent_entity_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_entities_user_memory_id_index": {+ "name": "user_memories_entities_user_memory_id_index",+ "columns": [+ {+ "expression": "user_memory_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_entities_user_id_self_unique": {+ "name": "user_memories_entities_user_id_self_unique",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"user_memories_entities\".\"is_self\"",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_entities_workspace_visibility_idx": {+ "name": "user_memories_entities_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_entities_agent_id_index": {+ "name": "user_memories_entities_agent_id_index",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_entities_project_id_index": {+ "name": "user_memories_entities_project_id_index",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_memories_entities_parent_entity_id_user_memories_entities_id_fk": {+ "name": "user_memories_entities_parent_entity_id_user_memories_entities_id_fk",+ "tableFrom": "user_memories_entities",+ "tableTo": "user_memories_entities",+ "columnsFrom": ["parent_entity_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "user_memories_entities_user_id_users_id_fk": {+ "name": "user_memories_entities_user_id_users_id_fk",+ "tableFrom": "user_memories_entities",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_entities_workspace_id_workspaces_id_fk": {+ "name": "user_memories_entities_workspace_id_workspaces_id_fk",+ "tableFrom": "user_memories_entities",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_entities_agent_id_agents_id_fk": {+ "name": "user_memories_entities_agent_id_agents_id_fk",+ "tableFrom": "user_memories_entities",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_entities_project_id_projects_id_fk": {+ "name": "user_memories_entities_project_id_projects_id_fk",+ "tableFrom": "user_memories_entities",+ "tableTo": "projects",+ "columnsFrom": ["project_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_entities_user_memory_id_user_memories_id_fk": {+ "name": "user_memories_entities_user_memory_id_user_memories_id_fk",+ "tableFrom": "user_memories_entities",+ "tableTo": "user_memories",+ "columnsFrom": ["user_memory_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_memories_entity_names": {+ "name": "user_memories_entity_names",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "entity_id": {+ "name": "entity_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "normalized": {+ "name": "normalized",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'alias'"+ },+ "source_memory_id": {+ "name": "source_memory_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_memories_entity_names_entity_id_normalized_unique": {+ "name": "user_memories_entity_names_entity_id_normalized_unique",+ "columns": [+ {+ "expression": "entity_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "normalized",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_entity_names_user_id_normalized_index": {+ "name": "user_memories_entity_names_user_id_normalized_index",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "normalized",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_entity_names_workspace_id_normalized_index": {+ "name": "user_memories_entity_names_workspace_id_normalized_index",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "normalized",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_memories_entity_names_entity_id_user_memories_entities_id_fk": {+ "name": "user_memories_entity_names_entity_id_user_memories_entities_id_fk",+ "tableFrom": "user_memories_entity_names",+ "tableTo": "user_memories_entities",+ "columnsFrom": ["entity_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_entity_names_user_id_users_id_fk": {+ "name": "user_memories_entity_names_user_id_users_id_fk",+ "tableFrom": "user_memories_entity_names",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_entity_names_workspace_id_workspaces_id_fk": {+ "name": "user_memories_entity_names_workspace_id_workspaces_id_fk",+ "tableFrom": "user_memories_entity_names",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_entity_names_source_memory_id_user_memories_id_fk": {+ "name": "user_memories_entity_names_source_memory_id_user_memories_id_fk",+ "tableFrom": "user_memories_entity_names",+ "tableTo": "user_memories",+ "columnsFrom": ["source_memory_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"}},"compositePrimaryKeys": {},@@ -38616,6 +41431,12 @@"primaryKey": false,"notNull": false},+ "entity_id": {+ "name": "entity_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },"captured_at": {"name": "captured_at","type": "timestamp with time zone",@@ -38706,6 +41527,21 @@"concurrently": false,"method": "btree","with": {}+ },+ "user_memories_identities_entity_id_index": {+ "name": "user_memories_identities_entity_id_index",+ "columns": [+ {+ "expression": "entity_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}}},"foreignKeys": {@@ -38726,6 +41562,15 @@"columnsTo": ["id"],"onDelete": "cascade","onUpdate": "no action"+ },+ "user_memories_identities_entity_id_user_memories_entities_id_fk": {+ "name": "user_memories_identities_entity_id_user_memories_entities_id_fk",+ "tableFrom": "user_memories_identities",+ "tableTo": "user_memories_entities",+ "columnsFrom": ["entity_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"}},"compositePrimaryKeys": {},@@ -38734,8 +41579,8 @@"checkConstraints": {},"isRLSEnabled": false},- "public.user_memories_preferences": {- "name": "user_memories_preferences",+ "public.user_memories_operations": {+ "name": "user_memories_operations","schema": "","columns": {"id": {@@ -38750,9 +41595,9 @@"primaryKey": false,"notNull": false},- "user_memory_id": {- "name": "user_memory_id",- "type": "varchar(255)",+ "workspace_id": {+ "name": "workspace_id",+ "type": "text","primaryKey": false,"notNull": false},@@ -38762,49 +41607,65 @@"primaryKey": false,"notNull": false},- "tags": {- "name": "tags",- "type": "text[]",+ "op": {+ "name": "op",+ "type": "text","primaryKey": false,- "notNull": false+ "notNull": true},- "conclusion_directives": {- "name": "conclusion_directives",+ "actor": {+ "name": "actor","type": "text","primaryKey": false,+ "notNull": true+ },+ "targets": {+ "name": "targets",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "before": {+ "name": "before",+ "type": "jsonb",+ "primaryKey": false,"notNull": false},- "conclusion_directives_vector": {- "name": "conclusion_directives_vector",- "type": "vector(1024)",+ "after": {+ "name": "after",+ "type": "jsonb","primaryKey": false,"notNull": false},- "type": {- "name": "type",- "type": "varchar(255)",+ "confidence": {+ "name": "confidence",+ "type": "real","primaryKey": false,"notNull": false},- "suggestions": {- "name": "suggestions",+ "reason": {+ "name": "reason","type": "text","primaryKey": false,"notNull": false},- "score_priority": {- "name": "score_priority",- "type": "numeric",+ "gate": {+ "name": "gate",+ "type": "text","primaryKey": false,- "notNull": false,- "default": 0+ "notNull": true},- "captured_at": {- "name": "captured_at",+ "state": {+ "name": "state",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "resolved_at": {+ "name": "resolved_at","type": "timestamp with time zone","primaryKey": false,- "notNull": true,- "default": "now()"+ "notNull": false},"accessed_at": {"name": "accessed_at",@@ -38829,27 +41690,23 @@}},"indexes": {- "user_memories_preferences_conclusion_directives_vector_index": {- "name": "user_memories_preferences_conclusion_directives_vector_index",+ "user_memories_operations_user_id_state_created_at_index": {+ "name": "user_memories_operations_user_id_state_created_at_index","columns": [{- "expression": "conclusion_directives_vector",+ "expression": "user_id","isExpression": false,"asc": true,- "nulls": "last",- "opclass": "vector_cosine_ops"- }- ],- "isUnique": false,- "concurrently": false,- "method": "hnsw",- "with": {}- },- "user_memories_preferences_user_id_index": {- "name": "user_memories_preferences_user_id_index",- "columns": [+ "nulls": "last"+ },{- "expression": "user_id",+ "expression": "state",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at","isExpression": false,"asc": true,"nulls": "last"@@ -38860,11 +41717,23 @@"method": "btree","with": {}},- "user_memories_preferences_user_memory_id_index": {- "name": "user_memories_preferences_user_memory_id_index",+ "user_memories_operations_workspace_id_state_created_at_index": {+ "name": "user_memories_operations_workspace_id_state_created_at_index","columns": [{- "expression": "user_memory_id",+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "state",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at","isExpression": false,"asc": true,"nulls": "last"@@ -38877,20 +41746,20 @@}},"foreignKeys": {- "user_memories_preferences_user_id_users_id_fk": {- "name": "user_memories_preferences_user_id_users_id_fk",- "tableFrom": "user_memories_preferences",+ "user_memories_operations_user_id_users_id_fk": {+ "name": "user_memories_operations_user_id_users_id_fk",+ "tableFrom": "user_memories_operations","tableTo": "users","columnsFrom": ["user_id"],"columnsTo": ["id"],"onDelete": "cascade","onUpdate": "no action"},- "user_memories_preferences_user_memory_id_user_memories_id_fk": {- "name": "user_memories_preferences_user_memory_id_user_memories_id_fk",- "tableFrom": "user_memories_preferences",- "tableTo": "user_memories",- "columnsFrom": ["user_memory_id"],+ "user_memories_operations_workspace_id_workspaces_id_fk": {+ "name": "user_memories_operations_workspace_id_workspaces_id_fk",+ "tableFrom": "user_memories_operations",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],"columnsTo": ["id"],"onDelete": "cascade","onUpdate": "no action"@@ -39256,6 +42125,259 @@"checkConstraints": {},"isRLSEnabled": false},+ "public.user_memories_preferences": {+ "name": "user_memories_preferences",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_memory_id": {+ "name": "user_memory_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "tags": {+ "name": "tags",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "conclusion_directives": {+ "name": "conclusion_directives",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "conclusion_directives_vector": {+ "name": "conclusion_directives_vector",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "suggestions": {+ "name": "suggestions",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "score_priority": {+ "name": "score_priority",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "holder_entity_id": {+ "name": "holder_entity_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "applies_to_entity_id": {+ "name": "applies_to_entity_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "evidence_source": {+ "name": "evidence_source",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "evidence_count": {+ "name": "evidence_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "last_evidence_at": {+ "name": "last_evidence_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_memories_preferences_conclusion_directives_vector_index": {+ "name": "user_memories_preferences_conclusion_directives_vector_index",+ "columns": [+ {+ "expression": "conclusion_directives_vector",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "vector_cosine_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "hnsw",+ "with": {}+ },+ "user_memories_preferences_user_id_index": {+ "name": "user_memories_preferences_user_id_index",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_preferences_user_memory_id_index": {+ "name": "user_memories_preferences_user_memory_id_index",+ "columns": [+ {+ "expression": "user_memory_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_preferences_holder_entity_id_index": {+ "name": "user_memories_preferences_holder_entity_id_index",+ "columns": [+ {+ "expression": "holder_entity_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_preferences_applies_to_entity_id_index": {+ "name": "user_memories_preferences_applies_to_entity_id_index",+ "columns": [+ {+ "expression": "applies_to_entity_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_memories_preferences_user_id_users_id_fk": {+ "name": "user_memories_preferences_user_id_users_id_fk",+ "tableFrom": "user_memories_preferences",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_preferences_user_memory_id_user_memories_id_fk": {+ "name": "user_memories_preferences_user_memory_id_user_memories_id_fk",+ "tableFrom": "user_memories_preferences",+ "tableTo": "user_memories",+ "columnsFrom": ["user_memory_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_preferences_holder_entity_id_user_memories_entities_id_fk": {+ "name": "user_memories_preferences_holder_entity_id_user_memories_entities_id_fk",+ "tableFrom": "user_memories_preferences",+ "tableTo": "user_memories_entities",+ "columnsFrom": ["holder_entity_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "user_memories_preferences_applies_to_entity_id_user_memories_entities_id_fk": {+ "name": "user_memories_preferences_applies_to_entity_id_user_memories_entities_id_fk",+ "tableFrom": "user_memories_preferences",+ "tableTo": "user_memories_entities",+ "columnsFrom": ["applies_to_entity_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },"public.acceptances": {"name": "acceptances","schema": "",diff --git a/packages/database/migrations/meta/_journal.json b/packages/database/migrations/meta/_journal.jsonindex b3cca284b3b..f21b8a8bea9 100644--- a/packages/database/migrations/meta/_journal.json+++ b/packages/database/migrations/meta/_journal.json@@ -1386,6 +1386,13 @@"when": 1793371200635,"tag": "0197_channel_jobs_message_member_unique","breakpoints": true+ },+ {+ "idx": 198,+ "version": "7",+ "when": 1793450092790,+ "tag": "0198_goal_visibility",+ "breakpoints": true}],"version": "6"diff --git a/packages/database/src/schemas/goal.ts b/packages/database/src/schemas/goal.tsindex acfe83647ed..6199af37951 100644--- a/packages/database/src/schemas/goal.ts+++ b/packages/database/src/schemas/goal.ts@@ -1,5 +1,5 @@import { goalStatuses, goalSubjectTypes } from '@lobechat/const/goal';-import type { GoalConfig } from '@lobechat/types';+import type { GoalConfig, GoalVisibility } from '@lobechat/types';import { index, integer, jsonb, pgTable, text } from 'drizzle-orm/pg-core';import { idGenerator } from '../utils/idGenerator';@@ -60,6 +60,13 @@ export const goals = pgTable(startedAt: timestamptz('started_at'),completedAt: timestamptz('completed_at'),++ // Visibility (mirrors agent / task visibility). Workspace goals are+ // 'public' (every member sees them) or 'private' (only the creator does);+ // `buildWorkspaceWhere` reads this column off the table, so every+ // goal-joined read is filtered without opting in. Personal-mode rows are+ // implicitly private to their owner and the column is ignored.+ visibility: text('visibility').$type<GoalVisibility>().default('public').notNull(),/** Recycle bin — see `schemas/trash.ts`. */...softDeleteColumns(),createdAt: createdAt(),@@ -68,6 +75,7 @@ export const goals = pgTable((t) => [index('goals_user_id_idx').on(t.userId),index('goals_workspace_id_idx').on(t.workspaceId),+ index('goals_workspace_visibility_idx').on(t.workspaceId, t.visibility, t.userId),index('goals_agent_id_idx').on(t.agentId),index('goals_project_id_idx').on(t.projectId),index('goals_status_idx').on(t.status),diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.tsindex ea2d68344ac..ae15c80ea3d 100644--- a/packages/locales/src/default/chat.ts+++ b/packages/locales/src/default/chat.ts@@ -2442,6 +2442,10 @@ export default {'goalChat.welcome':"Ask the agent about this goal — how it's going, what's blocking, or what happens next.",'goalDetail.acceptanceError': 'Could not load acceptance checks.',+ 'goalDetail.visibility.changeFailed': 'Failed to change goal visibility',+ 'goalDetail.visibility.creatorOnly': "Only the goal's creator can change its visibility",+ 'goalDetail.visibility.privateAgentLocked': 'Private agents can only run private goals.',+ 'goalDetail.visibility.privateProjectLocked': 'Goals in a private project stay private.','goalDetail.acceptanceProgress': 'Acceptance progress','goalDetail.agentRun': 'Agent run','goalDetail.definition': 'Goal definition',diff --git a/packages/types/src/goal.ts b/packages/types/src/goal.tsindex 08738c5b5b5..3f01ce10874 100644--- a/packages/types/src/goal.ts+++ b/packages/types/src/goal.ts@@ -35,6 +35,14 @@ export type GoalStatus =*/export type GoalSubjectType = 'task' | 'topic' | 'standalone';+/**+ * Who in a team workspace can see a goal. Mirrors agent / task visibility:+ * 'public' goals are visible to every member, 'private' ones only to their+ * creator. Personal-mode goals are implicitly private and ignore it.+ */+export const GOAL_VISIBILITIES = ['private', 'public'] as const;+export type GoalVisibility = (typeof GOAL_VISIBILITIES)[number];+/** Automatic recovery policy for Goal Graph Tasks. */export interface GoalRecoveryPolicy {/** Maximum execution attempts for one Task before escalating to a decision gate. */@@ -553,6 +561,8 @@ export interface GoalItem {title: string;updatedAt: Date;userId: string;+ /** Who in the workspace sees the goal; see {@link GoalVisibility}. */+ visibility: GoalVisibility;workspaceId: string | null;}diff --git a/src/features/AgentGoals/GoalAgentModelConfig.tsx b/src/features/AgentGoals/GoalAgentModelConfig.tsxindex 6db6c838e3c..249af936f45 100644--- a/src/features/AgentGoals/GoalAgentModelConfig.tsx+++ b/src/features/AgentGoals/GoalAgentModelConfig.tsx@@ -25,7 +25,7 @@ const GoalAgentModelConfig = ({routeAgentId,}: GoalAgentModelConfigProps) => {const { t } = useTranslation('chat');- const { executor, planner, viewerIsOwner } = useGoalAgentModel({ goalId, routeAgentId });+ const { executor, planner, privateAgentsAllowed } = useGoalAgentModel({ goalId, routeAgentId });return (<Flexbox horizontal align={'center'} gap={8} style={{ minWidth: 0 }} wrap={'wrap'}>@@ -33,7 +33,7 @@ const GoalAgentModelConfig = ({agentId={planner.agentId}disabled={disabled}disabledReason={disabledReason}- hidePrivateAgents={!viewerIsOwner}+ hidePrivateAgents={!privateAgentsAllowed}label={t('goalDetail.mainAgentLabel')}placeholder={t('goalDetail.mainAgentUnassigned')}tooltip={t('goalDetail.mainAgent')}@@ -59,7 +59,7 @@ const GoalAgentModelConfig = ({agentId={executor.agentId}disabled={disabled}disabledReason={disabledReason}- hidePrivateAgents={!viewerIsOwner}+ hidePrivateAgents={!privateAgentsAllowed}label={t('goalDetail.taskAgentLabel')}placeholder={t('goalDetail.taskAgentFollowsMain')}tooltip={t('goalDetail.taskAgent')}diff --git a/src/features/AgentGoals/GoalCardItem.tsx b/src/features/AgentGoals/GoalCardItem.tsxindex fc7442247fd..94031a9df7f 100644--- a/src/features/AgentGoals/GoalCardItem.tsx+++ b/src/features/AgentGoals/GoalCardItem.tsx@@ -10,6 +10,7 @@ import { useActiveRouteParams } from '@/hooks/useActiveRouteParams';import GoalAgentLabel from './GoalAgentLabel';import GoalItemMoreButton from './GoalItemMoreButton';import { goalItemPath } from './goalItemPath';+import GoalPrivateMark from './GoalPrivateMark';import { GoalProgress } from './GoalProgress';import GoalStatusGlyph from './GoalStatusGlyph';import type { GoalItemProps } from './types';@@ -76,6 +77,7 @@ export const GoalCardItem = memo<GoalItemProps>(({ globalScopeId, goal: item, pr<Text ellipsis fontSize={15} weight={600}>{goal.title}</Text>+ <GoalPrivateMark goal={goal} /></Flexbox>{goal.requirement && goal.requirement !== goal.title && (<Text ellipsis fontSize={12} type={'secondary'}>diff --git a/src/features/AgentGoals/GoalDetailPage.tsx b/src/features/AgentGoals/GoalDetailPage.tsxindex 942871d4e61..151f14e1abb 100644--- a/src/features/AgentGoals/GoalDetailPage.tsx+++ b/src/features/AgentGoals/GoalDetailPage.tsx@@ -38,6 +38,7 @@ import { goalManagerConversation } from './goalPresentation';import GoalRequirement from './GoalRequirement';import { GoalSupervision } from './GoalSupervision';import GoalSupervisorToggle from './GoalSupervisorToggle';+import GoalVisibilitySelector from './GoalVisibilitySelector';import GoalWorkspaceBreadcrumb from './GoalWorkspaceBreadcrumb';import NorthStarMetrics from './NorthStarMetrics';import ProcessControl from './ProcessControl';@@ -370,6 +371,7 @@ const GoalDetailPage = memo<GoalDetailPageProps>(({ agentId, goalId }) => {canEdit ? t('goalDetail.agentManagedByOwner') : editBlockedReason}/>+ <GoalVisibilitySelector goalId={goal.id} />{goal.status === 'draft' && (<Text fontSize={12} type={'secondary'}>{t('goalProcess.draft')}diff --git a/src/features/AgentGoals/GoalListItem.tsx b/src/features/AgentGoals/GoalListItem.tsxindex fa42774391e..fa94c1537dd 100644--- a/src/features/AgentGoals/GoalListItem.tsx+++ b/src/features/AgentGoals/GoalListItem.tsx@@ -10,6 +10,7 @@ import { useActiveRouteParams } from '@/hooks/useActiveRouteParams';import GoalAgentLabel from './GoalAgentLabel';import GoalItemMoreButton from './GoalItemMoreButton';import { goalItemPath } from './goalItemPath';+import GoalPrivateMark from './GoalPrivateMark';import { GoalProgress } from './GoalProgress';import GoalStatusGlyph from './GoalStatusGlyph';import type { GoalItemProps } from './types';@@ -93,6 +94,7 @@ export const GoalListItem = memo<GoalItemProps>(({ globalScopeId, goal: item, pr<Text ellipsis fontSize={15} weight={600}>{goal.title}</Text>+ <GoalPrivateMark goal={goal} /></Flexbox>{goal.requirement && goal.requirement !== goal.title && (<Text ellipsis fontSize={12} type={'secondary'}>diff --git a/src/features/AgentGoals/GoalPrivateMark.tsx b/src/features/AgentGoals/GoalPrivateMark.tsxnew file mode 100644index 00000000000..f78f62dddcd--- /dev/null+++ b/src/features/AgentGoals/GoalPrivateMark.tsx@@ -0,0 +1,38 @@+import { cssVar, Icon, Tooltip } from '@lobehub/ui';+import { LockIcon } from 'lucide-react';+import { memo } from 'react';+import { useTranslation } from 'react-i18next';++import {+ getTaskVisibilityDefaultLabel,+ getTaskVisibilityLabelKey,+} from '@/features/AgentTasks/features/taskVisibilityLabel';++interface GoalPrivateMarkProps {+ goal: { visibility?: 'private' | 'public' | null; workspaceId: string | null };+}++/** A lock next to a private workspace goal's title; personal goals are private by nature. */+const GoalPrivateMark = memo<GoalPrivateMarkProps>(({ goal }) => {+ const { t } = useTranslation('chat');+ if (!goal.workspaceId || goal.visibility !== 'private') return null;++ return (+ <Tooltip+ title={t(getTaskVisibilityLabelKey('private') as never, {+ defaultValue: getTaskVisibilityDefaultLabel('private'),+ })}+ >+ <Icon+ color={cssVar.colorTextDescription}+ icon={LockIcon}+ size={14}+ style={{ flex: 'none' }}+ />+ </Tooltip>+ );+});++GoalPrivateMark.displayName = 'GoalPrivateMark';++export default GoalPrivateMark;diff --git a/src/features/AgentGoals/GoalVisibilitySelector.tsx b/src/features/AgentGoals/GoalVisibilitySelector.tsxnew file mode 100644index 00000000000..09352a8df2d--- /dev/null+++ b/src/features/AgentGoals/GoalVisibilitySelector.tsx@@ -0,0 +1,76 @@+import { toast } from '@lobehub/ui';+import { memo, useState } from 'react';+import { useTranslation } from 'react-i18next';++import TaskVisibilityChipLabel from '@/features/AgentTasks/features/TaskVisibilityChipLabel';+import TaskVisibilityTag from '@/features/AgentTasks/features/TaskVisibilityTag';+import { useAgentVisibility } from '@/features/AgentTasks/shared/useAgentVisibility';+import { goalSelectors, useGoalStore } from '@/store/goal';+import { projectByRefSelector, useProjectStore } from '@/store/project';+import { useUserStore } from '@/store/user';+import { userProfileSelectors } from '@/store/user/selectors';++import { goalVisibilityLockKey } from './goalVisibilityLock';++interface GoalVisibilitySelectorProps {+ goalId: string;+}++/**+ * Who in the Workspace sees the goal, as the same Private / Workspace chip a+ * Task carries. Only the creator may switch it (the server's rule), and a goal+ * run by a private agent, or in a private project, cannot go public. Hidden outside a Workspace.+ */+const GoalVisibilitySelector = memo<GoalVisibilitySelectorProps>(({ goalId }) => {+ const { t } = useTranslation('chat');+ const [saving, setSaving] = useState(false);+ const graph = goalSelectors.goalGraph(goalId);+ const workspaceId = useGoalStore((s) => graph(s)?.goal.workspaceId);+ const ownerId = useGoalStore((s) => graph(s)?.goal.userId);+ // Rows read before the column shipped carry no value: they are public.+ const visibility = useGoalStore((s) => graph(s)?.goal.visibility) ?? 'public';+ const agentId = useGoalStore((s) => graph(s)?.goal.agentId);+ const taskAgentId = useGoalStore((s) => graph(s)?.goal.config?.taskAgentId);+ const projectId = useGoalStore((s) => graph(s)?.goal.projectId) ?? undefined;+ // The project list is persisted, so its row is usually here; unknown means no lock.+ const projectPrivate = useProjectStore(+ (s) => projectByRefSelector(projectId)(s)?.visibility === 'private',+ );+ const setGoalVisibility = useGoalStore((s) => s.setGoalVisibility);+ const viewerId = useUserStore(userProfileSelectors.userId);+ const agentPrivate = useAgentVisibility(agentId) === 'private';+ const taskAgentPrivate = useAgentVisibility(taskAgentId) === 'private';++ if (!workspaceId) return null;++ const lockKey = goalVisibilityLockKey({+ agentPrivate: agentPrivate || taskAgentPrivate,+ ownerId,+ projectPrivate,+ viewerId,+ visibility,+ });+ const lockedReason = lockKey ? t(lockKey) : undefined;++ const change = async (next: 'private' | 'public') => {+ if (saving) return;+ setSaving(true);+ try {+ await setGoalVisibility(goalId, next);+ } catch (error) {+ toast.error((error as Error).message || t('goalDetail.visibility.changeFailed'));+ } finally {+ setSaving(false);+ }+ };++ return (+ <TaskVisibilityTag lockedReason={lockedReason} visibility={visibility} onChange={change}>+ <TaskVisibilityChipLabel style={{ minHeight: 32 }} visibility={visibility} />+ </TaskVisibilityTag>+ );+});++GoalVisibilitySelector.displayName = 'GoalVisibilitySelector';++export default GoalVisibilitySelector;diff --git a/src/features/AgentGoals/ProcessControl/Graph/batchModel.test.ts b/src/features/AgentGoals/ProcessControl/Graph/batchModel.test.tsindex 64b333c9b36..8c152b40c12 100644--- a/src/features/AgentGoals/ProcessControl/Graph/batchModel.test.ts+++ b/src/features/AgentGoals/ProcessControl/Graph/batchModel.test.ts@@ -150,6 +150,7 @@ const batchSnapshot = ({title: 'Batch',updatedAt: T0,userId: 'user-1',+ visibility: 'public',workspaceId: null,},nodes,diff --git a/src/features/AgentGoals/ProcessControl/Graph/viewMode.test.ts b/src/features/AgentGoals/ProcessControl/Graph/viewMode.test.tsindex 5deb8065d25..7f8d8c95cb5 100644--- a/src/features/AgentGoals/ProcessControl/Graph/viewMode.test.ts+++ b/src/features/AgentGoals/ProcessControl/Graph/viewMode.test.ts@@ -23,6 +23,7 @@ const goal = (status: GoalStatus): GoalItem => ({title: 'Goal',updatedAt: T0,userId: 'user-1',+ visibility: 'public',workspaceId: null,});diff --git a/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.ts b/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.tsindex 9924ac97c2d..b4036c8b98d 100644--- a/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.ts+++ b/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.ts@@ -43,6 +43,7 @@ const goal = (overrides: Partial<GoalItem> = {}): GoalItem => ({title: 'Goal',updatedAt: T0,userId: 'user-1',+ visibility: 'public',workspaceId: null,...overrides,});diff --git a/src/features/AgentGoals/goalVisibilityLock.test.ts b/src/features/AgentGoals/goalVisibilityLock.test.tsnew file mode 100644index 00000000000..620d7a60dd6--- /dev/null+++ b/src/features/AgentGoals/goalVisibilityLock.test.ts@@ -0,0 +1,66 @@+import { describe, expect, it } from 'vitest';++import { goalVisibilityLockKey } from './goalVisibilityLock';++describe('goalVisibilityLockKey', () => {+ it('lets the creator switch a goal on public agents either way', () => {+ for (const visibility of ['private', 'public'] as const)+ expect(+ goalVisibilityLockKey({ agentPrivate: false, ownerId: 'u1', viewerId: 'u1', visibility }),+ ).toBeUndefined();+ });++ it('locks it for anyone but the creator, workspace owners included', () => {+ expect(+ goalVisibilityLockKey({+ agentPrivate: false,+ ownerId: 'u1',+ viewerId: 'u2',+ visibility: 'public',+ }),+ ).toBe('goalDetail.visibility.creatorOnly');+ });++ it('locks it while the profile has not loaded', () => {+ expect(+ goalVisibilityLockKey({+ agentPrivate: false,+ ownerId: 'u1',+ viewerId: undefined,+ visibility: 'public',+ }),+ ).toBe('goalDetail.visibility.creatorOnly');+ });++ it('keeps a goal a private agent runs private, but still lets it go private', () => {+ expect(+ goalVisibilityLockKey({+ agentPrivate: true,+ ownerId: 'u1',+ viewerId: 'u1',+ visibility: 'private',+ }),+ ).toBe('goalDetail.visibility.privateAgentLocked');+ // A legacy public goal on a private agent can still be fixed by going private.+ expect(+ goalVisibilityLockKey({+ agentPrivate: true,+ ownerId: 'u1',+ viewerId: 'u1',+ visibility: 'public',+ }),+ ).toBeUndefined();+ });++ it('keeps a goal in a private project private', () => {+ expect(+ goalVisibilityLockKey({+ agentPrivate: false,+ ownerId: 'u1',+ projectPrivate: true,+ viewerId: 'u1',+ visibility: 'private',+ }),+ ).toBe('goalDetail.visibility.privateProjectLocked');+ });+});diff --git a/src/features/AgentGoals/goalVisibilityLock.ts b/src/features/AgentGoals/goalVisibilityLock.tsnew file mode 100644index 00000000000..588dc501035--- /dev/null+++ b/src/features/AgentGoals/goalVisibilityLock.ts@@ -0,0 +1,30 @@+export interface GoalVisibilityLockInput {+ /** Either of the goal's agents (supervisor, dedicated executor) is private. */+ agentPrivate: boolean;+ ownerId?: string | null;+ /** The goal sits in a private workspace project. */+ projectPrivate?: boolean;+ viewerId?: string | null;+ visibility: 'private' | 'public';+}++/**+ * Why the viewer cannot switch the goal's visibility, or `undefined` when they+ * can. Mirrors the server: only the creator may, and a goal a private agent+ * runs, or one in a private project, cannot go public. Returns a `chat`+ * locale key.+ */+export const goalVisibilityLockKey = ({+ agentPrivate,+ ownerId,+ projectPrivate,+ viewerId,+ visibility,+}: GoalVisibilityLockInput) => {+ if (!ownerId || ownerId !== viewerId) return 'goalDetail.visibility.creatorOnly' as const;+ if (visibility === 'private' && agentPrivate)+ return 'goalDetail.visibility.privateAgentLocked' as const;+ if (visibility === 'private' && projectPrivate)+ return 'goalDetail.visibility.privateProjectLocked' as const;+ return undefined;+};diff --git a/src/features/AgentGoals/useGoalAgentModel.ts b/src/features/AgentGoals/useGoalAgentModel.tsindex e6ffe578553..3420c5571c1 100644--- a/src/features/AgentGoals/useGoalAgentModel.ts+++ b/src/features/AgentGoals/useGoalAgentModel.ts@@ -84,6 +84,12 @@ export const useGoalAgentModel = ({ goalId, routeAgentId }: UseGoalAgentModelPar// goal cannot see. Their planner fallback here is their own, so a pick that// matches it must be kept, not cleared into the owner's unknown default.const viewerIsOwner = !ownerId || ownerId === viewerId;+ // A public workspace goal cannot run on a private agent (the server refuses+ // the handoff), so its pickers offer only public ones.+ const publicGoal = useGoalStore((s) => {+ const goal = graph(s)?.goal;+ return !!goal?.workspaceId && goal.visibility !== 'private';+ });const systemGoalModel = useUserStore(systemAgentSelectors.goal);// The system goal model lives in user settings; before they load it reads as// the built-in default.@@ -141,6 +147,7 @@ export const useGoalAgentModel = ({ goalId, routeAgentId }: UseGoalAgentModelPar});return {+ privateAgentsAllowed: viewerIsOwner && !publicGoal,viewerIsOwner,executor: {agentId: taskAgentId,diff --git a/src/services/goal.ts b/src/services/goal.tsindex 7fe0eefb6be..3a920d9d76b 100644--- a/src/services/goal.ts+++ b/src/services/goal.ts@@ -203,6 +203,10 @@ class GoalService {setTaskAgent = async (id: string, agentId: string | null) =>lambdaClient.goal.setTaskAgent.mutate({ agentId, id });+ /** Make a workspace goal private or public; its own Tasks follow. */+ setVisibility = async (id: string, visibility: 'private' | 'public') =>+ lambdaClient.goal.setVisibility.mutate({ id, visibility });+/** The model the goal agent plans with; `null` falls back to the agent's own. */setModel = async (id: string, modelConfig: { model: string; provider: string } | null) =>lambdaClient.goal.setModel.mutate({ id, modelConfig });diff --git a/src/store/goal/action.ts b/src/store/goal/action.tsindex a5640423271..d935c96ae65 100644--- a/src/store/goal/action.ts+++ b/src/store/goal/action.ts@@ -394,6 +394,16 @@ export class GoalActionImpl {await this.refreshGoalGraph(goalId);};+ /** The goal leaves (or joins) other members' lists, and its Tasks move with it. */+ setGoalVisibility = async (goalId: string, visibility: 'private' | 'public'): Promise<void> => {+ await goalService.setVisibility(goalId, visibility);+ await Promise.all([+ this.refreshGoalGraph(goalId),+ revalidateReplica(goalListResource),+ revalidateReplica(homeGoalListResource),+ ]);+ };+setGoalModel = async (goalId: string,modelConfig: { model: string; provider: string } | null,