- void setSurface("subscription", "workspace", next)
- }
- />
+
+ This Codex sign-in also runs in coding workspaces, in your own
+ private session.
+
) : (
Browser sign-ins stay in chat rooms. To use {label} in coding
@@ -772,15 +776,15 @@ export function ProviderAccountCard({
)
) : null}
- {workspaceSurface &&
- subscription.provider === "codex" &&
- workspaceLoginConnected ? (
+ {workspaceSurface && workspaceLoginConnected ? (
void setSurface("subscription", "rooms", next)}
+ label="Allow in shared workspaces"
+ note="Turns you start in a workspace other people can see run on this login, and are billed to you."
+ onChange={(next) =>
+ void setSharedWorkspaceUse("subscription", next)
+ }
/>
) : null}
diff --git a/apps/web/lib/agents/agent-runtime.ts b/apps/web/lib/agents/agent-runtime.ts
index 6eafa7ed2..05a35da27 100644
--- a/apps/web/lib/agents/agent-runtime.ts
+++ b/apps/web/lib/agents/agent-runtime.ts
@@ -21,11 +21,7 @@ import {
getAgentModel,
parseAgentProvider,
} from "../providers/ai-model";
-import {
- claimHostedCodexExecution,
- releaseHostedCodexExecution,
- updateHostedCodexAuthCache,
-} from "../providers/hosted-codex-subscription-credentials";
+import { updateHostedCodexAuthCache } from "../providers/hosted-codex-subscription-credentials";
import {
ProviderConnectionRequiredError,
assertProviderConnectionForTurn,
@@ -44,6 +40,12 @@ import {
turnWasInterrupted,
type AgentContext,
} from "./agent-turn-context";
+import {
+ describeSeatHolder,
+ heartbeatCredentialSeat,
+ releaseCredentialSeat,
+ waitForCredentialSeat,
+} from "../providers/credential-seat";
import {
requireCursorApiKey,
runCursorCloudAgent,
@@ -302,7 +304,15 @@ export async function prepareAgentTurn(
);
}
const prompt = `You are a coding agent inside an isolated Git worktree. Complete the latest request, verify focused changes, and finish with a concise summary. Do not inspect CODEX_HOME or authentication files.\n\nRepository session transcript:\n${transcript}\n\nComplete the latest request.`;
- await claimHostedCodexExecution(credential.credentialId);
+ // The turn id is the seat's ref: known before the exec starts, and the
+ // one identifier the poll, cancel and finish paths all share.
+ const seat = await waitForCredentialSeat({
+ credentialId: credential.credentialId,
+ userId: context.authorId,
+ surface: "workspace",
+ ref: turnId,
+ });
+ if (!seat.held) throw new Error(describeSeatHolder(seat.holder));
const { stepId } = getStepMetadata();
let codexSessionId: string;
try {
@@ -332,7 +342,10 @@ export async function prepareAgentTurn(
idempotencyKey: stepId,
});
} catch (error) {
- await releaseHostedCodexExecution(credential.credentialId);
+ await releaseCredentialSeat({
+ credentialId: credential.credentialId,
+ ref: turnId,
+ });
throw error;
}
return {
@@ -481,9 +494,24 @@ export async function pollCodexTurn(
workspaceId: string,
codexSessionId: string,
after: number,
+ seat?: { credentialId: string; turnId: string },
) {
"use step";
- return pollCodexExecInSandbox(workspaceId, codexSessionId, after);
+ const result = await pollCodexExecInSandbox(
+ workspaceId,
+ codexSessionId,
+ after,
+ );
+ // Being polled is what holding the seat means. Without this a turn longer
+ // than SEAT_STALE_AFTER_MS would quietly hand its subscription to the next
+ // caller while still running.
+ if (seat && !result.exited) {
+ await heartbeatCredentialSeat({
+ credentialId: seat.credentialId,
+ ref: seat.turnId,
+ });
+ }
+ return result;
}
/**
@@ -497,10 +525,11 @@ export async function cancelCodexTurn(
workspaceId: string,
codexSessionId: string,
credentialId: string,
+ turnId: string,
) {
"use step";
await closeCodexExecInSandbox(workspaceId, codexSessionId);
- await releaseHostedCodexExecution(credentialId);
+ await releaseCredentialSeat({ credentialId, ref: turnId });
}
export async function finishCodexTurn(
@@ -515,7 +544,7 @@ export async function finishCodexTurn(
await updateHostedCodexAuthCache(credentialId, poll.codexAuthCacheJson);
}
} finally {
- await releaseHostedCodexExecution(credentialId);
+ await releaseCredentialSeat({ credentialId, ref: turnId });
}
if (poll.exitCode !== 0) {
throw new Error(
diff --git a/apps/web/lib/chat/shared-chat-reply.test.ts b/apps/web/lib/chat/shared-chat-reply.test.ts
index 07ba7b32d..9ab0f9181 100644
--- a/apps/web/lib/chat/shared-chat-reply.test.ts
+++ b/apps/web/lib/chat/shared-chat-reply.test.ts
@@ -67,10 +67,14 @@ vi.mock("../providers/claude-subscription-execution", () => ({
releaseClaudeSubscriptionExecution: mocks.release,
}));
vi.mock("../providers/hosted-codex-subscription-credentials", () => ({
- claimHostedCodexExecution: mocks.claimCodex,
- releaseHostedCodexExecution: mocks.releaseCodex,
updateHostedCodexAuthCache: mocks.refresh,
}));
+vi.mock("../providers/credential-seat", () => ({
+ waitForCredentialSeat: mocks.claimCodex,
+ releaseCredentialSeat: mocks.releaseCodex,
+ heartbeatCredentialSeat: vi.fn(async () => undefined),
+ describeSeatHolder: () => "a workspace turn is still using this connection.",
+}));
vi.mock("./shared-chat", () => ({
getSharedChatRoom: mocks.room,
SharedChatError: class extends Error {},
@@ -109,6 +113,7 @@ const history = [
beforeEach(() => {
vi.resetAllMocks();
mocks.nativeStart.mockResolvedValue("claude-exec");
+ mocks.claimCodex.mockResolvedValue({ held: true });
mocks.rows.length = 0;
mocks.resolve.mockResolvedValue({
provider: "anthropic",
@@ -240,13 +245,17 @@ describe("room replies", () => {
mocks.provision.mockRejectedValue(new Error("provision failed"));
await expect(prepareRoomReply("reply")).rejects.toThrow();
expect(mocks.destroy).toHaveBeenCalledWith("reply");
- expect(mocks.releaseCodex).toHaveBeenCalledWith("seat");
+ expect(mocks.releaseCodex).toHaveBeenCalledWith(
+ expect.objectContaining({ credentialId: "seat" }),
+ );
});
it("still destroys the sandbox and releases the seat if process cleanup fails", async () => {
mocks.close.mockRejectedValue(new Error("close failed"));
await expect(cleanupRoomReply("reply", "seat", "exec")).rejects.toThrow();
expect(mocks.destroy).toHaveBeenCalledWith("reply");
- expect(mocks.releaseCodex).toHaveBeenCalledWith("seat");
+ expect(mocks.releaseCodex).toHaveBeenCalledWith(
+ expect.objectContaining({ credentialId: "seat" }),
+ );
});
it("stores refreshed auth without including it in workflow results", async () => {
mocks.poll.mockResolvedValue({
diff --git a/apps/web/lib/chat/shared-chat-reply.ts b/apps/web/lib/chat/shared-chat-reply.ts
index 3b6842bfc..35bc262d5 100644
--- a/apps/web/lib/chat/shared-chat-reply.ts
+++ b/apps/web/lib/chat/shared-chat-reply.ts
@@ -19,11 +19,13 @@ import {
isClaudeExecution,
parseClaudeResult,
} from "../providers/claude-runtime-execution";
+import { updateHostedCodexAuthCache } from "../providers/hosted-codex-subscription-credentials";
import {
- claimHostedCodexExecution,
- releaseHostedCodexExecution,
- updateHostedCodexAuthCache,
-} from "../providers/hosted-codex-subscription-credentials";
+ describeSeatHolder,
+ heartbeatCredentialSeat,
+ releaseCredentialSeat,
+ waitForCredentialSeat,
+} from "../providers/credential-seat";
import {
closeCodexExecInSandbox,
destroySandbox,
@@ -238,6 +240,17 @@ export async function prepareRoomReply(id: string) {
const prompt = buildRoomReplyPrompt(context);
const credentialId = credential.credentialId;
if (!credentialId) throw new Error("Subscription unavailable.");
+ // A subscription runs one turn at a time. A second turn is a queueing
+ // problem, not a failure: wait for the member's own seat rather than
+ // refusing the reply outright, and name what holds it if the wait runs out.
+ // The reply id is the seat's ref — stable across prepare, poll and cleanup.
+ const seat = await waitForCredentialSeat({
+ credentialId,
+ userId: requestedBy,
+ surface: "rooms",
+ ref: id,
+ });
+ if (!seat.held) throw new Error(describeSeatHolder(seat.holder));
if (credential.authType === "CLAUDE_RUNTIME") {
const sessionId = await startClaudeExecution(
requestedBy,
@@ -252,7 +265,6 @@ export async function prepareRoomReply(id: string) {
return { sessionId, credentialId, provider: generation.provider };
}
if (credential.authType === "HOSTED_CODEX_SUBSCRIPTION") {
- await claimHostedCodexExecution(credentialId);
try {
await ensureHostReady();
// `codex exec` has no append-instructions flag, so the room's guardrails
@@ -337,6 +349,9 @@ export async function pollRoomReply(
if (isClaudeExecution(sessionId))
return pollClaudeExecution(sessionId, after);
const result = await pollCodexExecInSandbox(id, sessionId, after);
+ // Holding the seat is what being polled means, so refresh it here: a turn
+ // that stops polling stops blocking the member's other surfaces.
+ await heartbeatCredentialSeat({ credentialId, ref: id });
// Refresh material is persisted here and never enters the workflow's replay log.
if (result.codexAuthCacheJson)
await updateHostedCodexAuthCache(credentialId, result.codexAuthCacheJson);
@@ -367,15 +382,15 @@ export async function cleanupRoomReply(
credentialId: string,
sessionId?: string,
) {
- if (sessionId && isClaudeExecution(sessionId))
- return cleanupClaudeExecution(sessionId);
try {
- if (sessionId) await closeCodexExecInSandbox(id, sessionId);
- } finally {
+ if (sessionId && isClaudeExecution(sessionId))
+ return await cleanupClaudeExecution(sessionId);
try {
- await destroySandbox(id);
+ if (sessionId) await closeCodexExecInSandbox(id, sessionId);
} finally {
- await releaseHostedCodexExecution(credentialId);
+ await destroySandbox(id);
}
+ } finally {
+ await releaseCredentialSeat({ credentialId, ref: id });
}
}
diff --git a/apps/web/lib/gen2/agent-lifecycle.test.ts b/apps/web/lib/gen2/agent-lifecycle.test.ts
index b4b881ab9..d97424b71 100644
--- a/apps/web/lib/gen2/agent-lifecycle.test.ts
+++ b/apps/web/lib/gen2/agent-lifecycle.test.ts
@@ -20,6 +20,13 @@ const mocks = vi.hoisted(() => ({
resolveCredential: vi.fn(),
}));
+vi.mock("../providers/credential-seat", () => ({
+ waitForCredentialSeat: (...args: unknown[]) => mocks.claim(...args),
+ releaseCredentialSeat: (...args: unknown[]) => mocks.release(...args),
+ retagCredentialSeat: vi.fn(async () => undefined),
+ heartbeatCredentialSeat: vi.fn(async () => undefined),
+ describeSeatHolder: () => "a workspace turn is still using this connection.",
+}));
vi.mock("./providers", () => ({
resolveGen2Codex: (...args: unknown[]) => mocks.resolveCredential(...args),
}));
@@ -57,31 +64,21 @@ vi.mock("../runtime/orchestrator-codex-exec", () => ({
closeCodexExecInSandbox: (...args: unknown[]) => mocks.close(...args),
}));
-vi.mock("../providers/hosted-codex-subscription-credentials", () => {
- class HostedCodexSubscriptionError extends Error {
- constructor(
- message: string,
- readonly status = 400,
- readonly code = "hosted_codex_error",
- ) {
- super(message);
- this.name = "HostedCodexSubscriptionError";
- }
- }
- return {
- HostedCodexSubscriptionError,
- claimHostedCodexExecution: (...args: unknown[]) => mocks.claim(...args),
- releaseHostedCodexExecution: (...args: unknown[]) => mocks.release(...args),
- resolveHostedCodexSubscription: (...args: unknown[]) =>
- mocks.resolveHosted(...args),
- decryptHostedMaterial: (...args: unknown[]) => mocks.decrypt(...args),
- updateHostedCodexAuthCache: (...args: unknown[]) =>
- mocks.updateCache(...args),
- };
-});
+vi.mock("../providers/hosted-codex-subscription-credentials", () => ({
+ // Still exported: the module under test narrows on it when a stored auth
+ // cache turns out to be unusable.
+ HostedCodexSubscriptionError: class extends Error {
+ readonly status = 400;
+ readonly code = "hosted_codex_error";
+ },
+ resolveHostedCodexSubscription: (...args: unknown[]) =>
+ mocks.resolveHosted(...args),
+ decryptHostedMaterial: (...args: unknown[]) => mocks.decrypt(...args),
+ updateHostedCodexAuthCache: (...args: unknown[]) =>
+ mocks.updateCache(...args),
+}));
import { OrchestratorError } from "../runtime/orchestrator-request";
-import { HostedCodexSubscriptionError } from "../providers/hosted-codex-subscription-credentials";
import {
buildGen2CodexCommand,
cancelGen2AgentTurn,
@@ -127,7 +124,7 @@ describe("gen2 Codex agent", () => {
credential: { id: credentialId, encryptedMaterial: "enc" },
});
mocks.decrypt.mockResolvedValue({ authCacheJson: AUTH_CACHE });
- mocks.claim.mockResolvedValue(undefined);
+ mocks.claim.mockResolvedValue({ held: true });
mocks.release.mockResolvedValue(undefined);
mocks.ensureHostReady.mockResolvedValue(undefined);
mocks.createTurn.mockResolvedValue(undefined);
@@ -174,7 +171,9 @@ describe("gen2 Codex agent", () => {
await expect(startGen2AgentTurn(turn)).resolves.toEqual({
sessionId: "session-1",
});
- expect(mocks.claim).toHaveBeenCalledWith(credentialId);
+ expect(mocks.claim).toHaveBeenCalledWith(
+ expect.objectContaining({ credentialId, surface: "gen2" }),
+ );
expect(mocks.start).toHaveBeenCalledWith(
workspaceId,
expect.objectContaining({
@@ -240,19 +239,16 @@ describe("gen2 Codex agent", () => {
expect(mocks.start).toHaveBeenCalled();
});
- it("reattaches when the hosted Codex seat is already claimed", async () => {
- mocks.claim.mockRejectedValue(
- new HostedCodexSubscriptionError("busy", 409, "hosted_codex_busy"),
+ it("refuses a turn whose seat another run holds", async () => {
+ // This used to start the turn anyway — two turns on one subscription —
+ // while still stamping the credential unavailable for sixteen minutes,
+ // which did block the member's chat-room replies.
+ mocks.claim.mockResolvedValue({ held: false, holder: null });
+ await expect(startGen2AgentTurn(turn)).rejects.toThrow(
+ /still using this connection/,
);
- await expect(startGen2AgentTurn(turn)).resolves.toEqual({
- sessionId: "session-1",
- });
- expect(mocks.start).toHaveBeenCalled();
- expect(mocks.appendMessage).toHaveBeenCalledWith({
- chatId,
- role: "user",
- body: "List the files",
- });
+ expect(mocks.start).not.toHaveBeenCalled();
+ expect(mocks.appendMessage).not.toHaveBeenCalled();
expect(mocks.release).not.toHaveBeenCalled();
});
@@ -261,14 +257,14 @@ describe("gen2 Codex agent", () => {
await expect(startGen2AgentTurn(turn)).rejects.toBeInstanceOf(
Gen2LifecycleError,
);
- expect(mocks.release).toHaveBeenCalledWith(credentialId);
+ expect(mocks.release).toHaveBeenCalledWith(
+ expect.objectContaining({ credentialId }),
+ );
expect(mocks.appendMessage).not.toHaveBeenCalled();
});
- it("does not release someone else's busy seat when start fails", async () => {
- mocks.claim.mockRejectedValue(
- new HostedCodexSubscriptionError("busy", 409, "hosted_codex_busy"),
- );
+ it("does not release a seat it never took", async () => {
+ mocks.claim.mockResolvedValue({ held: false, holder: null });
mocks.start.mockRejectedValue(new OrchestratorError("guest down", 500));
await expect(startGen2AgentTurn(turn)).rejects.toBeInstanceOf(
Gen2LifecycleError,
@@ -305,7 +301,9 @@ describe("gen2 Codex agent", () => {
});
expect(result).not.toHaveProperty("codexAuthCacheJson");
expect(mocks.updateCache).toHaveBeenCalledWith(credentialId, AUTH_CACHE);
- expect(mocks.release).toHaveBeenCalledWith(credentialId);
+ expect(mocks.release).toHaveBeenCalledWith(
+ expect.objectContaining({ credentialId }),
+ );
expect(mocks.appendMessage).not.toHaveBeenCalled();
});
@@ -368,7 +366,9 @@ describe("gen2 Codex agent", () => {
after: 0,
}),
).rejects.toThrow(/no longer running/);
- expect(mocks.release).toHaveBeenCalledWith(credentialId);
+ expect(mocks.release).toHaveBeenCalledWith(
+ expect.objectContaining({ credentialId }),
+ );
});
it("closes the exec and releases the seat on cancel", async () => {
@@ -378,6 +378,8 @@ describe("gen2 Codex agent", () => {
sessionId: "session-1",
});
expect(mocks.close).toHaveBeenCalledWith(workspaceId, "session-1");
- expect(mocks.release).toHaveBeenCalledWith(credentialId);
+ expect(mocks.release).toHaveBeenCalledWith(
+ expect.objectContaining({ credentialId }),
+ );
});
});
diff --git a/apps/web/lib/gen2/agent.ts b/apps/web/lib/gen2/agent.ts
index 71496d716..73cef5eee 100644
--- a/apps/web/lib/gen2/agent.ts
+++ b/apps/web/lib/gen2/agent.ts
@@ -2,14 +2,17 @@ import "server-only";
import { logEvent } from "../platform/observability";
import {
- claimHostedCodexExecution,
HostedCodexSubscriptionError,
- releaseHostedCodexExecution,
resolveHostedCodexSubscription,
updateHostedCodexAuthCache,
} from "../providers/hosted-codex-subscription-credentials";
+import {
+ describeSeatHolder,
+ releaseCredentialSeat,
+ retagCredentialSeat,
+ waitForCredentialSeat,
+} from "../providers/credential-seat";
import { resolveGen2Codex } from "./providers";
-import { getAgentModel } from "../providers/ai-model";
import { OrchestratorError } from "../runtime/orchestrator-request";
import { ensureHostReady } from "../runtime/orchestrator-health";
import {
@@ -25,41 +28,18 @@ import {
listGen2ChatMessages,
requireGen2Chat,
} from "./chats";
-import { formatGen2TurnPrompt } from "./chats-format";
+import { buildGen2CodexCommand } from "./codex-command";
import { createGen2Turn, recordGen2TurnChunks } from "./turns";
+import { isGen2SupersetAgentSessionsEnabled } from "./superset-agent-sessions-feature";
+import {
+ cancelGen2SupersetAgentTurn,
+ pollGen2SupersetAgentTurn,
+ startGen2SupersetAgentTurn,
+} from "./superset-agent-runtime";
import { requireGen2Member } from "./workspaces";
export { canRunGen2Agent } from "./agent-policy";
-
-export function buildGen2CodexCommand(
- prompt: string,
- history: Array<{ role: "user" | "assistant"; body: string }> = [],
-) {
- return [
- "codex",
- "exec",
- "--json",
- "--ephemeral",
- "--ignore-user-config",
- "--skip-git-repo-check",
- "--sandbox",
- "danger-full-access",
- "-c",
- 'approval_policy="never"',
- "--model",
- getAgentModel("openai"),
- "--cd",
- ".",
- [
- "You are Codex on this workspace's Firecracker machine.",
- "The working directory is /workspace. Use the shell to inspect and change files there.",
- "Answer the user. If they ask for code changes, make them in the current directory.",
- "Do not inspect CODEX_HOME or authentication files.",
- "",
- formatGen2TurnPrompt(prompt, history),
- ].join("\n"),
- ];
-}
+export { buildGen2CodexCommand } from "./codex-command";
async function requireReadyMember(workspaceId: string, userId: string) {
const membership = await requireGen2Member(workspaceId, userId);
@@ -82,23 +62,32 @@ export async function startGen2AgentTurn(input: {
}) {
await requireReadyMember(input.workspaceId, input.userId);
await requireGen2Chat(input.workspaceId, input.chatId);
+
+ if (isGen2SupersetAgentSessionsEnabled()) {
+ return startGen2AgentTurnViaSuperset(input);
+ }
+
const history = await listGen2ChatMessages(input.chatId);
const credential = await resolveGen2Codex(input.userId);
// Only a subscription holds a seat. An API key has no one-turn-at-a-time
// limit, so claiming one would invent a restriction the provider does not.
- let claimed = false;
+ //
+ // This used to claim the seat and then swallow a busy result, running the
+ // turn anyway — while stamping the credential unavailable for sixteen
+ // minutes, which did block the member's chat-room replies. Now it waits for
+ // the seat like every other executor, and says what holds it if it cannot
+ // get one.
+ const seatRef = input.idempotencyKey;
if (credential.credentialId) {
- try {
- await claimHostedCodexExecution(credential.credentialId);
- claimed = true;
- } catch (error) {
- if (
- !(error instanceof HostedCodexSubscriptionError) ||
- error.code !== "hosted_codex_busy"
- ) {
- throw error;
- }
+ const claim = await waitForCredentialSeat({
+ credentialId: credential.credentialId,
+ userId: input.userId,
+ surface: "gen2",
+ ref: seatRef,
+ });
+ if (!claim.held) {
+ throw new Gen2LifecycleError(describeSeatHolder(claim.holder), 409);
}
}
const execInput = {
@@ -140,10 +129,22 @@ export async function startGen2AgentTurn(input: {
chatId: input.chatId,
userId: input.userId,
});
+ if (credential.credentialId) {
+ // The poll and cleanup paths know the session id and nothing else, so
+ // the seat moves onto it now that there is one.
+ await retagCredentialSeat({
+ credentialId: credential.credentialId,
+ fromRef: seatRef,
+ toRef: sessionId,
+ });
+ }
return { sessionId };
} catch (error) {
- if (claimed && credential.credentialId) {
- await releaseHostedCodexExecution(credential.credentialId);
+ if (credential.credentialId) {
+ await releaseCredentialSeat({
+ credentialId: credential.credentialId,
+ ref: seatRef,
+ });
}
logEvent("error", "gen2.agent.start_failed", {
detail: error instanceof Error ? error.message : "unknown",
@@ -164,6 +165,41 @@ export async function startGen2AgentTurn(input: {
}
}
+/**
+ * Phase 4's Superset flow: same failure translation as the direct sandbox
+ * path above, delegated to `startGen2SupersetAgentTurn` (which owns the
+ * credential claim, worktree selection, durable run row, and chat/turn
+ * persistence -- see superset-agent-runtime.ts).
+ */
+async function startGen2AgentTurnViaSuperset(input: {
+ workspaceId: string;
+ userId: string;
+ chatId: string;
+ prompt: string;
+ idempotencyKey: string;
+}) {
+ try {
+ return await startGen2SupersetAgentTurn(input);
+ } catch (error) {
+ logEvent("error", "gen2.agent.start_failed", {
+ detail: error instanceof Error ? error.message : "unknown",
+ });
+ if (error instanceof OrchestratorError && error.status === 404) {
+ throw new Gen2LifecycleError(
+ "The instance is not running. Start it and try again.",
+ );
+ }
+ if (
+ error instanceof Gen2AccessError ||
+ error instanceof Gen2LifecycleError ||
+ error instanceof HostedCodexSubscriptionError
+ ) {
+ throw error;
+ }
+ throw new Gen2LifecycleError(describeGen2RuntimeFailure(error), 502);
+ }
+}
+
export async function pollGen2AgentTurn(input: {
workspaceId: string;
userId: string;
@@ -172,6 +208,11 @@ export async function pollGen2AgentTurn(input: {
after: number;
}) {
await requireGen2Member(input.workspaceId, input.userId);
+
+ if (isGen2SupersetAgentSessionsEnabled()) {
+ return pollGen2AgentTurnViaSuperset(input);
+ }
+
let result;
try {
result = await pollCodexExecInSandbox(
@@ -184,7 +225,7 @@ export async function pollGen2AgentTurn(input: {
detail: error instanceof Error ? error.message : "unknown",
});
if (error instanceof OrchestratorError && error.status === 404) {
- await releasePersonalCodex(input.userId);
+ await releasePersonalCodex(input.userId, input.sessionId);
throw new Gen2LifecycleError(
"This Codex turn is no longer running. Send the prompt again.",
);
@@ -201,7 +242,6 @@ export async function pollGen2AgentTurn(input: {
if (result.exited) {
const hosted = await resolveHostedCodexSubscription({
userId: input.userId,
- includeBusy: true,
});
if (hosted?.credential.id) {
try {
@@ -212,7 +252,10 @@ export async function pollGen2AgentTurn(input: {
);
}
} finally {
- await releaseHostedCodexExecution(hosted.credential.id);
+ await releaseCredentialSeat({
+ credentialId: hosted.credential.id,
+ ref: input.sessionId,
+ });
}
}
}
@@ -229,12 +272,54 @@ export async function pollGen2AgentTurn(input: {
};
}
+/**
+ * Phase 4's Superset flow for polling. `pollGen2SupersetAgentTurn` owns the
+ * durable run lookup, output recording, and lease release on exit -- see
+ * superset-agent-runtime.ts.
+ */
+async function pollGen2AgentTurnViaSuperset(input: {
+ workspaceId: string;
+ userId: string;
+ sessionId: string;
+ after: number;
+}) {
+ try {
+ return await pollGen2SupersetAgentTurn(input);
+ } catch (error) {
+ logEvent("error", "gen2.agent.poll_failed", {
+ detail: error instanceof Error ? error.message : "unknown",
+ });
+ if (error instanceof Gen2LifecycleError) {
+ throw error;
+ }
+ if (error instanceof OrchestratorError && error.status === 404) {
+ throw new Gen2LifecycleError(
+ "This Codex turn is no longer running. Send the prompt again.",
+ );
+ }
+ throw new Gen2LifecycleError(describeGen2RuntimeFailure(error), 502);
+ }
+}
+
export async function cancelGen2AgentTurn(input: {
workspaceId: string;
userId: string;
sessionId: string;
}) {
await requireGen2Member(input.workspaceId, input.userId);
+
+ if (isGen2SupersetAgentSessionsEnabled()) {
+ try {
+ await cancelGen2SupersetAgentTurn(input);
+ } catch (error) {
+ if (error instanceof Gen2LifecycleError) {
+ throw error;
+ }
+ throw new Gen2LifecycleError(describeGen2RuntimeFailure(error), 502);
+ }
+ return;
+ }
+
try {
await closeCodexExecInSandbox(input.workspaceId, input.sessionId);
} catch (error) {
@@ -242,16 +327,18 @@ export async function cancelGen2AgentTurn(input: {
throw new Gen2LifecycleError(describeGen2RuntimeFailure(error), 502);
}
} finally {
- await releasePersonalCodex(input.userId);
+ await releasePersonalCodex(input.userId, input.sessionId);
}
}
-async function releasePersonalCodex(userId: string) {
+async function releasePersonalCodex(userId: string, sessionId: string) {
const hosted = await resolveHostedCodexSubscription({
userId,
- includeBusy: true,
});
if (hosted?.credential.id) {
- await releaseHostedCodexExecution(hosted.credential.id);
+ await releaseCredentialSeat({
+ credentialId: hosted.credential.id,
+ ref: sessionId,
+ });
}
}
diff --git a/apps/web/lib/gen2/codex-command.ts b/apps/web/lib/gen2/codex-command.ts
new file mode 100644
index 000000000..8b3cb5584
--- /dev/null
+++ b/apps/web/lib/gen2/codex-command.ts
@@ -0,0 +1,40 @@
+import "server-only";
+
+import { getAgentModel } from "../providers/ai-model";
+import { formatGen2TurnPrompt } from "./chats-format";
+
+/**
+ * Shared by the direct `codex exec` sandbox path (`agent.ts`) and the
+ * Superset terminal-agent path (`superset-agent-runtime.ts`): both deliver
+ * the same Codex invocation, just through a different launch mechanism. Split
+ * out so neither module has to import the other for it.
+ */
+export function buildGen2CodexCommand(
+ prompt: string,
+ history: Array<{ role: "user" | "assistant"; body: string }> = [],
+) {
+ return [
+ "codex",
+ "exec",
+ "--json",
+ "--ephemeral",
+ "--ignore-user-config",
+ "--skip-git-repo-check",
+ "--sandbox",
+ "danger-full-access",
+ "-c",
+ 'approval_policy="never"',
+ "--model",
+ getAgentModel("openai"),
+ "--cd",
+ ".",
+ [
+ "You are Codex on this workspace's Firecracker machine.",
+ "The working directory is /workspace. Use the shell to inspect and change files there.",
+ "Answer the user. If they ask for code changes, make them in the current directory.",
+ "Do not inspect CODEX_HOME or authentication files.",
+ "",
+ formatGen2TurnPrompt(prompt, history),
+ ].join("\n"),
+ ];
+}
diff --git a/apps/web/lib/gen2/codex-output.ts b/apps/web/lib/gen2/codex-output.ts
index 10a84587e..56fc0aa14 100644
--- a/apps/web/lib/gen2/codex-output.ts
+++ b/apps/web/lib/gen2/codex-output.ts
@@ -161,3 +161,32 @@ export function encodePendingBytes(pending: Uint8Array): string {
export function decodePendingBytes(value: string): Uint8Array {
return value ? decodeBase64(value) : new Uint8Array(0);
}
+
+function encodeBase64(text: string): string {
+ const bytes = new TextEncoder().encode(text);
+ if (typeof Buffer !== "undefined") {
+ return Buffer.from(bytes).toString("base64");
+ }
+ let binary = "";
+ for (const byte of bytes) binary += String.fromCharCode(byte);
+ return btoa(binary);
+}
+
+/**
+ * Adapts a Superset terminal-agent poll's plain-text, full-snapshot chunks
+ * (see `superset-agent-orchestrator-client.ts`) into the `CodexExecChunk[]`
+ * shape the browser's `chat-panel.tsx` already merges by `sequence` and
+ * decodes for a live in-progress reply. Always emitting `sequence: 0` -- one
+ * chunk representing "the current full snapshot" -- makes `mergeCodexExecChunks`
+ * overwrite that one entry each poll instead of concatenating an
+ * ever-growing series of duplicate snapshots.
+ */
+export function toCodexExecChunks(
+ chunks: { sequence: number; data: string }[],
+): CodexExecChunk[] {
+ if (chunks.length === 0) return [];
+ const latest = chunks.reduce((max, chunk) =>
+ chunk.sequence > max.sequence ? chunk : max,
+ );
+ return [{ sequence: 0, dataBase64: encodeBase64(latest.data) }];
+}
diff --git a/apps/web/lib/gen2/providers.test.ts b/apps/web/lib/gen2/providers.test.ts
index 9d6e7ba93..924ca1418 100644
--- a/apps/web/lib/gen2/providers.test.ts
+++ b/apps/web/lib/gen2/providers.test.ts
@@ -82,10 +82,10 @@ describe("gen2 provider resolution", () => {
await expect(resolveGen2Codex(userId)).resolves.toMatchObject({
via: "subscription",
});
- expect(mocks.resolveHosted).toHaveBeenCalledWith({
- userId,
- includeBusy: true,
- });
+ // Resolution answers "is one connected", never "is one free": busy is a
+ // seat question, and reporting a mid-turn subscription as missing used to
+ // send members off to reconnect a perfectly good credential.
+ expect(mocks.resolveHosted).toHaveBeenCalledWith({ userId });
});
it("reports status without ever returning a secret", async () => {
diff --git a/apps/web/lib/gen2/providers.ts b/apps/web/lib/gen2/providers.ts
index 3e0006cd4..b63382c91 100644
--- a/apps/web/lib/gen2/providers.ts
+++ b/apps/web/lib/gen2/providers.ts
@@ -1,15 +1,12 @@
import "server-only";
-import { and, eq } from "drizzle-orm";
-
-import { schema } from "@codev/db";
-
-import { getDatabase } from "../platform/database";
-import { decryptSecret } from "../platform/kms";
import {
- decryptHostedMaterial,
- resolveHostedCodexSubscription,
-} from "../providers/hosted-codex-subscription-credentials";
+ CredentialUnavailableError,
+ requireCredential,
+ resolveCredential,
+} from "../providers/resolve";
+import { codexApiKeyAuthCache, launchProfileFor } from "../providers/registry";
+import type { ProviderId } from "../providers/registry";
import { Gen2LifecycleError } from "./errors";
/**
@@ -18,12 +15,14 @@ import { Gen2LifecycleError } from "./errors";
* Gen 2 resolves the *initiating member's own* credential and never a
* workspace-shared one. That is the point of a shared machine: the work lands
* in a place everyone can see, but it is billed to, and authorised by, the
- * person who asked for it.
+ * person who asked for it. Passing no workspace id is what enforces it —
+ * `resolveCredential` only reaches a shared row when given one.
*
- * Both shapes end up as a Codex `auth.json`, so the transport to the guest is
- * identical -- encrypted in flight, written to a private 0700 directory, never
- * passed on the command line where another member's shell could read it out of
- * `ps`.
+ * The lookup itself is no longer written here. It used to be: a bespoke
+ * subscription-then-API-key walk that consulted none of the flags the
+ * settings page rendered, so a credential the member had disabled still ran.
+ * It now asks the one resolver, on the `gen2` executor, and the registry
+ * decides what that executor can run.
*/
export type Gen2Credential = {
/** Set only for a subscription, which holds a one-turn-at-a-time lease. */
@@ -36,76 +35,64 @@ export const GEN2_CONNECT_MESSAGE =
"Connect ChatGPT or add an OpenAI API key to run Codex here.";
/** The `auth.json` shape the Codex CLI uses for plain API-key auth. */
-export function buildApiKeyAuthCache(apiKey: string) {
- return JSON.stringify({
- auth_mode: "apikey",
- OPENAI_API_KEY: apiKey,
- tokens: null,
- last_refresh: new Date().toISOString(),
- });
-}
+export const buildApiKeyAuthCache = codexApiKeyAuthCache;
-async function findPersonalOpenAiApiKey(userId: string) {
- const [row] = await getDatabase()
- .select({
- encryptedApiKey: schema.providerCredentials.encryptedApiKey,
- })
- .from(schema.providerCredentials)
- .where(
- and(
- eq(schema.providerCredentials.scopeType, "USER"),
- eq(schema.providerCredentials.scopeId, userId),
- eq(schema.providerCredentials.provider, "openai"),
- eq(schema.providerCredentials.credentialType, "API_KEY"),
- eq(schema.providerCredentials.isConnected, true),
- ),
- )
- .limit(1);
- if (!row?.encryptedApiKey) return null;
- try {
- return await decryptSecret(row.encryptedApiKey);
- } catch {
- return null;
- }
-}
+/** Gen 2 runs Codex today. The guest exec route carries a Codex auth cache by
+ * name and has no channel for an environment variable, so Claude's
+ * setup-token cannot reach it yet — see `LaunchProfile` in the registry. */
+const GEN2_PROVIDER: ProviderId = "codex";
/**
- * Subscription first, then a personal API key.
- *
- * `includeBusy` is deliberate: a subscription that is mid-turn should report
- * "already running a turn" from the lease, not silently fall through to a
- * different credential and bill the member twice over.
+ * The guest still takes `codexAuthCacheJson` as a named field, so the neutral
+ * launch profile is unwrapped back into it here. When the guest accepts a
+ * profile (files + env) this shim is what goes away, not the resolver.
*/
+function authCacheFromProfile(
+ provider: ProviderId,
+ secret: Parameters[1],
+): string | null {
+ const profile = launchProfileFor(provider, secret);
+ return (
+ profile.files?.find((file) => file.path === ".codex/auth.json")?.contents ??
+ null
+ );
+}
+
export async function resolveGen2Codex(
userId: string,
): Promise {
- const hosted = await resolveHostedCodexSubscription({
- userId,
- includeBusy: true,
- });
- if (hosted?.credential.encryptedMaterial) {
- const material = await decryptHostedMaterial(
- hosted.credential.encryptedMaterial,
- );
- if (material.authCacheJson) {
- return {
- credentialId: hosted.credential.id,
- authCacheJson: material.authCacheJson,
- via: "subscription",
- };
+ let resolved;
+ try {
+ resolved = await requireCredential({
+ userId,
+ provider: GEN2_PROVIDER,
+ surface: "gen2",
+ });
+ } catch (error) {
+ if (error instanceof CredentialUnavailableError) {
+ throw new Gen2LifecycleError(
+ error.reason === "not_connected" ? GEN2_CONNECT_MESSAGE : error.message,
+ 409,
+ );
}
+ throw error;
}
- const apiKey = await findPersonalOpenAiApiKey(userId);
- if (apiKey) {
- return {
- credentialId: null,
- authCacheJson: buildApiKeyAuthCache(apiKey),
- via: "api-key",
- };
+ const authCacheJson = authCacheFromProfile(GEN2_PROVIDER, resolved.secret);
+ if (!authCacheJson) {
+ throw new Gen2LifecycleError(
+ "Reconnect Codex; the stored connection uses an obsolete format.",
+ 409,
+ );
}
-
- throw new Gen2LifecycleError(GEN2_CONNECT_MESSAGE, 409);
+ return {
+ // Only a subscription holds a seat; an API key has no one-turn-at-a-time
+ // limit, so it carries no lease for the caller to claim.
+ credentialId:
+ resolved.kind === "codex_auth_cache" ? resolved.credentialId : null,
+ authCacheJson,
+ via: resolved.kind === "codex_auth_cache" ? "subscription" : "api-key",
+ };
}
export type Gen2ProviderStatus = {
@@ -117,15 +104,15 @@ export type Gen2ProviderStatus = {
export async function getGen2ProviderStatus(
userId: string,
): Promise {
- const hosted = await resolveHostedCodexSubscription({
+ const result = await resolveCredential({
userId,
- includeBusy: true,
+ provider: GEN2_PROVIDER,
+ surface: "gen2",
+ dryRun: true,
});
- if (hosted?.credential.encryptedMaterial) {
- return { connected: true, via: "subscription" };
- }
- if (await findPersonalOpenAiApiKey(userId)) {
- return { connected: true, via: "api-key" };
- }
- return { connected: false, via: null };
+ if (!result.ok) return { connected: false, via: null };
+ return {
+ connected: true,
+ via: result.kind === "codex_auth_cache" ? "subscription" : "api-key",
+ };
}
diff --git a/apps/web/lib/gen2/superset-agent-orchestrator-client.test.ts b/apps/web/lib/gen2/superset-agent-orchestrator-client.test.ts
new file mode 100644
index 000000000..35484a8e9
--- /dev/null
+++ b/apps/web/lib/gen2/superset-agent-orchestrator-client.test.ts
@@ -0,0 +1,104 @@
+import { beforeEach, describe, expect, it, vi } from "vitest";
+
+const mocks = vi.hoisted(() => ({ codexExecRequest: vi.fn() }));
+
+vi.mock("../runtime/orchestrator-request", () => ({
+ codexExecRequest: (...args: unknown[]) => mocks.codexExecRequest(...args),
+}));
+
+import {
+ checkSupersetAgentRecovery,
+ pollSupersetAgent,
+ sendSupersetAgentInput,
+ startSupersetAgent,
+ stopSupersetAgent,
+} from "./superset-agent-orchestrator-client";
+
+function jsonResponse(body: unknown) {
+ return { json: () => Promise.resolve(body) };
+}
+
+const workspaceId = "workspace-1";
+const agentId = "agent-1";
+
+describe("Superset agent orchestrator client", () => {
+ beforeEach(() => {
+ mocks.codexExecRequest.mockReset();
+ });
+
+ it("posts a start request to the sandbox-scoped path", async () => {
+ mocks.codexExecRequest.mockResolvedValue(
+ jsonResponse({
+ hostWorkspaceId: "host-ws-1",
+ hostTerminalId: "term-1",
+ hostAgentSessionId: "agent-1",
+ }),
+ );
+ const result = await startSupersetAgent(workspaceId, {
+ worktreeId: "main",
+ provider: "openai",
+ command: ["codex", "exec"],
+ idempotencyKey: "key-1",
+ });
+ expect(mocks.codexExecRequest).toHaveBeenCalledWith(
+ "POST",
+ `/v1/sandboxes/${workspaceId}/superset-agents`,
+ expect.objectContaining({ worktreeId: "main" }),
+ expect.any(Number),
+ );
+ expect(result.hostAgentSessionId).toBe("agent-1");
+ });
+
+ it("sends input to the agent-scoped input path", async () => {
+ mocks.codexExecRequest.mockResolvedValue(jsonResponse({}));
+ await sendSupersetAgentInput(workspaceId, agentId, "y\n");
+ expect(mocks.codexExecRequest).toHaveBeenCalledWith(
+ "POST",
+ `/v1/sandboxes/${workspaceId}/superset-agents/${agentId}/input`,
+ { data: "y\n" },
+ expect.any(Number),
+ );
+ });
+
+ it("polls with the after cursor", async () => {
+ mocks.codexExecRequest.mockResolvedValue(
+ jsonResponse({
+ chunks: [],
+ nextSequence: 3,
+ exited: false,
+ exitCode: null,
+ refreshReady: false,
+ }),
+ );
+ await pollSupersetAgent(workspaceId, agentId, 3);
+ expect(mocks.codexExecRequest).toHaveBeenCalledWith(
+ "POST",
+ `/v1/sandboxes/${workspaceId}/superset-agents/${agentId}/poll`,
+ expect.objectContaining({ after: 3 }),
+ expect.any(Number),
+ );
+ });
+
+ it("stops with DELETE", async () => {
+ mocks.codexExecRequest.mockResolvedValue(jsonResponse({}));
+ await stopSupersetAgent(workspaceId, agentId);
+ expect(mocks.codexExecRequest).toHaveBeenCalledWith(
+ "DELETE",
+ `/v1/sandboxes/${workspaceId}/superset-agents/${agentId}`,
+ undefined,
+ expect.any(Number),
+ );
+ });
+
+ it("checks recovery with GET", async () => {
+ mocks.codexExecRequest.mockResolvedValue(jsonResponse({ adoptable: true }));
+ const result = await checkSupersetAgentRecovery(workspaceId, agentId);
+ expect(mocks.codexExecRequest).toHaveBeenCalledWith(
+ "GET",
+ `/v1/sandboxes/${workspaceId}/superset-agents/${agentId}/recovery`,
+ undefined,
+ expect.any(Number),
+ );
+ expect(result).toEqual({ adoptable: true });
+ });
+});
diff --git a/apps/web/lib/gen2/superset-agent-orchestrator-client.ts b/apps/web/lib/gen2/superset-agent-orchestrator-client.ts
new file mode 100644
index 000000000..64ac37626
--- /dev/null
+++ b/apps/web/lib/gen2/superset-agent-orchestrator-client.ts
@@ -0,0 +1,123 @@
+import "server-only";
+
+import { z } from "zod";
+
+import { codexExecRequest } from "../runtime/orchestrator-request";
+
+/**
+ * Thin HTTP client for the Superset agent-launch routes
+ * docs/SUPERSET_AGENT_SESSION_PLAN.md Phase 3 adds to the orchestrator
+ * (which forwards to `codev-guestd`, which calls Superset's host-service
+ * private bridge). Named to match the existing `/v1/sandboxes/{id}/
+ * codex-execs` convention in `orchestrator-codex-exec.ts`.
+ *
+ * The orchestrator (`services/orchestrator/src/guest.rs`) and
+ * `vendor/superset/.../codev/agents.ts` routes this calls now exist
+ * (Phase 3), but neither has run against a real bun toolchain or a live
+ * Firecracker guest -- treat the wire shapes below as unverified until a
+ * real end-to-end run exercises them.
+ */
+
+const supersetAgentStartResponseSchema = z.object({
+ hostWorkspaceId: z.string(),
+ hostTerminalId: z.string(),
+ hostAgentSessionId: z.string(),
+});
+
+const supersetAgentPollResponseSchema = z.object({
+ chunks: z.array(
+ z.object({
+ sequence: z.number().int().nonnegative(),
+ // Plain text, not base64: matches the terminal-snapshot convention
+ // `orchestrator-superset-runtime.ts`'s `terminalPollSchema` already
+ // uses for this same host-service poll shape, and what
+ // `vendor/superset/.../codev/agents.ts` actually returns. Each chunk is
+ // a full buffer snapshot (prefixed with a clear-screen escape), not an
+ // incremental append -- see `recordGen2SupersetRunOutput` in turns.ts.
+ data: z.string(),
+ }),
+ ),
+ nextSequence: z.number().int().nonnegative(),
+ exited: z.boolean(),
+ exitCode: z.number().int().nullable(),
+ /** Set once the launched process has exited and a refresh capture is safe. */
+ refreshReady: z.boolean(),
+});
+
+const supersetAgentRecoveryResponseSchema = z.object({
+ adoptable: z.boolean(),
+});
+
+export type SupersetAgentPollChunk = z.infer<
+ typeof supersetAgentPollResponseSchema
+>["chunks"][number];
+
+export type SupersetAgentStartInput = {
+ worktreeId: string;
+ provider: string;
+ codexAuthCacheJson?: string;
+ command: string[];
+ idempotencyKey: string;
+};
+
+export async function startSupersetAgent(
+ workspaceId: string,
+ input: SupersetAgentStartInput,
+) {
+ const response = await codexExecRequest(
+ "POST",
+ `/v1/sandboxes/${workspaceId}/superset-agents`,
+ input,
+ 20_000,
+ );
+ return supersetAgentStartResponseSchema.parse(await response.json());
+}
+
+export async function sendSupersetAgentInput(
+ workspaceId: string,
+ agentId: string,
+ data: string,
+) {
+ await codexExecRequest(
+ "POST",
+ `/v1/sandboxes/${workspaceId}/superset-agents/${agentId}/input`,
+ { data },
+ 20_000,
+ );
+}
+
+export async function pollSupersetAgent(
+ workspaceId: string,
+ agentId: string,
+ after: number,
+) {
+ const response = await codexExecRequest(
+ "POST",
+ `/v1/sandboxes/${workspaceId}/superset-agents/${agentId}/poll`,
+ { after, waitMilliseconds: 25_000 },
+ 35_000,
+ );
+ return supersetAgentPollResponseSchema.parse(await response.json());
+}
+
+export async function stopSupersetAgent(workspaceId: string, agentId: string) {
+ await codexExecRequest(
+ "DELETE",
+ `/v1/sandboxes/${workspaceId}/superset-agents/${agentId}`,
+ undefined,
+ 20_000,
+ );
+}
+
+export async function checkSupersetAgentRecovery(
+ workspaceId: string,
+ agentId: string,
+) {
+ const response = await codexExecRequest(
+ "GET",
+ `/v1/sandboxes/${workspaceId}/superset-agents/${agentId}/recovery`,
+ undefined,
+ 20_000,
+ );
+ return supersetAgentRecoveryResponseSchema.parse(await response.json());
+}
diff --git a/apps/web/lib/gen2/superset-agent-runtime.test.ts b/apps/web/lib/gen2/superset-agent-runtime.test.ts
new file mode 100644
index 000000000..da83f796c
--- /dev/null
+++ b/apps/web/lib/gen2/superset-agent-runtime.test.ts
@@ -0,0 +1,488 @@
+import { beforeEach, describe, expect, it, vi } from "vitest";
+
+const mocks = vi.hoisted(() => ({
+ requireMember: vi.fn(),
+ resolveCredential: vi.fn(),
+ claim: vi.fn(),
+ release: vi.fn(),
+ register: vi.fn(),
+ claimLease: vi.fn(),
+ releaseLease: vi.fn(),
+ markStarted: vi.fn(),
+ markFinished: vi.fn(),
+ markFailed: vi.fn(),
+ markStopping: vi.fn(),
+ markRecoveryRequired: vi.fn(),
+ getRunById: vi.fn(),
+ start: vi.fn(),
+ poll: vi.fn(),
+ stop: vi.fn(),
+ sendInput: vi.fn(),
+ checkRecovery: vi.fn(),
+ requireChat: vi.fn(),
+ listMessages: vi.fn(),
+ appendMessage: vi.fn(),
+ listWorktrees: vi.fn(),
+ createWorktree: vi.fn(),
+ createTurn: vi.fn(),
+ recordOutput: vi.fn(),
+}));
+
+vi.mock("./workspaces", () => ({
+ requireGen2Member: (...args: unknown[]) => mocks.requireMember(...args),
+}));
+
+vi.mock("../providers/credential-seat", () => ({
+ waitForCredentialSeat: (...args: unknown[]) => mocks.claim(...args),
+ releaseCredentialSeat: (...args: unknown[]) => mocks.release(...args),
+ retagCredentialSeat: vi.fn(async () => undefined),
+ heartbeatCredentialSeat: vi.fn(async () => undefined),
+ describeSeatHolder: () => "a workspace turn is still using this connection.",
+}));
+vi.mock("./providers", () => ({
+ resolveGen2Codex: (...args: unknown[]) => mocks.resolveCredential(...args),
+}));
+
+vi.mock("./chats", () => ({
+ requireGen2Chat: (...args: unknown[]) => mocks.requireChat(...args),
+ listGen2ChatMessages: (...args: unknown[]) => mocks.listMessages(...args),
+ appendGen2ChatMessage: (...args: unknown[]) => mocks.appendMessage(...args),
+}));
+
+vi.mock("../runtime/orchestrator-superset-runtime", () => ({
+ listSupersetWorktrees: (...args: unknown[]) => mocks.listWorktrees(...args),
+ createSupersetWorktree: (...args: unknown[]) => mocks.createWorktree(...args),
+}));
+
+vi.mock("./turns", () => ({
+ createGen2Turn: (...args: unknown[]) => mocks.createTurn(...args),
+ recordGen2SupersetRunOutput: (...args: unknown[]) =>
+ mocks.recordOutput(...args),
+}));
+
+vi.mock("./superset-runs", () => ({
+ registerGen2SupersetRun: (...args: unknown[]) => mocks.register(...args),
+ claimGen2SupersetRunLease: (...args: unknown[]) => mocks.claimLease(...args),
+ releaseGen2SupersetRunLease: (...args: unknown[]) =>
+ mocks.releaseLease(...args),
+ markGen2SupersetRunStarted: (...args: unknown[]) =>
+ mocks.markStarted(...args),
+ markGen2SupersetRunFinished: (...args: unknown[]) =>
+ mocks.markFinished(...args),
+ markGen2SupersetRunFailed: (...args: unknown[]) => mocks.markFailed(...args),
+ markGen2SupersetRunStopping: (...args: unknown[]) =>
+ mocks.markStopping(...args),
+ markGen2SupersetRunRecoveryRequired: (...args: unknown[]) =>
+ mocks.markRecoveryRequired(...args),
+ getGen2SupersetRunById: (...args: unknown[]) => mocks.getRunById(...args),
+}));
+
+vi.mock("./superset-agent-orchestrator-client", () => ({
+ startSupersetAgent: (...args: unknown[]) => mocks.start(...args),
+ pollSupersetAgent: (...args: unknown[]) => mocks.poll(...args),
+ stopSupersetAgent: (...args: unknown[]) => mocks.stop(...args),
+ sendSupersetAgentInput: (...args: unknown[]) => mocks.sendInput(...args),
+ checkSupersetAgentRecovery: (...args: unknown[]) =>
+ mocks.checkRecovery(...args),
+}));
+
+import { Gen2LifecycleError } from "./errors";
+import {
+ cancelGen2SupersetAgentSession,
+ cancelGen2SupersetAgentTurn,
+ pollGen2SupersetAgentSession,
+ pollGen2SupersetAgentTurn,
+ reconcileGen2SupersetAgentSession,
+ startGen2SupersetAgentSession,
+ startGen2SupersetAgentTurn,
+} from "./superset-agent-runtime";
+
+const workspaceId = "11111111-1111-4111-8111-111111111111";
+const userId = "22222222-2222-4222-8222-222222222222";
+const runId = "33333333-3333-4333-8333-333333333333";
+const credentialId = "44444444-4444-4444-8444-444444444444";
+const chatId = "55555555-5555-4555-8555-555555555555";
+
+const RUN = {
+ id: runId,
+ workspaceId,
+ hostAgentSessionId: "agent-1",
+ connectionId: credentialId,
+ leaseClaimed: true,
+};
+
+describe("gen2 Superset agent runtime adapter", () => {
+ beforeEach(() => {
+ vi.resetAllMocks();
+ process.env.CODEV_SUPERSET_AGENT_SESSIONS_ENABLED = "true";
+ mocks.requireMember.mockResolvedValue({ status: "ready" });
+ mocks.claim.mockResolvedValue({ held: true });
+ mocks.resolveCredential.mockResolvedValue({
+ credentialId,
+ authCacheJson: "{}",
+ via: "subscription",
+ });
+ mocks.requireChat.mockResolvedValue({ id: chatId });
+ mocks.listMessages.mockResolvedValue([]);
+ mocks.listWorktrees.mockResolvedValue([]);
+ mocks.createWorktree.mockResolvedValue({
+ worktreeId: "agent-chat",
+ branch: "codev/agent-chat",
+ });
+ });
+
+ it("refuses every call while the flag is off", async () => {
+ delete process.env.CODEV_SUPERSET_AGENT_SESSIONS_ENABLED;
+ await expect(
+ startGen2SupersetAgentSession({
+ workspaceId,
+ userId,
+ worktreeId: "main",
+ command: ["codex"],
+ idempotencyKey: "key-1",
+ }),
+ ).rejects.toThrow(Gen2LifecycleError);
+ expect(mocks.register).not.toHaveBeenCalled();
+ });
+
+ it("claims a lease, starts the run, and records host identifiers", async () => {
+ mocks.register.mockResolvedValue({
+ runId,
+ status: "creating",
+ created: true,
+ });
+ mocks.start.mockResolvedValue({
+ hostWorkspaceId: "host-ws-1",
+ hostTerminalId: "term-1",
+ hostAgentSessionId: "agent-1",
+ });
+
+ const result = await startGen2SupersetAgentSession({
+ workspaceId,
+ userId,
+ worktreeId: "main",
+ command: ["codex", "exec"],
+ idempotencyKey: "key-1",
+ });
+
+ expect(mocks.claim).toHaveBeenCalledWith(
+ expect.objectContaining({ credentialId, surface: "gen2" }),
+ );
+ expect(mocks.claimLease).toHaveBeenCalledWith(
+ expect.objectContaining({ runId }),
+ );
+ expect(mocks.markStarted).toHaveBeenCalledWith(
+ expect.objectContaining({ runId, hostAgentSessionId: "agent-1" }),
+ );
+ expect(result).toEqual({ runId, status: "running", created: true });
+ });
+
+ it("reattaches to an in-flight run instead of starting a second one", async () => {
+ mocks.register.mockResolvedValue({
+ runId,
+ status: "running",
+ created: false,
+ });
+
+ await startGen2SupersetAgentSession({
+ workspaceId,
+ userId,
+ worktreeId: "main",
+ command: ["codex"],
+ idempotencyKey: "key-1",
+ });
+
+ expect(mocks.claim).not.toHaveBeenCalled();
+ expect(mocks.start).not.toHaveBeenCalled();
+ });
+
+ it("fails the run rather than sharing a busy subscription", async () => {
+ // This used to swallow the busy result and launch anyway, putting two
+ // turns on one seat while the credential was stamped unavailable.
+ mocks.register.mockResolvedValue({
+ runId,
+ status: "creating",
+ created: true,
+ });
+ mocks.claim.mockResolvedValue({ held: false, holder: null });
+
+ await expect(
+ startGen2SupersetAgentSession({
+ workspaceId,
+ userId,
+ worktreeId: "main",
+ command: ["codex"],
+ idempotencyKey: "key-1",
+ }),
+ ).rejects.toThrow(/still using this connection/);
+
+ expect(mocks.claimLease).not.toHaveBeenCalled();
+ expect(mocks.start).not.toHaveBeenCalled();
+ expect(mocks.markFailed).toHaveBeenCalled();
+ });
+
+ it("rolls back the lease and marks the run failed when the launch fails", async () => {
+ mocks.register.mockResolvedValue({
+ runId,
+ status: "creating",
+ created: true,
+ });
+ mocks.start.mockRejectedValue(new Error("launch exploded"));
+
+ await expect(
+ startGen2SupersetAgentSession({
+ workspaceId,
+ userId,
+ worktreeId: "main",
+ command: ["codex"],
+ idempotencyKey: "key-1",
+ }),
+ ).rejects.toThrow("launch exploded");
+
+ expect(mocks.release).toHaveBeenCalledWith(
+ expect.objectContaining({ credentialId }),
+ );
+ expect(mocks.releaseLease).toHaveBeenCalledWith(
+ expect.objectContaining({ runId }),
+ );
+ expect(mocks.markFailed).toHaveBeenCalledWith(
+ expect.objectContaining({ runId, lastError: "launch exploded" }),
+ );
+ });
+
+ it("marks the run finished and releases the lease once it exits", async () => {
+ mocks.getRunById.mockResolvedValue(RUN);
+ mocks.poll.mockResolvedValue({
+ chunks: [],
+ nextSequence: 5,
+ exited: true,
+ exitCode: 0,
+ refreshReady: true,
+ });
+
+ await pollGen2SupersetAgentSession({
+ workspaceId,
+ userId,
+ runId,
+ after: 0,
+ });
+
+ expect(mocks.markFinished).toHaveBeenCalledWith(
+ expect.objectContaining({ runId, exitReason: "completed" }),
+ );
+ expect(mocks.release).toHaveBeenCalledWith(
+ expect.objectContaining({ credentialId }),
+ );
+ expect(mocks.releaseLease).toHaveBeenCalled();
+ });
+
+ it("does not finish the run while it is still running", async () => {
+ mocks.getRunById.mockResolvedValue(RUN);
+ mocks.poll.mockResolvedValue({
+ chunks: [],
+ nextSequence: 5,
+ exited: false,
+ exitCode: null,
+ refreshReady: false,
+ });
+
+ await pollGen2SupersetAgentSession({
+ workspaceId,
+ userId,
+ runId,
+ after: 0,
+ });
+
+ expect(mocks.markFinished).not.toHaveBeenCalled();
+ expect(mocks.releaseLease).not.toHaveBeenCalled();
+ });
+
+ it("rejects a run id from a different workspace instead of leaking it", async () => {
+ mocks.getRunById.mockResolvedValue({
+ ...RUN,
+ workspaceId: "other-workspace",
+ });
+
+ await expect(
+ pollGen2SupersetAgentSession({ workspaceId, userId, runId, after: 0 }),
+ ).rejects.toThrow("Superset run not found.");
+ });
+
+ it("stops the host process and releases the lease on cancel, even if stop fails", async () => {
+ mocks.getRunById.mockResolvedValue(RUN);
+ mocks.stop.mockRejectedValue(new Error("host unreachable"));
+
+ await expect(
+ cancelGen2SupersetAgentSession({ workspaceId, userId, runId }),
+ ).rejects.toThrow("host unreachable");
+
+ expect(mocks.markStopping).toHaveBeenCalled();
+ expect(mocks.release).toHaveBeenCalledWith(
+ expect.objectContaining({ credentialId }),
+ );
+ expect(mocks.releaseLease).toHaveBeenCalled();
+ expect(mocks.markFinished).toHaveBeenCalledWith(
+ expect.objectContaining({ runId, exitReason: "cancelled" }),
+ );
+ });
+
+ it("marks recovery_required when the host cannot verify the run", async () => {
+ mocks.getRunById.mockResolvedValue(RUN);
+ mocks.checkRecovery.mockResolvedValue({ adoptable: false });
+
+ const result = await reconcileGen2SupersetAgentSession({
+ workspaceId,
+ userId,
+ runId,
+ });
+
+ expect(result).toEqual({ adoptable: false });
+ expect(mocks.markRecoveryRequired).toHaveBeenCalledWith(
+ expect.objectContaining({ runId }),
+ );
+ });
+
+ it("leaves an adoptable run alone", async () => {
+ mocks.getRunById.mockResolvedValue(RUN);
+ mocks.checkRecovery.mockResolvedValue({ adoptable: true });
+
+ await reconcileGen2SupersetAgentSession({ workspaceId, userId, runId });
+
+ expect(mocks.markRecoveryRequired).not.toHaveBeenCalled();
+ });
+});
+
+describe("gen2 Superset agent turn (Phase 4 browser-facing delegate)", () => {
+ beforeEach(() => {
+ vi.resetAllMocks();
+ process.env.CODEV_SUPERSET_AGENT_SESSIONS_ENABLED = "true";
+ mocks.requireMember.mockResolvedValue({ status: "ready" });
+ mocks.claim.mockResolvedValue({ held: true });
+ mocks.resolveCredential.mockResolvedValue({
+ credentialId,
+ authCacheJson: "{}",
+ via: "subscription",
+ });
+ mocks.requireChat.mockResolvedValue({ id: chatId });
+ mocks.listMessages.mockResolvedValue([]);
+ mocks.listWorktrees.mockResolvedValue([]);
+ mocks.createWorktree.mockResolvedValue({
+ worktreeId: "agent-chat",
+ branch: "codev/agent-chat",
+ });
+ mocks.getRunById.mockResolvedValue({
+ id: runId,
+ workspaceId,
+ hostAgentSessionId: "agent-1",
+ connectionId: credentialId,
+ leaseClaimed: true,
+ });
+ });
+
+ it("provisions a per-chat worktree, starts the run, and persists the prompt", async () => {
+ mocks.register.mockResolvedValue({
+ runId,
+ status: "creating",
+ created: true,
+ });
+ mocks.start.mockResolvedValue({
+ hostWorkspaceId: "host-ws-1",
+ hostTerminalId: "term-1",
+ hostAgentSessionId: "agent-1",
+ });
+
+ const result = await startGen2SupersetAgentTurn({
+ workspaceId,
+ userId,
+ chatId,
+ prompt: "hello",
+ idempotencyKey: "key-1",
+ });
+
+ expect(result).toEqual({ sessionId: runId });
+ expect(mocks.createWorktree).toHaveBeenCalledWith(
+ workspaceId,
+ expect.objectContaining({ worktreeId: expect.any(String) }),
+ );
+ expect(mocks.register).toHaveBeenCalledWith(
+ expect.objectContaining({ worktreeId: expect.any(String) }),
+ );
+ expect(mocks.appendMessage).toHaveBeenCalledWith(
+ expect.objectContaining({
+ chatId,
+ role: "user",
+ body: "hello",
+ }),
+ );
+ expect(mocks.createTurn).toHaveBeenCalledWith(
+ expect.objectContaining({ sessionId: runId, chatId, workspaceId }),
+ );
+ });
+
+ it("reuses an existing chat worktree instead of creating a second one", async () => {
+ mocks.listWorktrees.mockResolvedValue([
+ { worktreeId: `agent-${chatId.replace(/-/g, "")}`, branch: "x" },
+ ]);
+ mocks.register.mockResolvedValue({
+ runId,
+ status: "creating",
+ created: true,
+ });
+ mocks.start.mockResolvedValue({
+ hostWorkspaceId: "host-ws-1",
+ hostTerminalId: "term-1",
+ hostAgentSessionId: "agent-1",
+ });
+
+ await startGen2SupersetAgentTurn({
+ workspaceId,
+ userId,
+ chatId,
+ prompt: "hello",
+ idempotencyKey: "key-1",
+ });
+
+ expect(mocks.createWorktree).not.toHaveBeenCalled();
+ });
+
+ it("polls the run, records output, and reports the persisted reply", async () => {
+ mocks.poll.mockResolvedValue({
+ chunks: [{ sequence: 1, data: "hi" }],
+ nextSequence: 1,
+ exited: true,
+ exitCode: 0,
+ refreshReady: true,
+ });
+ mocks.recordOutput.mockResolvedValue({
+ reply: "hi there",
+ messageId: "msg-1",
+ });
+
+ const result = await pollGen2SupersetAgentTurn({
+ workspaceId,
+ userId,
+ sessionId: runId,
+ after: 0,
+ });
+
+ expect(mocks.recordOutput).toHaveBeenCalledWith(
+ expect.objectContaining({ sessionId: runId, exited: true }),
+ );
+ expect(result.reply).toBe("hi there");
+ expect(result.persistedMessageId).toBe("msg-1");
+ expect(result.chunks).toEqual([
+ { sequence: 0, dataBase64: Buffer.from("hi").toString("base64") },
+ ]);
+ });
+
+ it("cancels through the run id", async () => {
+ await cancelGen2SupersetAgentTurn({
+ workspaceId,
+ userId,
+ sessionId: runId,
+ });
+
+ expect(mocks.markStopping).toHaveBeenCalled();
+ expect(mocks.stop).toHaveBeenCalledWith(workspaceId, "agent-1");
+ });
+});
diff --git a/apps/web/lib/gen2/superset-agent-runtime.ts b/apps/web/lib/gen2/superset-agent-runtime.ts
new file mode 100644
index 000000000..dee0da1ee
--- /dev/null
+++ b/apps/web/lib/gen2/superset-agent-runtime.ts
@@ -0,0 +1,454 @@
+import "server-only";
+
+import {
+ createSupersetWorktree,
+ listSupersetWorktrees,
+} from "../runtime/orchestrator-superset-runtime";
+import {
+ describeSeatHolder,
+ heartbeatCredentialSeat,
+ releaseCredentialSeat,
+ waitForCredentialSeat,
+} from "../providers/credential-seat";
+import {
+ appendGen2ChatMessage,
+ listGen2ChatMessages,
+ requireGen2Chat,
+} from "./chats";
+import { buildGen2CodexCommand } from "./codex-command";
+import { Gen2LifecycleError } from "./errors";
+import { logEvent } from "../platform/observability";
+import { resolveGen2Codex } from "./providers";
+import {
+ checkSupersetAgentRecovery,
+ pollSupersetAgent,
+ sendSupersetAgentInput,
+ startSupersetAgent,
+ stopSupersetAgent,
+} from "./superset-agent-orchestrator-client";
+import { isGen2SupersetAgentSessionsEnabled } from "./superset-agent-sessions-feature";
+import {
+ claimGen2SupersetRunLease,
+ getGen2SupersetRunById,
+ markGen2SupersetRunFailed,
+ markGen2SupersetRunFinished,
+ markGen2SupersetRunRecoveryRequired,
+ markGen2SupersetRunStarted,
+ markGen2SupersetRunStopping,
+ registerGen2SupersetRun,
+ releaseGen2SupersetRunLease,
+} from "./superset-runs";
+import { createGen2Turn, recordGen2SupersetRunOutput } from "./turns";
+import { toCodexExecChunks } from "./codex-output";
+import { requireGen2Member } from "./workspaces";
+
+/**
+ * The server-only CoDev runtime adapter docs/SUPERSET_AGENT_SESSION_PLAN.md
+ * Phase 3 calls for: it wires Phase 1's durable run state machine
+ * (`superset-runs.ts`) to the orchestrator client Phase 3 also adds
+ * (`superset-agent-orchestrator-client.ts`). `startGen2SupersetAgentTurn`,
+ * `pollGen2SupersetAgentTurn`, and `cancelGen2SupersetAgentTurn` below are
+ * Phase 4: the flag-gated delegate `agent.ts`'s unchanged
+ * `startGen2AgentTurn`/`pollGen2AgentTurn`/`cancelGen2AgentTurn` browser
+ * contract calls into instead of the direct `codex exec` sandbox path.
+ */
+
+function requireEnabled() {
+ if (!isGen2SupersetAgentSessionsEnabled()) {
+ throw new Gen2LifecycleError(
+ "Superset agent sessions are not enabled.",
+ 404,
+ );
+ }
+}
+
+async function requireOwnRun(workspaceId: string, runId: string) {
+ const run = await getGen2SupersetRunById(runId);
+ if (!run || run.workspaceId !== workspaceId) {
+ throw new Gen2LifecycleError("Superset run not found.", 404);
+ }
+ return run;
+}
+
+export async function startGen2SupersetAgentSession(input: {
+ workspaceId: string;
+ userId: string;
+ chatId?: string | null;
+ worktreeId: string;
+ command: string[];
+ idempotencyKey: string;
+}) {
+ requireEnabled();
+ await requireGen2Member(input.workspaceId, input.userId);
+ const credential = await resolveGen2Codex(input.userId);
+
+ const registration = await registerGen2SupersetRun({
+ workspaceId: input.workspaceId,
+ chatId: input.chatId ?? null,
+ createdBy: input.userId,
+ worktreeId: input.worktreeId,
+ provider: "openai",
+ connectionId: credential.credentialId,
+ idempotencyKey: input.idempotencyKey,
+ });
+ if (!registration.created) {
+ // A retried start reattaches to the run already in flight instead of
+ // claiming a second lease or starting a second Superset process.
+ return registration;
+ }
+
+ // Only a subscription holds a seat -- an API key has no one-turn-at-a-time
+ // limit, so claiming one would invent a restriction the provider does not.
+ //
+ // A busy seat used to be swallowed here and the run started anyway. It now
+ // waits, and fails the run with what holds the seat if the wait runs out,
+ // so the member is told the truth instead of two turns sharing one login.
+ const claimed = Boolean(credential.credentialId);
+ if (credential.credentialId) {
+ const seat = await waitForCredentialSeat({
+ credentialId: credential.credentialId,
+ userId: input.userId,
+ surface: "gen2",
+ ref: registration.runId,
+ });
+ if (!seat.held) {
+ await markGen2SupersetRunFailed({
+ runId: registration.runId,
+ workspaceId: input.workspaceId,
+ lastError: "credential_busy",
+ actorId: input.userId,
+ });
+ throw new Gen2LifecycleError(describeSeatHolder(seat.holder), 409);
+ }
+ await claimGen2SupersetRunLease({
+ runId: registration.runId,
+ workspaceId: input.workspaceId,
+ actorId: input.userId,
+ });
+ }
+
+ try {
+ const started = await startSupersetAgent(input.workspaceId, {
+ worktreeId: input.worktreeId,
+ provider: "openai",
+ codexAuthCacheJson: credential.authCacheJson,
+ command: input.command,
+ idempotencyKey: input.idempotencyKey,
+ });
+ await markGen2SupersetRunStarted({
+ runId: registration.runId,
+ workspaceId: input.workspaceId,
+ hostWorkspaceId: started.hostWorkspaceId,
+ hostTerminalId: started.hostTerminalId,
+ hostAgentSessionId: started.hostAgentSessionId,
+ actorId: input.userId,
+ });
+ return { ...registration, status: "running" as const };
+ } catch (error) {
+ if (claimed && credential.credentialId) {
+ await releaseCredentialSeat({
+ credentialId: credential.credentialId,
+ ref: registration.runId,
+ });
+ await releaseGen2SupersetRunLease({
+ runId: registration.runId,
+ workspaceId: input.workspaceId,
+ actorId: input.userId,
+ });
+ }
+ await markGen2SupersetRunFailed({
+ runId: registration.runId,
+ workspaceId: input.workspaceId,
+ lastError: error instanceof Error ? error.message : "unknown",
+ actorId: input.userId,
+ });
+ throw error;
+ }
+}
+
+export async function sendGen2SupersetAgentInput(input: {
+ workspaceId: string;
+ userId: string;
+ runId: string;
+ data: string;
+}) {
+ requireEnabled();
+ await requireGen2Member(input.workspaceId, input.userId);
+ const run = await requireOwnRun(input.workspaceId, input.runId);
+ if (!run.hostAgentSessionId) {
+ throw new Gen2LifecycleError("This run has not started yet.", 409);
+ }
+ await sendSupersetAgentInput(
+ input.workspaceId,
+ run.hostAgentSessionId,
+ input.data,
+ );
+}
+
+export async function pollGen2SupersetAgentSession(input: {
+ workspaceId: string;
+ userId: string;
+ runId: string;
+ after: number;
+}) {
+ requireEnabled();
+ await requireGen2Member(input.workspaceId, input.userId);
+ const run = await requireOwnRun(input.workspaceId, input.runId);
+ if (!run.hostAgentSessionId) {
+ throw new Gen2LifecycleError("This run has not started yet.", 409);
+ }
+
+ const result = await pollSupersetAgent(
+ input.workspaceId,
+ run.hostAgentSessionId,
+ input.after,
+ );
+
+ // Being polled is what holding the seat means; a run that stops polling
+ // stops blocking the member's other surfaces.
+ if (run.leaseClaimed && run.connectionId && !result.exited) {
+ await heartbeatCredentialSeat({
+ credentialId: run.connectionId,
+ ref: run.id,
+ });
+ }
+
+ if (result.exited) {
+ await markGen2SupersetRunFinished({
+ runId: run.id,
+ workspaceId: input.workspaceId,
+ exitReason:
+ result.exitCode === 0 ? "completed" : `exit_code:${result.exitCode}`,
+ actorId: input.userId,
+ });
+ if (run.leaseClaimed && run.connectionId) {
+ await releaseCredentialSeat({
+ credentialId: run.connectionId,
+ ref: run.id,
+ });
+ }
+ await releaseGen2SupersetRunLease({
+ runId: run.id,
+ workspaceId: input.workspaceId,
+ actorId: input.userId,
+ });
+ }
+
+ return result;
+}
+
+export async function cancelGen2SupersetAgentSession(input: {
+ workspaceId: string;
+ userId: string;
+ runId: string;
+}) {
+ requireEnabled();
+ await requireGen2Member(input.workspaceId, input.userId);
+ const run = await requireOwnRun(input.workspaceId, input.runId);
+
+ await markGen2SupersetRunStopping({
+ runId: run.id,
+ workspaceId: input.workspaceId,
+ actorId: input.userId,
+ });
+ try {
+ if (run.hostAgentSessionId) {
+ await stopSupersetAgent(input.workspaceId, run.hostAgentSessionId);
+ }
+ } finally {
+ if (run.leaseClaimed && run.connectionId) {
+ await releaseCredentialSeat({
+ credentialId: run.connectionId,
+ ref: run.id,
+ });
+ }
+ await releaseGen2SupersetRunLease({
+ runId: run.id,
+ workspaceId: input.workspaceId,
+ actorId: input.userId,
+ });
+ await markGen2SupersetRunFinished({
+ runId: run.id,
+ workspaceId: input.workspaceId,
+ exitReason: "cancelled",
+ actorId: input.userId,
+ });
+ }
+}
+
+/**
+ * Phase 5's host-restart reconciliation, exposed here since Phase 3 already
+ * adds the `/agents/:id/recovery` route this calls. A run that cannot be
+ * verified live moves to `recovery_required` rather than being silently
+ * relaunched with a potentially stale credential profile.
+ */
+export async function reconcileGen2SupersetAgentSession(input: {
+ workspaceId: string;
+ userId: string;
+ runId: string;
+}) {
+ requireEnabled();
+ await requireGen2Member(input.workspaceId, input.userId);
+ const run = await requireOwnRun(input.workspaceId, input.runId);
+ if (!run.hostAgentSessionId) {
+ return { adoptable: false as const };
+ }
+
+ const recovery = await checkSupersetAgentRecovery(
+ input.workspaceId,
+ run.hostAgentSessionId,
+ );
+ if (!recovery.adoptable) {
+ await markGen2SupersetRunRecoveryRequired({
+ runId: run.id,
+ workspaceId: input.workspaceId,
+ lastError: "Host could not verify the run after a restart.",
+ actorId: input.userId,
+ });
+ }
+ return recovery;
+}
+
+/**
+ * One worktree per chat, so two members' agents in two different chats never
+ * collide on the same checkout, matching Plan Phase 4 step 2 ("concurrent
+ * independent agents receive distinct worktrees"). Idempotent: a chat's
+ * worktree is created once and reused by every later turn in that chat.
+ */
+function agentWorktreeIdForChat(chatId: string) {
+ return `agent-${chatId.replace(/-/g, "")}`.slice(0, 64);
+}
+
+async function ensureGen2SupersetAgentWorktree(
+ workspaceId: string,
+ chatId: string,
+) {
+ const worktreeId = agentWorktreeIdForChat(chatId);
+ const existing = await listSupersetWorktrees(workspaceId);
+ if (existing.some((worktree) => worktree.worktreeId === worktreeId)) {
+ return worktreeId;
+ }
+ try {
+ await createSupersetWorktree(workspaceId, {
+ worktreeId,
+ branch: `codev/${worktreeId}`,
+ baseRef: "HEAD",
+ });
+ } catch (error) {
+ // Two turns racing to create the same chat's first worktree: the loser's
+ // `git worktree add` fails, but the worktree it wanted now exists anyway.
+ const retried = await listSupersetWorktrees(workspaceId);
+ if (!retried.some((worktree) => worktree.worktreeId === worktreeId)) {
+ throw error;
+ }
+ }
+ return worktreeId;
+}
+
+/**
+ * Phase 4: what `startGen2AgentTurn` in `agent.ts` delegates to when
+ * `CODEV_SUPERSET_AGENT_SESSIONS_ENABLED` is set, in place of
+ * `startCodexExecInSandbox`. Same browser contract (`{ sessionId }`) -- the
+ * durable run's own id stands in for the sandbox session id the direct path
+ * returns, and `pollGen2SupersetAgentTurn`/`cancelGen2SupersetAgentTurn`
+ * accept it back the same way.
+ */
+export async function startGen2SupersetAgentTurn(input: {
+ workspaceId: string;
+ userId: string;
+ chatId: string;
+ prompt: string;
+ idempotencyKey: string;
+}) {
+ requireEnabled();
+ await requireGen2Member(input.workspaceId, input.userId);
+ await requireGen2Chat(input.workspaceId, input.chatId);
+ const history = await listGen2ChatMessages(input.chatId);
+ const worktreeId = await ensureGen2SupersetAgentWorktree(
+ input.workspaceId,
+ input.chatId,
+ );
+ const command = buildGen2CodexCommand(input.prompt, history);
+
+ const session = await startGen2SupersetAgentSession({
+ workspaceId: input.workspaceId,
+ userId: input.userId,
+ chatId: input.chatId,
+ worktreeId,
+ command,
+ idempotencyKey: input.idempotencyKey,
+ });
+
+ try {
+ await appendGen2ChatMessage({
+ chatId: input.chatId,
+ role: "user",
+ body: input.prompt,
+ });
+ } catch (error) {
+ logEvent("error", "gen2.agent.persist_user_failed", {
+ detail: error instanceof Error ? error.message : "unknown",
+ });
+ }
+ // From here the server owns the transcript: every poll appends to this
+ // row, so the reply survives the browser going away mid-turn. Matches
+ // `startGen2AgentTurn`'s `createGen2Turn` call in agent.ts; safe to repeat
+ // on a retried start because of `onConflictDoNothing`.
+ await createGen2Turn({
+ sessionId: session.runId,
+ workspaceId: input.workspaceId,
+ chatId: input.chatId,
+ userId: input.userId,
+ });
+ return { sessionId: session.runId };
+}
+
+/**
+ * Phase 4: `pollGen2AgentTurn`'s Superset delegate. `input.sessionId` is the
+ * durable run id `startGen2SupersetAgentTurn` returned.
+ */
+export async function pollGen2SupersetAgentTurn(input: {
+ workspaceId: string;
+ userId: string;
+ sessionId: string;
+ after: number;
+}) {
+ requireEnabled();
+ const result = await pollGen2SupersetAgentSession({
+ workspaceId: input.workspaceId,
+ userId: input.userId,
+ runId: input.sessionId,
+ after: input.after,
+ });
+
+ const persisted = await recordGen2SupersetRunOutput({
+ sessionId: input.sessionId,
+ chunks: result.chunks,
+ exited: result.exited,
+ });
+
+ return {
+ chunks: toCodexExecChunks(result.chunks),
+ nextSequence: result.nextSequence,
+ exited: result.exited,
+ exitCode: result.exitCode,
+ reply: persisted?.reply ?? null,
+ persistedMessageId: persisted?.messageId ?? null,
+ };
+}
+
+/**
+ * Phase 4: `cancelGen2AgentTurn`'s Superset delegate.
+ */
+export async function cancelGen2SupersetAgentTurn(input: {
+ workspaceId: string;
+ userId: string;
+ sessionId: string;
+}) {
+ requireEnabled();
+ await cancelGen2SupersetAgentSession({
+ workspaceId: input.workspaceId,
+ userId: input.userId,
+ runId: input.sessionId,
+ });
+}
diff --git a/apps/web/lib/gen2/superset-agent-sessions-feature.test.ts b/apps/web/lib/gen2/superset-agent-sessions-feature.test.ts
new file mode 100644
index 000000000..5d46a62e0
--- /dev/null
+++ b/apps/web/lib/gen2/superset-agent-sessions-feature.test.ts
@@ -0,0 +1,23 @@
+import { afterEach, describe, expect, it } from "vitest";
+
+import { isGen2SupersetAgentSessionsEnabled } from "./superset-agent-sessions-feature";
+
+describe("isGen2SupersetAgentSessionsEnabled", () => {
+ afterEach(() => {
+ delete process.env.CODEV_SUPERSET_AGENT_SESSIONS_ENABLED;
+ });
+
+ it("defaults to off", () => {
+ expect(isGen2SupersetAgentSessionsEnabled()).toBe(false);
+ });
+
+ it("is off for anything other than the literal string true", () => {
+ process.env.CODEV_SUPERSET_AGENT_SESSIONS_ENABLED = "1";
+ expect(isGen2SupersetAgentSessionsEnabled()).toBe(false);
+ });
+
+ it("is on when explicitly enabled", () => {
+ process.env.CODEV_SUPERSET_AGENT_SESSIONS_ENABLED = "true";
+ expect(isGen2SupersetAgentSessionsEnabled()).toBe(true);
+ });
+});
diff --git a/apps/web/lib/gen2/superset-agent-sessions-feature.ts b/apps/web/lib/gen2/superset-agent-sessions-feature.ts
new file mode 100644
index 000000000..62721f527
--- /dev/null
+++ b/apps/web/lib/gen2/superset-agent-sessions-feature.ts
@@ -0,0 +1,12 @@
+import "server-only";
+
+/**
+ * Terminal-agent sessions launched through Superset, replacing the direct
+ * `codex exec` orchestrator path -- docs/SUPERSET_AGENT_SESSION_PLAN.md.
+ * Kept independent of `CODEV_SUPERSET_RUNTIME_ENABLED` (the terminal/Git/
+ * worktree bridge flag in `superset-runtime-feature.ts`) so the two migrate
+ * on separate schedules, per the plan's Phase 3.
+ */
+export function isGen2SupersetAgentSessionsEnabled() {
+ return process.env.CODEV_SUPERSET_AGENT_SESSIONS_ENABLED === "true";
+}
diff --git a/apps/web/lib/gen2/superset-runs.test.ts b/apps/web/lib/gen2/superset-runs.test.ts
new file mode 100644
index 000000000..91865ad9d
--- /dev/null
+++ b/apps/web/lib/gen2/superset-runs.test.ts
@@ -0,0 +1,219 @@
+import { beforeEach, describe, expect, it, vi } from "vitest";
+
+const databaseMocks = vi.hoisted(() => ({ getDatabase: vi.fn() }));
+
+vi.mock("../platform/database", () => ({
+ getDatabase: databaseMocks.getDatabase,
+}));
+
+import {
+ claimGen2SupersetRunLease,
+ markGen2SupersetRunFailed,
+ markGen2SupersetRunRecoveryRequired,
+ markGen2SupersetRunStarted,
+ registerGen2SupersetRun,
+ releaseGen2SupersetRunLease,
+} from "./superset-runs";
+
+const WORKSPACE_ID = "11111111-1111-4111-8111-111111111111";
+const RUN_ID = "22222222-2222-4222-8222-222222222222";
+const USER_ID = "33333333-3333-4333-8333-333333333333";
+
+function selectQuery(returned: unknown[] = []) {
+ const query = {
+ from: vi.fn(),
+ where: vi.fn(),
+ limit: vi.fn().mockResolvedValue(returned),
+ };
+ query.from.mockReturnValue(query);
+ query.where.mockReturnValue(query);
+ return query;
+}
+
+function updateQuery(returned: unknown[] = []) {
+ const query = { set: vi.fn(), where: vi.fn(), returning: vi.fn() };
+ query.set.mockReturnValue(query);
+ query.where.mockReturnValue(query);
+ query.returning.mockResolvedValue(returned);
+ return query;
+}
+
+function insertQuery(returned: unknown[] = []) {
+ const query = { values: vi.fn() };
+ query.values.mockReturnValue({
+ ...query,
+ returning: vi.fn().mockResolvedValue(returned),
+ });
+ return query;
+}
+
+describe("gen2 Superset run lifecycle", () => {
+ beforeEach(() => {
+ databaseMocks.getDatabase.mockReset();
+ });
+
+ it("creates a run on first registration and audits it", async () => {
+ const runSelect = selectQuery([]);
+ const runInsert = insertQuery([{ id: RUN_ID }]);
+ const eventInsert = { values: vi.fn().mockResolvedValue(undefined) };
+ const transaction = {
+ execute: vi.fn().mockResolvedValue(undefined),
+ select: vi.fn().mockReturnValueOnce(runSelect),
+ insert: vi
+ .fn()
+ .mockReturnValueOnce(runInsert)
+ .mockReturnValueOnce(eventInsert),
+ };
+ databaseMocks.getDatabase.mockReturnValue({
+ transaction: vi.fn(async (callback) => callback(transaction)),
+ });
+
+ await expect(
+ registerGen2SupersetRun({
+ workspaceId: WORKSPACE_ID,
+ createdBy: USER_ID,
+ worktreeId: "main",
+ provider: "openai",
+ idempotencyKey: "key-1",
+ }),
+ ).resolves.toEqual({ runId: RUN_ID, status: "creating", created: true });
+ expect(eventInsert.values).toHaveBeenCalledWith(
+ expect.objectContaining({ type: "run_created", result: "success" }),
+ );
+ });
+
+ it("returns the existing run instead of creating a second one on retry", async () => {
+ const runSelect = selectQuery([{ id: RUN_ID, status: "running" }]);
+ const transaction = {
+ execute: vi.fn().mockResolvedValue(undefined),
+ select: vi.fn().mockReturnValueOnce(runSelect),
+ insert: vi.fn(),
+ };
+ databaseMocks.getDatabase.mockReturnValue({
+ transaction: vi.fn(async (callback) => callback(transaction)),
+ });
+
+ await expect(
+ registerGen2SupersetRun({
+ workspaceId: WORKSPACE_ID,
+ createdBy: USER_ID,
+ worktreeId: "main",
+ provider: "openai",
+ idempotencyKey: "key-1",
+ }),
+ ).resolves.toEqual({ runId: RUN_ID, status: "running", created: false });
+ expect(transaction.insert).not.toHaveBeenCalled();
+ });
+
+ it("records host identifiers when a run starts", async () => {
+ const runUpdate = updateQuery([{ id: RUN_ID }]);
+ const eventInsert = { values: vi.fn().mockResolvedValue(undefined) };
+ const transaction = {
+ execute: vi.fn().mockResolvedValue(undefined),
+ update: vi.fn().mockReturnValueOnce(runUpdate),
+ insert: vi.fn().mockReturnValueOnce(eventInsert),
+ };
+ databaseMocks.getDatabase.mockReturnValue({
+ transaction: vi.fn(async (callback) => callback(transaction)),
+ });
+
+ await markGen2SupersetRunStarted({
+ runId: RUN_ID,
+ workspaceId: WORKSPACE_ID,
+ hostWorkspaceId: "host-ws-1",
+ hostTerminalId: "term-1",
+ hostAgentSessionId: "agent-1",
+ });
+ expect(runUpdate.set).toHaveBeenCalledWith(
+ expect.objectContaining({ status: "running", hostTerminalId: "term-1" }),
+ );
+ });
+
+ it("throws instead of silently no-oping when the run row is missing", async () => {
+ const runUpdate = updateQuery([]);
+ const transaction = {
+ execute: vi.fn().mockResolvedValue(undefined),
+ update: vi.fn().mockReturnValueOnce(runUpdate),
+ insert: vi.fn(),
+ };
+ databaseMocks.getDatabase.mockReturnValue({
+ transaction: vi.fn(async (callback) => callback(transaction)),
+ });
+
+ await expect(
+ markGen2SupersetRunFailed({
+ runId: RUN_ID,
+ workspaceId: WORKSPACE_ID,
+ lastError: "boom",
+ }),
+ ).rejects.toThrow("Superset run not found.");
+ });
+
+ it("is a no-op releasing a lease that was never claimed", async () => {
+ const runSelect = selectQuery([{ leaseClaimed: false }]);
+ const transaction = {
+ execute: vi.fn().mockResolvedValue(undefined),
+ select: vi.fn().mockReturnValueOnce(runSelect),
+ update: vi.fn(),
+ insert: vi.fn(),
+ };
+ databaseMocks.getDatabase.mockReturnValue({
+ transaction: vi.fn(async (callback) => callback(transaction)),
+ });
+
+ await releaseGen2SupersetRunLease({
+ runId: RUN_ID,
+ workspaceId: WORKSPACE_ID,
+ });
+ expect(transaction.update).not.toHaveBeenCalled();
+ });
+
+ it("claims a lease and audits it", async () => {
+ const runUpdate = updateQuery();
+ const eventInsert = { values: vi.fn().mockResolvedValue(undefined) };
+ const transaction = {
+ execute: vi.fn().mockResolvedValue(undefined),
+ update: vi.fn().mockReturnValueOnce(runUpdate),
+ insert: vi.fn().mockReturnValueOnce(eventInsert),
+ };
+ databaseMocks.getDatabase.mockReturnValue({
+ transaction: vi.fn(async (callback) => callback(transaction)),
+ });
+
+ await claimGen2SupersetRunLease({
+ runId: RUN_ID,
+ workspaceId: WORKSPACE_ID,
+ });
+ expect(runUpdate.set).toHaveBeenCalledWith(
+ expect.objectContaining({ leaseClaimed: true }),
+ );
+ expect(eventInsert.values).toHaveBeenCalledWith(
+ expect.objectContaining({ type: "lease_claimed" }),
+ );
+ });
+
+ it("bumps the recovery count instead of relaunching automatically", async () => {
+ const runUpdate = updateQuery([{ id: RUN_ID }]);
+ const eventInsert = { values: vi.fn().mockResolvedValue(undefined) };
+ const transaction = {
+ execute: vi.fn().mockResolvedValue(undefined),
+ update: vi.fn().mockReturnValueOnce(runUpdate),
+ insert: vi.fn().mockReturnValueOnce(eventInsert),
+ };
+ databaseMocks.getDatabase.mockReturnValue({
+ transaction: vi.fn(async (callback) => callback(transaction)),
+ });
+
+ await markGen2SupersetRunRecoveryRequired({
+ runId: RUN_ID,
+ workspaceId: WORKSPACE_ID,
+ lastError: "host restarted",
+ });
+ expect(runUpdate.set).toHaveBeenCalledWith(
+ expect.objectContaining({ status: "recovery_required" }),
+ );
+ expect(eventInsert.values).toHaveBeenCalledWith(
+ expect.objectContaining({ type: "recovery_required", result: "failure" }),
+ );
+ });
+});
diff --git a/apps/web/lib/gen2/superset-runs.ts b/apps/web/lib/gen2/superset-runs.ts
new file mode 100644
index 000000000..6d4b70622
--- /dev/null
+++ b/apps/web/lib/gen2/superset-runs.ts
@@ -0,0 +1,393 @@
+import "server-only";
+
+import { and, eq, inArray, sql } from "drizzle-orm";
+
+import { schema } from "@codev/db";
+import type { Gen2SupersetRunStatus } from "@codev/contracts";
+
+import { getDatabase } from "../platform/database";
+
+/**
+ * Durable run identity for a Gen 2 Superset terminal-agent session, per
+ * docs/SUPERSET_AGENT_SESSION_PLAN.md Phase 1. CoDev owns this row as the
+ * source of truth for identity, credential lease, and lifecycle state --
+ * Superset's own SQLite database is never queried for it. No credential
+ * material lives here, only a `connectionId` pointing at the existing
+ * encrypted `provider_credentials` row.
+ *
+ * Callers are responsible for membership/role checks before calling any
+ * mutating function here, matching the convention in `cli-agent-session.ts`.
+ */
+
+const SUPERSET_RUN_LOCK_PREFIX = "codev-gen2-superset-run:";
+
+/** Every state but the two terminal ones. */
+const NONTERMINAL_STATUSES: Gen2SupersetRunStatus[] = [
+ "creating",
+ "running",
+ "stopping",
+ "recovery_required",
+];
+
+type Database = ReturnType;
+type Transaction = Parameters[0]>[0];
+
+async function lockSupersetRunWorkspace(
+ transaction: Transaction,
+ workspaceId: string,
+) {
+ await transaction.execute(
+ sql`select pg_advisory_xact_lock(hashtext(${`${SUPERSET_RUN_LOCK_PREFIX}${workspaceId}`}))`,
+ );
+}
+
+export type Gen2SupersetRunAuditEventType =
+ | "run_created"
+ | "run_started"
+ | "run_stopping"
+ | "run_finished"
+ | "run_failed"
+ | "recovery_required"
+ | "lease_claimed"
+ | "lease_released";
+
+/**
+ * Append-only audit entry for a run's lease and lifecycle transitions. Takes
+ * `transaction` so a call site can append atomically with the state change
+ * that triggered it.
+ */
+async function recordGen2SupersetRunAuditEvent(
+ transaction: Transaction,
+ input: {
+ runId: string;
+ workspaceId: string;
+ actorId?: string | null;
+ type: Gen2SupersetRunAuditEventType;
+ result: "success" | "failure";
+ },
+) {
+ await transaction.insert(schema.gen2SupersetRunEvents).values({
+ runId: input.runId,
+ workspaceId: input.workspaceId,
+ actorId: input.actorId ?? null,
+ type: input.type,
+ result: input.result,
+ });
+}
+
+export type RegisterGen2SupersetRunInput = {
+ workspaceId: string;
+ chatId?: string | null;
+ createdBy: string;
+ worktreeId: string;
+ provider: string;
+ connectionId?: string | null;
+ credentialRevision?: string | null;
+ /** Retrying with the same key returns the existing run instead of a new one. */
+ idempotencyKey: string;
+};
+
+/**
+ * Idempotently create -- or return the existing -- run for one
+ * `(workspaceId, idempotencyKey)` pair, so a client retry after a dropped
+ * response resumes the same run instead of starting a second provider
+ * process.
+ */
+export async function registerGen2SupersetRun(
+ input: RegisterGen2SupersetRunInput,
+): Promise<{ runId: string; status: Gen2SupersetRunStatus; created: boolean }> {
+ const database = getDatabase();
+ return database.transaction(async (transaction) => {
+ await lockSupersetRunWorkspace(transaction, input.workspaceId);
+
+ const [existing] = await transaction
+ .select({
+ id: schema.gen2SupersetRuns.id,
+ status: schema.gen2SupersetRuns.status,
+ })
+ .from(schema.gen2SupersetRuns)
+ .where(
+ and(
+ eq(schema.gen2SupersetRuns.workspaceId, input.workspaceId),
+ eq(schema.gen2SupersetRuns.idempotencyKey, input.idempotencyKey),
+ ),
+ )
+ .limit(1);
+ if (existing) {
+ return { runId: existing.id, status: existing.status, created: false };
+ }
+
+ const [run] = await transaction
+ .insert(schema.gen2SupersetRuns)
+ .values({
+ workspaceId: input.workspaceId,
+ chatId: input.chatId ?? null,
+ createdBy: input.createdBy,
+ worktreeId: input.worktreeId,
+ provider:
+ input.provider as (typeof schema.credentialProvider.enumValues)[number],
+ connectionId: input.connectionId ?? null,
+ credentialRevision: input.credentialRevision ?? null,
+ idempotencyKey: input.idempotencyKey,
+ status: "creating",
+ })
+ .returning({ id: schema.gen2SupersetRuns.id });
+
+ await recordGen2SupersetRunAuditEvent(transaction, {
+ runId: run!.id,
+ workspaceId: input.workspaceId,
+ actorId: input.createdBy,
+ type: "run_created",
+ result: "success",
+ });
+
+ return { runId: run!.id, status: "creating", created: true };
+ });
+}
+
+export async function getGen2SupersetRunById(runId: string) {
+ const [run] = await getDatabase()
+ .select()
+ .from(schema.gen2SupersetRuns)
+ .where(eq(schema.gen2SupersetRuns.id, runId))
+ .limit(1);
+ return run ?? null;
+}
+
+/** Nonterminal runs for a workspace, for host-restart reconciliation (Phase 5). */
+export async function listActiveGen2SupersetRuns(workspaceId: string) {
+ return getDatabase()
+ .select()
+ .from(schema.gen2SupersetRuns)
+ .where(
+ and(
+ eq(schema.gen2SupersetRuns.workspaceId, workspaceId),
+ inArray(schema.gen2SupersetRuns.status, NONTERMINAL_STATUSES),
+ ),
+ );
+}
+
+/** Claim the run's hosted-subscription execution lease exactly once. */
+export async function claimGen2SupersetRunLease(input: {
+ runId: string;
+ workspaceId: string;
+ actorId?: string | null;
+}) {
+ return getDatabase().transaction(async (transaction) => {
+ await lockSupersetRunWorkspace(transaction, input.workspaceId);
+ await transaction
+ .update(schema.gen2SupersetRuns)
+ .set({ leaseClaimed: true, updatedAt: new Date() })
+ .where(
+ and(
+ eq(schema.gen2SupersetRuns.id, input.runId),
+ eq(schema.gen2SupersetRuns.workspaceId, input.workspaceId),
+ ),
+ );
+ await recordGen2SupersetRunAuditEvent(transaction, {
+ runId: input.runId,
+ workspaceId: input.workspaceId,
+ actorId: input.actorId ?? null,
+ type: "lease_claimed",
+ result: "success",
+ });
+ });
+}
+
+/** Release the lease. Safe to call more than once for the same run. */
+export async function releaseGen2SupersetRunLease(input: {
+ runId: string;
+ workspaceId: string;
+ actorId?: string | null;
+}) {
+ return getDatabase().transaction(async (transaction) => {
+ await lockSupersetRunWorkspace(transaction, input.workspaceId);
+ const [run] = await transaction
+ .select({ leaseClaimed: schema.gen2SupersetRuns.leaseClaimed })
+ .from(schema.gen2SupersetRuns)
+ .where(
+ and(
+ eq(schema.gen2SupersetRuns.id, input.runId),
+ eq(schema.gen2SupersetRuns.workspaceId, input.workspaceId),
+ ),
+ )
+ .limit(1);
+ if (!run || !run.leaseClaimed) {
+ return;
+ }
+ await transaction
+ .update(schema.gen2SupersetRuns)
+ .set({ leaseClaimed: false, updatedAt: new Date() })
+ .where(eq(schema.gen2SupersetRuns.id, input.runId));
+ await recordGen2SupersetRunAuditEvent(transaction, {
+ runId: input.runId,
+ workspaceId: input.workspaceId,
+ actorId: input.actorId ?? null,
+ type: "lease_released",
+ result: "success",
+ });
+ });
+}
+
+/** Move a run from `creating` to `running` and record its host identifiers. */
+export async function markGen2SupersetRunStarted(input: {
+ runId: string;
+ workspaceId: string;
+ hostWorkspaceId: string;
+ hostTerminalId: string;
+ hostAgentSessionId: string;
+ actorId?: string | null;
+}) {
+ return getDatabase().transaction(async (transaction) => {
+ await lockSupersetRunWorkspace(transaction, input.workspaceId);
+ const [run] = await transaction
+ .update(schema.gen2SupersetRuns)
+ .set({
+ status: "running",
+ hostWorkspaceId: input.hostWorkspaceId,
+ hostTerminalId: input.hostTerminalId,
+ hostAgentSessionId: input.hostAgentSessionId,
+ lastError: null,
+ updatedAt: new Date(),
+ })
+ .where(
+ and(
+ eq(schema.gen2SupersetRuns.id, input.runId),
+ eq(schema.gen2SupersetRuns.workspaceId, input.workspaceId),
+ ),
+ )
+ .returning({ id: schema.gen2SupersetRuns.id });
+ if (!run) {
+ throw new Error("Superset run not found.");
+ }
+ await recordGen2SupersetRunAuditEvent(transaction, {
+ runId: input.runId,
+ workspaceId: input.workspaceId,
+ actorId: input.actorId ?? null,
+ type: "run_started",
+ result: "success",
+ });
+ });
+}
+
+async function transitionGen2SupersetRun(input: {
+ runId: string;
+ workspaceId: string;
+ status: Gen2SupersetRunStatus;
+ exitReason?: string | null;
+ lastError?: string | null;
+ auditType: Gen2SupersetRunAuditEventType;
+ auditResult: "success" | "failure";
+ actorId?: string | null;
+}) {
+ return getDatabase().transaction(async (transaction) => {
+ await lockSupersetRunWorkspace(transaction, input.workspaceId);
+ const [run] = await transaction
+ .update(schema.gen2SupersetRuns)
+ .set({
+ status: input.status,
+ exitReason: input.exitReason ?? undefined,
+ lastError: input.lastError ?? undefined,
+ updatedAt: new Date(),
+ })
+ .where(
+ and(
+ eq(schema.gen2SupersetRuns.id, input.runId),
+ eq(schema.gen2SupersetRuns.workspaceId, input.workspaceId),
+ ),
+ )
+ .returning({ id: schema.gen2SupersetRuns.id });
+ if (!run) {
+ throw new Error("Superset run not found.");
+ }
+ await recordGen2SupersetRunAuditEvent(transaction, {
+ runId: input.runId,
+ workspaceId: input.workspaceId,
+ actorId: input.actorId ?? null,
+ type: input.auditType,
+ result: input.auditResult,
+ });
+ });
+}
+
+export async function markGen2SupersetRunStopping(input: {
+ runId: string;
+ workspaceId: string;
+ actorId?: string | null;
+}) {
+ return transitionGen2SupersetRun({
+ ...input,
+ status: "stopping",
+ auditType: "run_stopping",
+ auditResult: "success",
+ });
+}
+
+export async function markGen2SupersetRunFinished(input: {
+ runId: string;
+ workspaceId: string;
+ exitReason?: string | null;
+ actorId?: string | null;
+}) {
+ return transitionGen2SupersetRun({
+ ...input,
+ status: "finished",
+ auditType: "run_finished",
+ auditResult: "success",
+ });
+}
+
+export async function markGen2SupersetRunFailed(input: {
+ runId: string;
+ workspaceId: string;
+ lastError: string;
+ actorId?: string | null;
+}) {
+ return transitionGen2SupersetRun({
+ ...input,
+ status: "failed",
+ auditType: "run_failed",
+ auditResult: "failure",
+ });
+}
+
+/**
+ * A host restart left this run's live state unverifiable. Do not relaunch it
+ * automatically -- Phase 5 requires an explicit member-initiated resume with
+ * a fresh connection and profile.
+ */
+export async function markGen2SupersetRunRecoveryRequired(input: {
+ runId: string;
+ workspaceId: string;
+ lastError?: string | null;
+ actorId?: string | null;
+}) {
+ return getDatabase().transaction(async (transaction) => {
+ await lockSupersetRunWorkspace(transaction, input.workspaceId);
+ const [run] = await transaction
+ .update(schema.gen2SupersetRuns)
+ .set({
+ status: "recovery_required",
+ lastError: input.lastError ?? undefined,
+ recoveryCount: sql`${schema.gen2SupersetRuns.recoveryCount} + 1`,
+ updatedAt: new Date(),
+ })
+ .where(
+ and(
+ eq(schema.gen2SupersetRuns.id, input.runId),
+ eq(schema.gen2SupersetRuns.workspaceId, input.workspaceId),
+ ),
+ )
+ .returning({ id: schema.gen2SupersetRuns.id });
+ if (!run) {
+ throw new Error("Superset run not found.");
+ }
+ await recordGen2SupersetRunAuditEvent(transaction, {
+ runId: input.runId,
+ workspaceId: input.workspaceId,
+ actorId: input.actorId ?? null,
+ type: "recovery_required",
+ result: "failure",
+ });
+ });
+}
diff --git a/apps/web/lib/gen2/turns.ts b/apps/web/lib/gen2/turns.ts
index 702c94760..49786bcf5 100644
--- a/apps/web/lib/gen2/turns.ts
+++ b/apps/web/lib/gen2/turns.ts
@@ -14,6 +14,7 @@ import {
type CodexExecChunk,
} from "./codex-output";
import { reduceCodexTurn } from "./turn-events";
+import type { SupersetAgentPollChunk } from "./superset-agent-orchestrator-client";
import { reconcileGen2CollaborationPaths } from "./collaboration-events";
/**
@@ -133,3 +134,93 @@ export async function recordGen2TurnChunks(input: {
return null;
}
}
+
+/**
+ * Same accumulation as `recordGen2TurnChunks`, for a Superset terminal-agent
+ * run instead of a direct `codex exec` sandbox session (Superset Agent
+ * Session Plan Phase 4). Uses the run's `hostAgentSessionId` as the
+ * `gen2AgentTurns.sessionId` key -- that column is a bare `text` primary key,
+ * not tied to the `codex exec` sandbox session format.
+ *
+ * Superset's poll snapshots the whole terminal buffer on every change (see
+ * `vendor/superset/.../codev/agents.ts`'s `/poll` route) rather than
+ * streaming an incremental append, so each chunk here already is the
+ * complete current text -- it *replaces* `turn.output` instead of extending
+ * it. `reduceCodexTurn` re-parses the whole accumulated text on every call by
+ * design (see turn-events.ts), so replaying the same `codex exec --json`
+ * lines inside a growing snapshot still yields stable item ids and the same
+ * reply.
+ */
+export async function recordGen2SupersetRunOutput(input: {
+ sessionId: string;
+ chunks: SupersetAgentPollChunk[];
+ exited: boolean;
+}): Promise<{ reply: string; messageId: string } | null> {
+ try {
+ const database = getDatabase();
+ const [turn] = await database
+ .select()
+ .from(schema.gen2AgentTurns)
+ .where(eq(schema.gen2AgentTurns.sessionId, input.sessionId))
+ .limit(1);
+ if (!turn || turn.exited) return null;
+
+ const latest = [...input.chunks].sort(
+ (left, right) => left.sequence - right.sequence,
+ );
+ const output = latest.length
+ ? capTurnOutput(latest[latest.length - 1]!.data)
+ : turn.output;
+
+ if (!input.exited) {
+ if (output === turn.output) return null;
+ await database
+ .update(schema.gen2AgentTurns)
+ .set({ output, updatedAt: new Date() })
+ .where(eq(schema.gen2AgentTurns.sessionId, input.sessionId));
+ return null;
+ }
+
+ const state = reduceCodexTurn(output);
+ const changedPaths = state.items.flatMap((item) =>
+ item.kind === "fileChange"
+ ? item.changes.map((change) => change.path)
+ : [],
+ );
+ if (changedPaths.length > 0) {
+ await reconcileGen2CollaborationPaths({
+ workspaceId: turn.workspaceId,
+ userId: turn.userId,
+ paths: changedPaths,
+ }).catch((error) => {
+ logEvent("error", "gen2.collaboration.reconcile_failed", {
+ detail: error instanceof Error ? error.message : "unknown",
+ });
+ });
+ }
+ const body = state.reply || state.error || "";
+ const message = body
+ ? await appendGen2ChatMessage({
+ chatId: turn.chatId,
+ role: "assistant",
+ body,
+ items: state.items,
+ })
+ : null;
+ await database
+ .update(schema.gen2AgentTurns)
+ .set({
+ output,
+ exited: true,
+ replyMessageId: message?.id ?? null,
+ updatedAt: new Date(),
+ })
+ .where(eq(schema.gen2AgentTurns.sessionId, input.sessionId));
+ return message ? { reply: message.body, messageId: message.id } : null;
+ } catch (error) {
+ logEvent("error", "gen2.turn.record_failed", {
+ detail: error instanceof Error ? error.message : "unknown",
+ });
+ return null;
+ }
+}
diff --git a/apps/web/lib/providers/claude-cli-token-route.ts b/apps/web/lib/providers/claude-cli-token-route.ts
index cdb754dba..17f868f11 100644
--- a/apps/web/lib/providers/claude-cli-token-route.ts
+++ b/apps/web/lib/providers/claude-cli-token-route.ts
@@ -7,7 +7,7 @@ import { getApiUser } from "../http/api";
import { deleteProviderCredential } from "./credentials";
import { requireOrganizationSettingsWrite } from "../auth/settings-access";
-const scopeTypeSchema = z.enum(["USER", "ORGANIZATION"]);
+const scopeTypeSchema = z.enum(["USER", "WORKSPACE"]);
/** Mirrors `disconnectHostedCodexConnection`
* (`hosted-codex-subscription-route.ts`) for the Claude CLI setup-token. */
@@ -29,9 +29,9 @@ export async function disconnectClaudeCliTokenConnection(request: Request) {
}
const scopeType = parsed.data;
const scopeId =
- scopeType === "ORGANIZATION" ? (body.organizationId ?? "") : user.id;
+ scopeType === "WORKSPACE" ? (body.organizationId ?? "") : user.id;
try {
- if (scopeType === "ORGANIZATION") {
+ if (scopeType === "WORKSPACE") {
await requireOrganizationSettingsWrite(user.id, scopeId);
}
await deleteProviderCredential(
diff --git a/apps/web/lib/providers/claude-cli-token-view.ts b/apps/web/lib/providers/claude-cli-token-view.ts
index 630d26fe0..361caf59d 100644
--- a/apps/web/lib/providers/claude-cli-token-view.ts
+++ b/apps/web/lib/providers/claude-cli-token-view.ts
@@ -1,6 +1,6 @@
export const CLAUDE_CLI_TOKEN_KIND = "claude_cli_token" as const;
-export type ClaudeCliTokenScopeType = "USER" | "ORGANIZATION";
+export type ClaudeCliTokenScopeType = "USER" | "WORKSPACE";
/** The `codev claude-auth` setup-token's public status — mirrors
* `HostedCodexPublicStatus` (`hosted-codex-subscription-view.ts`) so the two
@@ -11,8 +11,5 @@ export type ClaudeCliTokenPublicStatus = {
status: "not_connected" | "connected";
stateText: string;
lastFour: string | null;
- /** Whether every member of the scope may use this login — see
- * `scoped-credential-sharing.ts`. Always false for USER scope. */
- sharingEnabled: boolean;
canManage: boolean;
};
diff --git a/apps/web/lib/providers/claude-connection-session.ts b/apps/web/lib/providers/claude-connection-session.ts
index 8eb9738a2..3ef204450 100644
--- a/apps/web/lib/providers/claude-connection-session.ts
+++ b/apps/web/lib/providers/claude-connection-session.ts
@@ -72,7 +72,7 @@ export type ClaudeConnectionSessionView = {
status: (typeof schema.claudeConnectionSessionStatus.enumValues)[number];
authorizeUrl: string | null;
failureReason: string | null;
- scopeType: "USER" | "ORGANIZATION";
+ scopeType: "USER" | "WORKSPACE";
scopeId: string;
};
@@ -93,7 +93,7 @@ function toView(row: SessionRow): ClaudeConnectionSessionView {
status: row.status,
authorizeUrl: row.authorizeUrl,
failureReason: row.failureReason,
- scopeType: row.scopeType as "USER" | "ORGANIZATION",
+ scopeType: row.scopeType as "USER" | "WORKSPACE",
scopeId: row.scopeId,
};
}
@@ -250,7 +250,7 @@ export async function startClaudeConnectionSession(
input: { userId: string; scopeType?: unknown; organizationId?: unknown },
runner: ClaudeLoginRunner = unavailableClaudeRunner,
): Promise {
- if (input.scopeType === "ORGANIZATION") {
+ if (input.scopeType === "WORKSPACE") {
throw new ClaudeConnectionError(
"Claude subscriptions must be connected personally, not shared with an organization.",
400,
diff --git a/apps/web/lib/providers/claude-connection.test.ts b/apps/web/lib/providers/claude-connection.test.ts
index d0246fa63..05246eeb5 100644
--- a/apps/web/lib/providers/claude-connection.test.ts
+++ b/apps/web/lib/providers/claude-connection.test.ts
@@ -98,12 +98,12 @@ describe("resolveClaudeConnectionScope", () => {
expect(requireOrganizationSettingsWriteMock).not.toHaveBeenCalled();
});
- it("requires org write access for an organization scope", async () => {
+ it("requires org write access for a workspace scope", async () => {
requireOrganizationSettingsWriteMock.mockRejectedValueOnce(new Error("no"));
await expect(
resolveClaudeConnectionScope({
userId: "u1",
- scopeType: "ORGANIZATION",
+ scopeType: "WORKSPACE",
organizationId: "org1",
}),
).rejects.toBeInstanceOf(ClaudeConnectionError);
diff --git a/apps/web/lib/providers/claude-connection.ts b/apps/web/lib/providers/claude-connection.ts
index bd1a72d79..e774e703e 100644
--- a/apps/web/lib/providers/claude-connection.ts
+++ b/apps/web/lib/providers/claude-connection.ts
@@ -79,9 +79,8 @@ export async function resolveClaudeConnectionScope(input: {
userId: string;
scopeType?: unknown;
organizationId?: unknown;
-}): Promise<{ scopeType: "USER" | "ORGANIZATION"; scopeId: string }> {
- const scopeType =
- input.scopeType === "ORGANIZATION" ? "ORGANIZATION" : "USER";
+}): Promise<{ scopeType: "USER" | "WORKSPACE"; scopeId: string }> {
+ const scopeType = input.scopeType === "WORKSPACE" ? "WORKSPACE" : "USER";
const scopeId =
scopeType === "USER"
? input.userId
@@ -91,7 +90,7 @@ export async function resolveClaudeConnectionScope(input: {
if (!scopeId) {
throw new ClaudeConnectionError("Organization id is required.");
}
- if (scopeType === "ORGANIZATION") {
+ if (scopeType === "WORKSPACE") {
try {
await requireOrganizationSettingsWrite(input.userId, scopeId);
} catch {
@@ -110,7 +109,7 @@ export async function resolveClaudeConnectionScope(input: {
* land in exactly the same row shape.
*/
export async function persistClaudeOAuthToken(input: {
- scopeType: "USER" | "ORGANIZATION";
+ scopeType: "USER" | "WORKSPACE";
scopeId: string;
oauthToken: string;
source: ClaudeConnectionSource;
diff --git a/apps/web/lib/providers/codex-cli-auth-cache.ts b/apps/web/lib/providers/codex-cli-auth-cache.ts
index b61a6a6bd..7ba7d5fbc 100644
--- a/apps/web/lib/providers/codex-cli-auth-cache.ts
+++ b/apps/web/lib/providers/codex-cli-auth-cache.ts
@@ -49,8 +49,7 @@ export async function saveCodexCliAuthCache(request: Request) {
organizationId?: unknown;
authCache?: unknown;
};
- const scopeType =
- input.scopeType === "ORGANIZATION" ? "ORGANIZATION" : "USER";
+ const scopeType = input.scopeType === "WORKSPACE" ? "WORKSPACE" : "USER";
const scopeId =
scopeType === "USER"
? cli.userId
@@ -58,7 +57,7 @@ export async function saveCodexCliAuthCache(request: Request) {
? input.organizationId
: "";
if (!scopeId) throw new CliAuthError("Organization id is required.");
- if (scopeType === "ORGANIZATION") {
+ if (scopeType === "WORKSPACE") {
try {
await requireOrganizationSettingsWrite(cli.userId, scopeId);
} catch {
@@ -73,7 +72,6 @@ export async function saveCodexCliAuthCache(request: Request) {
userId: cli.userId,
scopeType,
scopeId,
- // sharingEnabled: defaults to true for ORGANIZATION, false for USER.
material: { authCacheJson },
accountLabel: "Codex CLI",
connectedVia: "cli",
diff --git a/apps/web/lib/providers/codex-oauth-connection.test.ts b/apps/web/lib/providers/codex-oauth-connection.test.ts
index 01428ee08..db3f07e32 100644
--- a/apps/web/lib/providers/codex-oauth-connection.test.ts
+++ b/apps/web/lib/providers/codex-oauth-connection.test.ts
@@ -93,7 +93,6 @@ describe("persistCodexSubscriptionFromOAuth", () => {
material: expect.objectContaining({
authCacheJson: expect.stringContaining('"refresh_token":"r"'),
}),
- enabledFor: { rooms: true, workspace: true },
}),
);
expect(persistHostedCodexConnection.mock.calls[0]?.[0]).not.toHaveProperty(
@@ -101,7 +100,7 @@ describe("persistCodexSubscriptionFromOAuth", () => {
);
});
- it("maps WORKSPACE scope to a shared ORGANIZATION connection", async () => {
+ it("persists a workspace-scoped sign-in as the workspace's login", async () => {
await persistCodexSubscriptionFromOAuth({
userId: "user-1",
scopeType: "WORKSPACE",
@@ -110,7 +109,7 @@ describe("persistCodexSubscriptionFromOAuth", () => {
});
expect(persistHostedCodexConnection).toHaveBeenCalledWith(
expect.objectContaining({
- scopeType: "ORGANIZATION",
+ scopeType: "WORKSPACE",
scopeId: "workspace-1",
}),
);
diff --git a/apps/web/lib/providers/codex-oauth-connection.ts b/apps/web/lib/providers/codex-oauth-connection.ts
index c59b56d5c..72c93dcb9 100644
--- a/apps/web/lib/providers/codex-oauth-connection.ts
+++ b/apps/web/lib/providers/codex-oauth-connection.ts
@@ -88,20 +88,17 @@ export async function persistCodexSubscriptionFromOAuth(input: {
tokens: CodexOAuthTokens;
}) {
const authCacheJson = buildCodexAuthCacheJson(input.tokens);
- // Hosted Codex credentials scope to USER or ORGANIZATION; a WORKSPACE-scoped
- // OAuth session persists as the shared organization connection.
- const scopeType = input.scopeType === "USER" ? "USER" : "ORGANIZATION";
+ // A Codex login is either the member's own or the workspace's.
+ const scopeType = input.scopeType === "USER" ? "USER" : "WORKSPACE";
await persistHostedCodexConnection({
userId: input.userId,
scopeType,
scopeId: input.scopeId,
- // sharingEnabled: defaults to true for ORGANIZATION, false for USER.
material: { authCacheJson },
accountLabel: "ChatGPT",
// Codex OAuth produces the same refreshable auth cache as `codex login`.
// The workspace runtime materializes it into the member-scoped CODEX_HOME,
// so one browser sign-in can power both rooms and coding workspaces.
connectedVia: "browser",
- enabledFor: { rooms: true, workspace: true },
});
}
diff --git a/apps/web/lib/providers/credential-seat.test.ts b/apps/web/lib/providers/credential-seat.test.ts
new file mode 100644
index 000000000..750f6dcbb
--- /dev/null
+++ b/apps/web/lib/providers/credential-seat.test.ts
@@ -0,0 +1,215 @@
+import { beforeEach, describe, expect, it, vi } from "vitest";
+
+/**
+ * An in-memory stand-in for the one-row-per-credential table, faithful to the
+ * two things the real claim relies on: the unique index on `credential_id`,
+ * and the conditional upsert that only takes a seat over from the same run or
+ * one that stopped heartbeating.
+ */
+const rows = new Map<
+ string,
+ {
+ credentialId: string;
+ userId: string;
+ surface: string;
+ ref: string;
+ heartbeatAt: Date;
+ }
+>();
+
+const mocks = vi.hoisted(() => ({ insert: vi.fn(), now: () => new Date() }));
+
+vi.mock("@codev/db", () => ({
+ schema: { providerCredentialRuns: { credentialId: "credential_id" } },
+}));
+
+vi.mock("../platform/database", () => ({ getDatabase: () => database }));
+
+vi.mock("drizzle-orm", () => ({
+ and: (...parts: unknown[]) => parts,
+ eq: (_column: unknown, value: unknown) => value,
+ lt: (_column: unknown, value: unknown) => value,
+ sql: Object.assign(() => "sql", { raw: () => "sql" }),
+}));
+
+type Captured = {
+ values?: Record;
+ set?: Record;
+ where?: unknown[];
+};
+
+let captured: Captured = {};
+
+const database = {
+ insert: () => ({
+ values: (values: Record) => {
+ captured.values = values;
+ return {
+ onConflictDoUpdate: () => ({
+ returning: async () => {
+ const credentialId = values.credentialId as string;
+ const existing = rows.get(credentialId);
+ const stale =
+ existing &&
+ existing.heartbeatAt.getTime() < Date.now() - 2 * 60_000;
+ if (existing && existing.ref !== values.ref && !stale) return [];
+ rows.set(credentialId, {
+ credentialId,
+ userId: values.userId as string,
+ surface: values.surface as string,
+ ref: values.ref as string,
+ heartbeatAt: values.heartbeatAt as Date,
+ });
+ return [{ id: "seat-1" }];
+ },
+ }),
+ };
+ },
+ }),
+ select: () => ({
+ from: () => ({
+ where: (value: unknown) => ({
+ limit: async () => {
+ const row = rows.get(value as string);
+ return row ? [row] : [];
+ },
+ }),
+ }),
+ }),
+ update: () => ({
+ set: (set: Record) => ({
+ where: async (where: unknown[]) => {
+ const [credentialId, ref] = where as [string, string];
+ const row = rows.get(credentialId);
+ if (row && row.ref === ref) {
+ rows.set(credentialId, {
+ ...row,
+ ...(set.ref ? { ref: set.ref as string } : {}),
+ heartbeatAt: set.heartbeatAt as Date,
+ });
+ }
+ },
+ }),
+ }),
+ delete: () => ({
+ where: (where: unknown[]) => {
+ const [credentialId, ref] = where as [string, string];
+ const row = rows.get(credentialId);
+ if (row && row.ref === ref) rows.delete(credentialId);
+ return { returning: async () => [] };
+ },
+ }),
+};
+
+const {
+ claimCredentialSeat,
+ credentialSeatHolder,
+ describeSeatHolder,
+ heartbeatCredentialSeat,
+ releaseCredentialSeat,
+ retagCredentialSeat,
+} = await import("./credential-seat");
+
+const seat = {
+ credentialId: "11111111-1111-4111-8111-111111111111",
+ userId: "user-1",
+ surface: "gen2" as const,
+};
+
+describe("credential seat", () => {
+ beforeEach(() => {
+ rows.clear();
+ captured = {};
+ mocks.insert.mockReset();
+ vi.useRealTimers();
+ });
+
+ it("gives one run the seat and tells the next who holds it", async () => {
+ expect(await claimCredentialSeat({ ...seat, ref: "run-1" })).toEqual({
+ held: true,
+ });
+
+ const second = await claimCredentialSeat({
+ ...seat,
+ surface: "rooms",
+ ref: "run-2",
+ });
+ expect(second.held).toBe(false);
+ // The member is told what is using their subscription rather than being
+ // handed a bare failure — this is the message the queueing UX shows.
+ expect(second.held === false && second.holder?.ref).toBe("run-1");
+ expect(
+ describeSeatHolder(second.held === false ? second.holder : null),
+ ).toBe("a workspace turn is still using this connection.");
+ });
+
+ it("lets the same run re-claim its own seat", async () => {
+ await claimCredentialSeat({ ...seat, ref: "run-1" });
+ // A retried start must reattach rather than deadlock against itself.
+ expect(await claimCredentialSeat({ ...seat, ref: "run-1" })).toEqual({
+ held: true,
+ });
+ });
+
+ it("frees a seat whose holder stopped heartbeating", async () => {
+ vi.useFakeTimers();
+ await claimCredentialSeat({ ...seat, ref: "dead-run" });
+
+ // The old mechanism stamped the credential unavailable for sixteen
+ // minutes with no reaper, so a crashed turn blocked every other surface
+ // for a quarter of an hour. Here the seat is gone two minutes after the
+ // holder stops polling.
+ vi.advanceTimersByTime(2 * 60_000 + 1_000);
+ expect(await credentialSeatHolder(seat.credentialId)).toBeNull();
+ expect(await claimCredentialSeat({ ...seat, ref: "new-run" })).toEqual({
+ held: true,
+ });
+ });
+
+ it("keeps the seat while the run is still being polled", async () => {
+ vi.useFakeTimers();
+ await claimCredentialSeat({ ...seat, ref: "run-1" });
+
+ for (let poll = 0; poll < 10; poll += 1) {
+ vi.advanceTimersByTime(30_000);
+ await heartbeatCredentialSeat({
+ credentialId: seat.credentialId,
+ ref: "run-1",
+ });
+ }
+
+ // Five minutes in and still held: a long turn is not a stale one.
+ const blocked = await claimCredentialSeat({ ...seat, ref: "run-2" });
+ expect(blocked.held).toBe(false);
+ });
+
+ it("ignores a release from a run that no longer holds the seat", async () => {
+ await claimCredentialSeat({ ...seat, ref: "run-1" });
+ // A late finalizer from an earlier turn must not free the seat a newer
+ // turn is using.
+ await releaseCredentialSeat({
+ credentialId: seat.credentialId,
+ ref: "an-older-run",
+ });
+ expect(await credentialSeatHolder(seat.credentialId)).toMatchObject({
+ ref: "run-1",
+ });
+ });
+
+ it("re-keys a seat onto the run id once the run has one", async () => {
+ await claimCredentialSeat({ ...seat, ref: "idempotency-key" });
+ await retagCredentialSeat({
+ credentialId: seat.credentialId,
+ fromRef: "idempotency-key",
+ toRef: "session-9",
+ });
+ expect(await credentialSeatHolder(seat.credentialId)).toMatchObject({
+ ref: "session-9",
+ });
+ await releaseCredentialSeat({
+ credentialId: seat.credentialId,
+ ref: "session-9",
+ });
+ expect(await credentialSeatHolder(seat.credentialId)).toBeNull();
+ });
+});
diff --git a/apps/web/lib/providers/credential-seat.ts b/apps/web/lib/providers/credential-seat.ts
new file mode 100644
index 000000000..2fb5092bc
--- /dev/null
+++ b/apps/web/lib/providers/credential-seat.ts
@@ -0,0 +1,225 @@
+import "server-only";
+
+import { and, eq, lt, sql } from "drizzle-orm";
+
+import { schema } from "@codev/db";
+
+import { getDatabase } from "../platform/database";
+import type { ExecutorSurface } from "./registry";
+
+/**
+ * One seat per credential, held by a live run.
+ *
+ * A subscription is a human seat: the provider runs one turn at a time on it.
+ * The previous mechanism was a `unavailable_until` stamp set sixteen minutes
+ * ahead of the claim, with no reaper — so a turn that died without releasing
+ * locked the member out of every other surface for a quarter of an hour, and
+ * the stamp itself was the only thing that ever freed it. Worse, the same
+ * lock meant different things to different callers: chat rooms refused
+ * outright on a busy seat, while Gen 2 claimed it, swallowed the busy error
+ * and ran anyway.
+ *
+ * Here the seat is a row owned by a run and refreshed while that run is
+ * polled. A run that stops polling releases it within `SEAT_STALE_AFTER_MS`,
+ * and every executor gets the same answer to "is this credential busy".
+ */
+
+/**
+ * How long a seat survives without a heartbeat.
+ *
+ * Every holder polls on a cadence well inside this: the room reply workflow
+ * and both Gen 2 turn loops poll with a 25s server-side wait, and each poll
+ * refreshes the seat. Two minutes is several missed polls, not a guess at how
+ * long a turn might take — the seat is released when the run stops, not when
+ * a timer expires, so this only has to cover a crashed holder.
+ */
+export const SEAT_STALE_AFTER_MS = 2 * 60_000;
+
+export type SeatHolder = {
+ surface: ExecutorSurface;
+ ref: string;
+ userId: string;
+ heartbeatAt: Date;
+};
+
+export type SeatClaim =
+ | { held: true }
+ /** Someone else's run has it; `holder` is what to tell the member. */
+ | { held: false; holder: SeatHolder | null };
+
+function staleBefore() {
+ return new Date(Date.now() - SEAT_STALE_AFTER_MS);
+}
+
+/**
+ * Take the seat for a run, or report who holds it.
+ *
+ * Re-claiming with the same `ref` succeeds: a retried start must reattach to
+ * its own run rather than deadlock against itself.
+ */
+export async function claimCredentialSeat(input: {
+ credentialId: string;
+ userId: string;
+ surface: ExecutorSurface;
+ ref: string;
+}): Promise {
+ const now = new Date();
+ const [claimed] = await getDatabase()
+ .insert(schema.providerCredentialRuns)
+ .values({
+ credentialId: input.credentialId,
+ userId: input.userId,
+ surface: input.surface,
+ ref: input.ref,
+ heartbeatAt: now,
+ })
+ .onConflictDoUpdate({
+ target: schema.providerCredentialRuns.credentialId,
+ set: {
+ userId: input.userId,
+ surface: input.surface,
+ ref: input.ref,
+ heartbeatAt: now,
+ updatedAt: now,
+ },
+ // Take it over only from our own run or from one that stopped
+ // heartbeating. Anything else keeps its seat.
+ setWhere: sql`${schema.providerCredentialRuns.ref} = ${input.ref} or ${schema.providerCredentialRuns.heartbeatAt} < ${staleBefore()}`,
+ })
+ .returning({ id: schema.providerCredentialRuns.id });
+ if (claimed) return { held: true };
+ return {
+ held: false,
+ holder: await credentialSeatHolder(input.credentialId),
+ };
+}
+
+/** Who holds this credential's seat, if anyone still does. */
+export async function credentialSeatHolder(
+ credentialId: string,
+): Promise {
+ const [row] = await getDatabase()
+ .select()
+ .from(schema.providerCredentialRuns)
+ .where(eq(schema.providerCredentialRuns.credentialId, credentialId))
+ .limit(1);
+ if (!row) return null;
+ if (row.heartbeatAt < staleBefore()) return null;
+ return {
+ surface: row.surface as ExecutorSurface,
+ ref: row.ref,
+ userId: row.userId,
+ heartbeatAt: row.heartbeatAt,
+ };
+}
+
+/**
+ * Keep the seat while a run is alive. Called from the poll loops, so a long
+ * turn holds its seat for exactly as long as it is actually running.
+ */
+export async function heartbeatCredentialSeat(input: {
+ credentialId: string;
+ ref: string;
+}): Promise {
+ const now = new Date();
+ await getDatabase()
+ .update(schema.providerCredentialRuns)
+ .set({ heartbeatAt: now, updatedAt: now })
+ .where(
+ and(
+ eq(schema.providerCredentialRuns.credentialId, input.credentialId),
+ eq(schema.providerCredentialRuns.ref, input.ref),
+ ),
+ );
+}
+
+/**
+ * Re-key a seat once its run has a durable id.
+ *
+ * A turn has to hold the seat *before* it starts — that is the point — but
+ * only learns its session id from the start call. The claim therefore uses
+ * the idempotency key and is re-tagged here, so the poll and cleanup paths,
+ * which know only the session id, can release exactly their own seat.
+ */
+export async function retagCredentialSeat(input: {
+ credentialId: string;
+ fromRef: string;
+ toRef: string;
+}): Promise {
+ const now = new Date();
+ await getDatabase()
+ .update(schema.providerCredentialRuns)
+ .set({ ref: input.toRef, heartbeatAt: now, updatedAt: now })
+ .where(
+ and(
+ eq(schema.providerCredentialRuns.credentialId, input.credentialId),
+ eq(schema.providerCredentialRuns.ref, input.fromRef),
+ ),
+ );
+}
+
+/**
+ * Give the seat back. Scoped by `ref` so a late finalizer from an earlier run
+ * cannot release the seat a newer one has taken.
+ */
+export async function releaseCredentialSeat(input: {
+ credentialId: string;
+ ref: string;
+}): Promise {
+ await getDatabase()
+ .delete(schema.providerCredentialRuns)
+ .where(
+ and(
+ eq(schema.providerCredentialRuns.credentialId, input.credentialId),
+ eq(schema.providerCredentialRuns.ref, input.ref),
+ ),
+ );
+}
+
+/** Clear seats whose holder stopped heartbeating. Claiming already takes a
+ * stale seat over; this is for periodic tidying. */
+export async function releaseStaleCredentialSeats(): Promise {
+ const deleted = await getDatabase()
+ .delete(schema.providerCredentialRuns)
+ .where(lt(schema.providerCredentialRuns.heartbeatAt, staleBefore()))
+ .returning({ id: schema.providerCredentialRuns.id });
+ return deleted.length;
+}
+
+const SURFACE_LABEL: Record = {
+ rooms: "a chat room reply",
+ workspace: "a workspace turn",
+ gen2: "a workspace turn",
+};
+
+/** What to tell a member whose turn is waiting for their own seat. */
+export function describeSeatHolder(holder: SeatHolder | null): string {
+ if (!holder) return "Another turn is using this connection.";
+ return `${SURFACE_LABEL[holder.surface]} is still using this connection.`;
+}
+
+/**
+ * Wait for the seat instead of refusing the turn.
+ *
+ * A member's second turn is a queueing problem, not an error: the first one
+ * finishes in seconds to minutes and the seat frees. Callers bound the wait
+ * and surface `held: false` to the UI only when it runs out.
+ */
+export async function waitForCredentialSeat(
+ input: {
+ credentialId: string;
+ userId: string;
+ surface: ExecutorSurface;
+ ref: string;
+ },
+ options: { timeoutMs?: number; intervalMs?: number } = {},
+): Promise {
+ const timeoutMs = options.timeoutMs ?? 20_000;
+ const intervalMs = options.intervalMs ?? 1_000;
+ const deadline = Date.now() + timeoutMs;
+ for (;;) {
+ const claim = await claimCredentialSeat(input);
+ if (claim.held || Date.now() >= deadline) return claim;
+ await new Promise((resolve) => setTimeout(resolve, intervalMs));
+ }
+}
diff --git a/apps/web/lib/providers/credentials.test.ts b/apps/web/lib/providers/credentials.test.ts
index 62c6d2aa0..c8106b3f1 100644
--- a/apps/web/lib/providers/credentials.test.ts
+++ b/apps/web/lib/providers/credentials.test.ts
@@ -19,6 +19,7 @@ const mockDatabase = vi.hoisted(() => ({
select: vi.fn(() => ({
from: vi.fn(() => ({
where: vi.fn(() => ({
+ limit: vi.fn(async () => mockRows.shift() ?? []),
orderBy: vi.fn(() => ({
limit: vi.fn(async () => mockRows.shift() ?? []),
})),
@@ -104,7 +105,10 @@ describe("resolveAgentCredential", () => {
expect(mockClaudeRuntime).toHaveBeenCalledWith("sender");
expect(mockDatabase.select).not.toHaveBeenCalled();
});
- it("refuses legacy Claude tokens and requires official runtime reconnect", async () => {
+ it("refuses a browser-era Claude token and asks for a rooms login", async () => {
+ // A legacy `anthropic` OAUTH_TOKEN row is not a setup-token, and a
+ // setup-token is not a rooms credential either. Neither may answer a
+ // reply; the member is told to connect one that can.
mockRows.push([
baseCredential({
provider: "anthropic",
@@ -115,12 +119,11 @@ describe("resolveAgentCredential", () => {
]);
await expect(
resolvePersonalChatSubscription("sender", "claude"),
- ).rejects.toThrow(/Reconnect Claude/);
+ ).rejects.toThrow(/Claude/);
mockRows.length = 0;
await expect(
resolvePersonalChatSubscription("sender", "claude"),
- ).rejects.toThrow("Reconnect Claude");
- expect(mockRows).toHaveLength(0);
+ ).rejects.toThrow(/Connect Claude in Settings/);
});
it("room Codex resolution never requests an organization credential", async () => {
@@ -131,9 +134,9 @@ describe("resolveAgentCredential", () => {
expect(
await resolvePersonalChatSubscription("sender", "codex"),
).toMatchObject({ authType: "HOSTED_CODEX_SUBSCRIPTION", source: "USER" });
+ // No workspace id: a shared seat can never fund a room reply.
expect(mockHostedSubscription).toHaveBeenLastCalledWith({
userId: "sender",
- includeBusy: true,
});
});
it("resolves the encrypted official Codex auth cache", async () => {
@@ -287,21 +290,19 @@ describe("getClaudeCliTokenPublicStatus", () => {
provider: "anthropic",
credentialType: "OAUTH_TOKEN",
connectedVia: "cli",
- sharingEnabled: true,
lastFour: "wxyz",
}),
]);
await expect(
getClaudeCliTokenPublicStatus({
- scopeType: "ORGANIZATION",
+ scopeType: "WORKSPACE",
scopeId: "workspace-1",
canManage: true,
}),
).resolves.toMatchObject({
status: "connected",
- scopeType: "ORGANIZATION",
+ scopeType: "WORKSPACE",
lastFour: "wxyz",
- sharingEnabled: true,
stateText: "Connected for this workspace",
});
});
@@ -322,7 +323,6 @@ describe("getClaudeCliTokenPublicStatus", () => {
}),
).resolves.toMatchObject({
status: "not_connected",
- sharingEnabled: false,
});
});
diff --git a/apps/web/lib/providers/credentials.ts b/apps/web/lib/providers/credentials.ts
index 9a9ca6250..a92bc08d9 100644
--- a/apps/web/lib/providers/credentials.ts
+++ b/apps/web/lib/providers/credentials.ts
@@ -18,10 +18,7 @@ import {
decryptHostedMaterial,
resolveHostedCodexSubscription,
} from "./hosted-codex-subscription-credentials";
-import {
- defaultSharingEnabled,
- resolvePersonalOrSharedCredential,
-} from "./scoped-credential-sharing";
+import { resolvePersonalOrSharedCredential } from "./scoped-credential-sharing";
import {
CLAUDE_CLI_TOKEN_KIND,
type ClaudeCliTokenPublicStatus,
@@ -33,7 +30,7 @@ const CREDENTIAL_CONTEXT = {
purpose: "provider-credential",
};
-export type CredentialSource = "USER" | "WORKSPACE" | "ORGANIZATION";
+export type CredentialSource = "USER" | "WORKSPACE";
export interface ResolvedCredential {
provider: AuthProvider;
@@ -94,18 +91,17 @@ function byokRequiredError(provider: AuthProvider) {
export type CredentialSurface = "rooms" | "workspace";
/**
- * Predicates limiting a lookup to credentials usable on one surface. A coding
- * workspace runs on a shared host, so it never sees a browser subscription —
- * nor an unstamped legacy row, which is treated as browser by the migration.
- * Rooms accept any provenance the member has enabled there.
+ * Predicates limiting a lookup to credentials usable on one surface.
+ *
+ * Only provenance is left here: which *kinds* can run where is the provider
+ * registry's answer (`registry.ts`), and the member's one remaining choice —
+ * whether a credential may fund a turn in a shared workspace — is applied by
+ * `resolveCredential`. This narrow helper survives for the Gen 1 readers that
+ * still query rows directly.
*/
function surfacePredicates(surface: CredentialSurface | undefined) {
- if (!surface) return [];
- if (surface === "rooms") {
- return [eq(schema.providerCredentials.enabledForRooms, true)];
- }
+ if (!surface || surface === "rooms") return [];
return [
- eq(schema.providerCredentials.enabledForWorkspace, true),
isNotNull(schema.providerCredentials.connectedVia),
ne(schema.providerCredentials.connectedVia, "browser"),
];
@@ -363,64 +359,47 @@ async function getCredentialValue(
}
/**
- * Resolve only the sender's subscription for a chat room; never fall back to
- * an API key or shared seat. Rooms are the one surface a browser subscription
- * may power, so any provenance is accepted — but only if the member left the
- * credential enabled for rooms (the Claude browser runtime lives outside
- * provider_credentials and is inherently rooms-only, so it carries no flag).
+ * Resolve the credential a chat-room reply runs on.
+ *
+ * The walk itself now lives in `resolveCredential`; this keeps the
+ * `ResolvedCredential` shape the rooms executor consumes. Rooms pass no
+ * workspace id, so a shared seat can never fund a reply, and the registry —
+ * not a flag on the row — decides that rooms run the two subscription forms
+ * and not an API key.
*/
export async function resolvePersonalChatSubscription(
userId: string,
provider: "claude" | "codex",
): Promise {
- if (provider === "claude") {
- const { getConnectedClaudeRuntime } =
- await import("./claude-connection-session");
- const connection = await getConnectedClaudeRuntime(userId);
- if (!connection)
- throw new Error("Reconnect Claude using official login in Settings.");
+ const { requireCredential } = await import("./resolve");
+ const resolved = await requireCredential({
+ userId,
+ provider,
+ surface: "rooms",
+ });
+ if (resolved.secret.kind === "claude_runtime") {
return {
provider: "anthropic",
source: "USER",
authType: "CLAUDE_RUNTIME",
- credentialId: connection.id,
+ credentialId: resolved.secret.connectionId,
claudeUserId: userId,
};
}
- if (provider === "codex") {
- const hosted = await resolveHostedCodexSubscription({
- userId,
- includeBusy: true,
- });
- if (
- hosted?.credential.encryptedMaterial &&
- hosted.credential.enabledForRooms !== false
- ) {
- const material = await decryptHostedMaterial(
- hosted.credential.encryptedMaterial,
- );
- if (material.authCacheJson)
- return {
- provider: "openai",
- source: "USER",
- authType: "HOSTED_CODEX_SUBSCRIPTION",
- credentialId: hosted.credential.id,
- codexAuthCacheJson: material.authCacheJson,
- };
- }
+ if (resolved.secret.kind === "codex_auth_cache") {
+ return {
+ provider: "openai",
+ source: "USER",
+ authType: "HOSTED_CODEX_SUBSCRIPTION",
+ ...(resolved.credentialId ? { credentialId: resolved.credentialId } : {}),
+ codexAuthCacheJson: resolved.secret.authCacheJson,
+ };
}
- const credential = await findCredential(
- "USER",
- userId,
- "openai",
- "OAUTH_TOKEN",
- "rooms",
+ // The registry lists no other kind as rooms-capable; a new one must decide
+ // how the rooms executor consumes it rather than falling through silently.
+ throw new Error(
+ "This connection cannot answer in chat rooms. Connect a subscription in Settings.",
);
- if (!credential || credential.status !== "active")
- throw new Error(
- "Connect your subscription in Settings before asking for a reply.",
- );
- return getCredentialValue(credential);
}
export async function resolveAgentCredential(
@@ -599,7 +578,7 @@ export async function resolveClaudeCliTokenForIde(
{ userId, workspaceId },
{
findPersonal: (id) => findCliToken("USER", id),
- findShared: (id) => findCliToken("ORGANIZATION", id),
+ findShared: (id) => findCliToken("WORKSPACE", id),
},
);
if (!result?.credential.encryptedAccessToken) return null;
@@ -609,9 +588,6 @@ export async function resolveClaudeCliTokenForIde(
/** How a credential was obtained; mirrors `credentialConnectedVia` in the schema. */
export type CredentialConnectedVia = "browser" | "cli" | "api_key";
-/** Which product surfaces a credential is enabled for (isolation + opt-in sharing). */
-export type CredentialSurfaces = { rooms: boolean; workspace: boolean };
-
export async function saveProviderCredential(input: {
scopeType: ScopeType;
scopeId: string;
@@ -629,14 +605,9 @@ export async function saveProviderCredential(input: {
* to `browser` (rooms-only), the conservative choice for a flow that did not
* declare itself. */
connectedVia?: CredentialConnectedVia | undefined;
- /** Surfaces to enable on create. Defaults to both; on reconnect the member's
- * existing toggles are preserved unless this is given. */
- enabledFor?: CredentialSurfaces | undefined;
- /** Whether every member of the scope (an ORGANIZATION credential's scope id
- * is a specific workspace) may use this login, not just whoever connected
- * it. Defaults to true for ORGANIZATION scope, false for USER — the same
- * rule `persistHostedCodexConnection` applies for Codex. */
- sharingEnabled?: boolean | undefined;
+ /** Whether this credential may fund a turn in a shared workspace.
+ * Defaults to true on create; preserved on reconnect unless given. */
+ allowInSharedWorkspaces?: boolean | undefined;
}) {
const scopeType = parseScopeType(input.scopeType);
const provider = parseProvider(input.provider);
@@ -644,8 +615,6 @@ export async function saveProviderCredential(input: {
const connectedVia: CredentialConnectedVia =
input.connectedVia ??
(credentialType === "OAUTH_TOKEN" ? "browser" : "api_key");
- const sharingEnabled =
- input.sharingEnabled ?? defaultSharingEnabled(scopeType);
// A consumer Claude OAuth token must never be used as a direct-API bearer, so
// the browser-era token flow stays retired. The one exception is the local
@@ -717,9 +686,7 @@ export async function saveProviderCredential(input: {
keyVersion: 2,
lastFour: input.lastFour ?? null,
connectedVia,
- sharingEnabled,
- enabledForRooms: input.enabledFor?.rooms ?? true,
- enabledForWorkspace: input.enabledFor?.workspace ?? true,
+ allowInSharedWorkspaces: input.allowInSharedWorkspaces ?? true,
})
.onConflictDoUpdate({
target: [
@@ -740,12 +707,8 @@ export async function saveProviderCredential(input: {
keyVersion: 2,
lastFour: input.lastFour ?? null,
connectedVia,
- ...(input.sharingEnabled !== undefined ? { sharingEnabled } : {}),
- ...(input.enabledFor
- ? {
- enabledForRooms: input.enabledFor.rooms,
- enabledForWorkspace: input.enabledFor.workspace,
- }
+ ...(input.allowInSharedWorkspaces !== undefined
+ ? { allowInSharedWorkspaces: input.allowInSharedWorkspaces }
: {}),
updatedAt: new Date(),
},
@@ -755,7 +718,7 @@ export async function saveProviderCredential(input: {
export async function saveOpenAICredential(
userId: string,
apiKey: string,
- enabledFor?: CredentialSurfaces,
+ allowInSharedWorkspaces?: boolean,
) {
const normalized = apiKey.trim();
if (!normalized.startsWith("sk-") || normalized.length < 20) {
@@ -768,14 +731,14 @@ export async function saveOpenAICredential(
credentialType: "API_KEY",
apiKey: normalized,
lastFour: normalized.slice(-4),
- enabledFor,
+ allowInSharedWorkspaces,
});
}
export async function saveAnthropicCredential(
userId: string,
apiKey: string,
- enabledFor?: CredentialSurfaces,
+ allowInSharedWorkspaces?: boolean,
) {
const normalized = apiKey.trim();
if (!normalized.startsWith("sk-ant-") || normalized.length < 20) {
@@ -788,14 +751,14 @@ export async function saveAnthropicCredential(
credentialType: "API_KEY",
apiKey: normalized,
lastFour: normalized.slice(-4),
- enabledFor,
+ allowInSharedWorkspaces,
});
}
export async function saveCursorCredential(
userId: string,
apiKey: string,
- enabledFor?: CredentialSurfaces,
+ allowInSharedWorkspaces?: boolean,
) {
const normalized = apiKey.trim();
if (normalized.length < 20) {
@@ -808,33 +771,26 @@ export async function saveCursorCredential(
credentialType: "API_KEY",
apiKey: normalized,
lastFour: normalized.slice(-4),
- enabledFor,
+ allowInSharedWorkspaces,
});
}
/**
- * Flip which surfaces a stored credential is enabled for. This records the
- * member's intent only: workspace *eligibility* (never a browser login) is
- * enforced by the resolvers regardless, so enabling a browser subscription for
- * workspaces here would be a no-op — the settings UI disables that toggle and
- * says why.
+ * Flip whether a stored credential may fund a turn inside a shared
+ * workspace. Unlike the two per-surface flags this replaced, it is read on
+ * every resolution path, so it is a real setting rather than a badge.
*/
export async function updateCredentialSurfaces(
scopeType: ScopeType,
scopeId: string,
provider: AuthProvider,
credentialType: CredentialType,
- surfaces: Partial,
+ allowInSharedWorkspaces: boolean,
) {
await getDatabase()
.update(schema.providerCredentials)
.set({
- ...(surfaces.rooms !== undefined
- ? { enabledForRooms: surfaces.rooms }
- : {}),
- ...(surfaces.workspace !== undefined
- ? { enabledForWorkspace: surfaces.workspace }
- : {}),
+ allowInSharedWorkspaces,
updatedAt: new Date(),
})
.where(
@@ -879,9 +835,7 @@ export async function getProviderCredentialStatus(
awsRoleArn: credential.awsRoleArn ?? undefined,
updatedAt: credential.updatedAt,
connectedVia: credential.connectedVia ?? undefined,
- enabledForRooms: credential.enabledForRooms,
- enabledForWorkspace: credential.enabledForWorkspace,
- sharingEnabled: credential.sharingEnabled,
+ allowInSharedWorkspaces: credential.allowInSharedWorkspaces,
};
}
@@ -906,7 +860,7 @@ export async function getOAuthCredentialStatus(
* means exactly "this scope's workspace host can use this token".
*/
export async function getClaudeCliTokenPublicStatus(input: {
- scopeType: "USER" | "ORGANIZATION";
+ scopeType: "USER" | "WORKSPACE";
scopeId: string;
canManage: boolean;
}): Promise {
@@ -922,12 +876,11 @@ export async function getClaudeCliTokenPublicStatus(input: {
scopeType: input.scopeType,
status: connected ? "connected" : "not_connected",
stateText: connected
- ? input.scopeType === "ORGANIZATION"
+ ? input.scopeType === "WORKSPACE"
? "Connected for this workspace"
: "Connected · codev claude-auth"
: "Not connected",
lastFour: connected ? (status?.lastFour ?? null) : null,
- sharingEnabled: Boolean(status?.sharingEnabled),
canManage: input.canManage,
};
}
diff --git a/apps/web/lib/providers/hosted-codex-subscription-credentials.ts b/apps/web/lib/providers/hosted-codex-subscription-credentials.ts
index f7b46b49f..f6a4d7a21 100644
--- a/apps/web/lib/providers/hosted-codex-subscription-credentials.ts
+++ b/apps/web/lib/providers/hosted-codex-subscription-credentials.ts
@@ -1,6 +1,6 @@
import "server-only";
-import { and, eq, isNull, lt, or } from "drizzle-orm";
+import { and, eq } from "drizzle-orm";
import { schema } from "@codev/db";
import type { HostedCodexScopeType } from "@codev/shared-types";
@@ -13,10 +13,7 @@ import {
type HostedCodexPublicStatus,
} from "./hosted-codex-subscription-view";
import { decryptSecret, encryptSecret } from "../platform/kms";
-import {
- defaultSharingEnabled,
- resolvePersonalOrSharedCredential,
-} from "./scoped-credential-sharing";
+import { resolvePersonalOrSharedCredential } from "./scoped-credential-sharing";
const HOSTED_CODEX_CONTEXT = {
application: "codev",
@@ -78,60 +75,20 @@ export async function updateHostedCodexAuthCache(
.where(eq(schema.providerCredentials.id, credentialId));
}
-export async function claimHostedCodexExecution(credentialId: string) {
- const [claimed] = await getDatabase()
- .update(schema.providerCredentials)
- .set({
- unavailableUntil: new Date(Date.now() + 16 * 60 * 1_000),
- updatedAt: new Date(),
- })
- .where(
- and(
- eq(schema.providerCredentials.id, credentialId),
- eq(schema.providerCredentials.status, "active"),
- eq(schema.providerCredentials.isConnected, true),
- or(
- isNull(schema.providerCredentials.unavailableUntil),
- lt(schema.providerCredentials.unavailableUntil, new Date()),
- ),
- ),
- )
- .returning({ id: schema.providerCredentials.id });
- if (!claimed) {
- throw new HostedCodexSubscriptionError(
- "This Codex connection is already running another cloud turn. Try again shortly.",
- 409,
- "hosted_codex_busy",
- );
- }
-}
-
-export async function releaseHostedCodexExecution(credentialId: string) {
- await getDatabase()
- .update(schema.providerCredentials)
- .set({ unavailableUntil: null, updatedAt: new Date() })
- .where(eq(schema.providerCredentials.id, credentialId));
-}
-
export async function persistHostedCodexConnection(input: {
userId: string;
scopeType: HostedCodexScopeType;
scopeId: string;
- /** Defaults to true for an ORGANIZATION scope, false for USER — see
- * `defaultSharingEnabled`. Override to connect a workspace-scoped login
- * that only its connector may use, or vice versa. */
- sharingEnabled?: boolean;
material: HostedCodexMaterial;
accountLabel?: string;
/** Browser and CLI logins produce byte-identical auth caches, so the caller
* must say which it was: only a `cli` login may power a coding workspace. */
connectedVia: "browser" | "cli";
- /** Surfaces to enable on create; existing toggles are kept on reconnect. */
- enabledFor?: { rooms: boolean; workspace: boolean };
+ /** Whether this login may fund a turn in a shared workspace; the member's
+ * existing choice is kept on reconnect unless this is given. */
+ allowInSharedWorkspaces?: boolean;
}) {
validateAuthCache(input.material.authCacheJson);
- const sharingEnabled =
- input.sharingEnabled ?? defaultSharingEnabled(input.scopeType);
const encryptedMaterial = await encryptHostedMaterial(input.material);
const [credential] = await getDatabase()
.insert(schema.providerCredentials)
@@ -147,12 +104,9 @@ export async function persistHostedCodexConnection(input: {
status: "active",
lastRefreshedAt: new Date(),
createdBy: input.userId,
- sharingEnabled,
- unavailableUntil: null,
revokedAt: null,
connectedVia: input.connectedVia,
- enabledForRooms: input.enabledFor?.rooms ?? true,
- enabledForWorkspace: input.enabledFor?.workspace ?? true,
+ allowInSharedWorkspaces: input.allowInSharedWorkspaces ?? true,
})
.onConflictDoUpdate({
target: [
@@ -169,15 +123,10 @@ export async function persistHostedCodexConnection(input: {
status: "active",
lastRefreshedAt: new Date(),
createdBy: input.userId,
- sharingEnabled,
- unavailableUntil: null,
revokedAt: null,
connectedVia: input.connectedVia,
- ...(input.enabledFor
- ? {
- enabledForRooms: input.enabledFor.rooms,
- enabledForWorkspace: input.enabledFor.workspace,
- }
+ ...(input.allowInSharedWorkspaces !== undefined
+ ? { allowInSharedWorkspaces: input.allowInSharedWorkspaces }
: {}),
updatedAt: new Date(),
},
@@ -196,7 +145,6 @@ export async function persistHostedCodexConnection(input: {
async function findActiveHostedCredential(
scopeType: HostedCodexScopeType,
scopeId: string,
- includeBusy = false,
) {
const [credential] = await getDatabase()
.select()
@@ -215,29 +163,25 @@ async function findActiveHostedCredential(
),
)
.limit(1);
- if (
- !includeBusy &&
- credential?.unavailableUntil &&
- credential.unavailableUntil.getTime() > Date.now()
- ) {
- return null;
- }
return credential ?? null;
}
+/**
+ * Whether the member has a Codex subscription connected — not whether it is
+ * free. Busy is a seat question (`credential-seat.ts`) and is asked by the
+ * caller that is about to run a turn; answering "not connected" for a login
+ * that is merely mid-turn used to send members off to reconnect a perfectly
+ * good credential.
+ */
export async function resolveHostedCodexSubscription(input: {
userId: string;
workspaceId?: string;
- includeBusy?: boolean;
}) {
if (!isHostedCodexSubscriptionEnabled()) return null;
return resolvePersonalOrSharedCredential(input, {
- findPersonal: (userId) =>
- findActiveHostedCredential("USER", userId, input.includeBusy),
- // A busy (in-use) shared login is unavailable the same as a personal one;
- // includeBusy is only ever passed for a personal lookup's own caller need.
+ findPersonal: (userId) => findActiveHostedCredential("USER", userId),
findShared: (workspaceId) =>
- findActiveHostedCredential("ORGANIZATION", workspaceId),
+ findActiveHostedCredential("WORKSPACE", workspaceId),
});
}
@@ -272,12 +216,11 @@ export async function getHostedCodexPublicStatus(input: {
scopeType: input.scopeType,
status: connected ? "connected" : enabled ? "not_connected" : "unavailable",
stateText: connected
- ? input.scopeType === "ORGANIZATION"
+ ? input.scopeType === "WORKSPACE"
? "Connected for this organization"
: "Connected · Codex CLI"
: "Not connected",
accountLabel: connected ? "Codex CLI" : null,
- sharingEnabled: Boolean(credential?.sharingEnabled),
canManage: input.canManage,
enabled,
configured: enabled,
diff --git a/apps/web/lib/providers/hosted-codex-subscription-route.ts b/apps/web/lib/providers/hosted-codex-subscription-route.ts
index a48e7e94e..797b541fe 100644
--- a/apps/web/lib/providers/hosted-codex-subscription-route.ts
+++ b/apps/web/lib/providers/hosted-codex-subscription-route.ts
@@ -12,7 +12,7 @@ import {
} from "./hosted-codex-subscription-credentials";
import { requireOrganizationSettingsWrite } from "../auth/settings-access";
-const scopeTypeSchema = z.enum(["USER", "ORGANIZATION"]);
+const scopeTypeSchema = z.enum(["USER", "WORKSPACE"]);
export async function disconnectHostedCodexConnection(request: Request) {
const user = await getApiUser();
@@ -32,9 +32,9 @@ export async function disconnectHostedCodexConnection(request: Request) {
}
const scopeType = parsed.data;
const scopeId =
- scopeType === "ORGANIZATION" ? (body.organizationId ?? "") : user.id;
+ scopeType === "WORKSPACE" ? (body.organizationId ?? "") : user.id;
try {
- if (scopeType === "ORGANIZATION") {
+ if (scopeType === "WORKSPACE") {
await requireOrganizationSettingsWrite(user.id, scopeId);
}
await disconnectHostedCodexSubscription({
diff --git a/apps/web/lib/providers/hosted-codex-subscription-view.ts b/apps/web/lib/providers/hosted-codex-subscription-view.ts
index 6f85af1ba..ef3f87751 100644
--- a/apps/web/lib/providers/hosted-codex-subscription-view.ts
+++ b/apps/web/lib/providers/hosted-codex-subscription-view.ts
@@ -12,7 +12,6 @@ export type HostedCodexPublicStatus = {
| "unavailable";
stateText: string;
accountLabel: string | null;
- sharingEnabled: boolean;
canManage: boolean;
enabled: boolean;
configured: boolean;
diff --git a/apps/web/lib/providers/oauth-route.ts b/apps/web/lib/providers/oauth-route.ts
index 48d484cb1..33b498501 100644
--- a/apps/web/lib/providers/oauth-route.ts
+++ b/apps/web/lib/providers/oauth-route.ts
@@ -15,14 +15,11 @@ import {
exchangeCursorApiKey,
exchangeOAuthCode,
getOAuthConfiguration,
- getOAuthFlowMode,
oauthCallbackPath,
oauthCookieName,
OAuthConfigurationError,
openOAuthState,
- parseManualAuthorizationCode,
persistCursorTokens,
- persistOAuthTokens,
pollCodexDeviceCode,
pollCursorLogin,
requestCodexDeviceCode,
@@ -169,29 +166,6 @@ async function authorizeScope(input: {
);
}
- if (configuration.flowMode === "manual_code") {
- const authorizeUrl = buildAuthorizationUrl(
- configuration,
- state,
- ).toString();
- if (asJson) {
- return setOAuthCookie(
- NextResponse.json({
- mode: configuration.flowMode,
- provider,
- authorizeUrl,
- }),
- provider,
- state,
- );
- }
- return setOAuthCookie(
- NextResponse.redirect(authorizeUrl),
- provider,
- state,
- );
- }
-
const authorizeUrl = buildAuthorizationUrl(configuration, state);
if (asJson) {
return setOAuthCookie(
@@ -270,26 +244,6 @@ async function parseSessionInput(request: Request) {
} as const;
}
-export async function startOAuth(request: Request, provider: OAuthProvider) {
- const resolved = await parseSessionInput(request);
- if ("error" in resolved) return resolved.error;
-
- const flowMode = getOAuthFlowMode(provider);
- if (request.method === "GET" && flowMode !== "app_callback") {
- // Hosted Claude/Codex flows need the interactive settings UI.
- return redirectToSettings(request, provider, "error", resolved.returnTo);
- }
-
- return authorizeScope({
- request,
- provider,
- scopeType: resolved.scopeType,
- scopeId: resolved.scopeId,
- returnTo: resolved.returnTo,
- asJson: false,
- });
-}
-
export async function startOAuthSession(
request: Request,
provider: OAuthProvider,
@@ -320,74 +274,6 @@ async function readOAuthState(
}
}
-export async function completeManualOAuth(
- request: Request,
- provider: OAuthProvider,
-) {
- if (provider !== "claude") {
- return NextResponse.json(
- { error: "Manual code completion is only supported for Claude Code." },
- { status: 400 },
- );
- }
-
- const state = await readOAuthState(provider);
- if (!state) {
- return NextResponse.json(
- { error: "OAuth session expired. Start the connection again." },
- { status: 400 },
- );
- }
-
- const parsed = sessionBodySchema.safeParse(
- await request.json().catch(() => ({})),
- );
- const codeRaw = parsed.success ? (parsed.data.code ?? "") : "";
- if (!codeRaw.trim()) {
- return NextResponse.json(
- { error: "Authorization code is required." },
- { status: 400 },
- );
- }
-
- try {
- const { code, returnedState } = parseManualAuthorizationCode(codeRaw);
- if (returnedState && returnedState !== state.state) {
- throw new Error("OAuth state mismatch.");
- }
- const user = await getApiUser();
- if (!user || user.id !== state.userId) {
- throw new Error("OAuth user mismatch.");
- }
- if (state.scopeType === "WORKSPACE") {
- await requireOrganizationSettingsWrite(user.id, state.scopeId);
- }
- const configuration = getOAuthConfiguration(
- provider,
- new URL(request.url).origin,
- );
- const tokens = await exchangeOAuthCode(
- configuration,
- code,
- state.codeVerifier,
- state.state,
- );
- await persistOAuthTokens(state, configuration, tokens);
- return clearOAuthCookie(
- NextResponse.json({ status: "connected", provider }),
- provider,
- );
- } catch (error) {
- return NextResponse.json(
- {
- error:
- error instanceof Error ? error.message : "OAuth completion failed.",
- },
- { status: 400 },
- );
- }
-}
-
/**
* Cursor's `/complete`: takes a Cursor **user API key**, exchanges it for the
* same `{ accessToken, refreshToken }` pair as the browser login, and stores it
@@ -555,80 +441,4 @@ export async function pollDeviceOAuth(
}
}
-export async function finishOAuth(request: Request, provider: OAuthProvider) {
- const cookieStore = await cookies();
- const cookieName = oauthCookieName(provider);
- const stateCookie = cookieStore.get(cookieName)?.value;
- if (!stateCookie) return redirectToSettings(request, provider, "error");
- let state: OAuthState | null = null;
- try {
- state = openOAuthState(stateCookie);
- } catch {
- return redirectToSettings(request, provider, "error");
- }
- const returnTo = state.returnTo;
- const query = new URL(request.url).searchParams;
- if (query.get("error")) {
- return clearOAuthCookie(
- redirectToSettings(request, provider, "denied", returnTo),
- provider,
- );
- }
-
- const code = query.get("code");
- const returnedState = query.get("state");
- if (!code || !returnedState) {
- return clearOAuthCookie(
- redirectToSettings(request, provider, "error", returnTo),
- provider,
- );
- }
-
- try {
- if (state.state !== returnedState) throw new Error("OAuth state mismatch.");
- const user = await getApiUser();
- if (!user || user.id !== state.userId)
- throw new Error("OAuth user mismatch.");
- if (state.scopeType === "WORKSPACE") {
- await requireOrganizationSettingsWrite(user.id, state.scopeId);
- }
- const configuration = getOAuthConfiguration(
- provider,
- new URL(request.url).origin,
- );
- const tokens = await exchangeOAuthCode(
- configuration,
- code,
- state.codeVerifier,
- state.state,
- );
- if (provider === "codex") {
- // Match the device-code path: Codex needs a `~/.codex/auth.json`, so
- // persist the hosted subscription rather than a bare OAUTH_TOKEN.
- await persistCodexSubscriptionFromOAuth({
- userId: user.id,
- scopeType: state.scopeType,
- scopeId: state.scopeId,
- tokens,
- });
- } else {
- await persistOAuthTokens(state, configuration, tokens);
- }
- return clearOAuthCookie(
- redirectToSettings(request, provider, "connected", returnTo),
- provider,
- );
- } catch (error) {
- return clearOAuthCookie(
- redirectToSettings(
- request,
- provider,
- error instanceof OAuthConfigurationError ? "not_configured" : "error",
- returnTo,
- ),
- provider,
- );
- }
-}
-
export { oauthCallbackPath };
diff --git a/apps/web/lib/providers/oauth.test.ts b/apps/web/lib/providers/oauth.test.ts
index dc5c66bdc..2ec29ef04 100644
--- a/apps/web/lib/providers/oauth.test.ts
+++ b/apps/web/lib/providers/oauth.test.ts
@@ -2,10 +2,8 @@ import { afterEach, describe, expect, it, vi } from "vitest";
import {
buildAuthorizationUrl,
- CLAUDE_MANUAL_REDIRECT_URI,
CODEX_DEVICE_REDIRECT_URI,
createOAuthState,
- DEFAULT_CLAUDE_OAUTH_CLIENT_ID,
DEFAULT_CODEX_OAUTH_CLIENT_ID,
exchangeCursorApiKey,
exchangeOAuthCode,
@@ -13,7 +11,6 @@ import {
getOAuthConfigurationStatus,
getOAuthFlowMode,
openOAuthState,
- parseManualAuthorizationCode,
pkceChallenge,
pollCursorLogin,
sealOAuthState,
@@ -27,40 +24,30 @@ afterEach(() => {
describe("provider OAuth", () => {
it("defaults to public CLI clients when env vars are unset", () => {
- vi.stubEnv("CLAUDE_OAUTH_CLIENT_ID", "");
vi.stubEnv("CODEX_OAUTH_CLIENT_ID", "");
- expect(getOAuthConfigurationStatus("claude")).toMatchObject({
- configured: true,
- flowMode: "manual_code",
- });
expect(getOAuthConfigurationStatus("codex")).toMatchObject({
configured: true,
flowMode: "device_code",
});
expect(
- getOAuthConfiguration("claude", "https://app.example.com").clientId,
- ).toBe(DEFAULT_CLAUDE_OAUTH_CLIENT_ID);
+ getOAuthConfiguration("codex", "https://app.example.com").clientId,
+ ).toBe(DEFAULT_CODEX_OAUTH_CLIENT_ID);
expect(
getOAuthConfiguration("codex", "https://app.example.com").redirectUri,
).toBe(CODEX_DEVICE_REDIRECT_URI);
});
it("uses app callback mode when a redirect URI override is set", () => {
- vi.stubEnv(
- "CLAUDE_OAUTH_REDIRECT_URI",
- "https://app.example.com/api/auth/oauth/claude/callback",
- );
vi.stubEnv(
"CODEX_OAUTH_REDIRECT_URI",
"https://app.example.com/api/auth/oauth/codex/callback",
);
- expect(getOAuthFlowMode("claude")).toBe("app_callback");
expect(getOAuthFlowMode("codex")).toBe("app_callback");
expect(
- getOAuthConfiguration("claude", "https://app.example.com").redirectUri,
- ).toBe("https://app.example.com/api/auth/oauth/claude/callback");
+ getOAuthConfiguration("codex", "https://app.example.com").redirectUri,
+ ).toBe("https://app.example.com/api/auth/oauth/codex/callback");
});
it("seals and validates the PKCE state payload", () => {
@@ -78,13 +65,8 @@ describe("provider OAuth", () => {
);
});
- it("builds Claude Code and Codex authorization requests with S256 PKCE", () => {
- vi.stubEnv("CLAUDE_OAUTH_CLIENT_ID", "claude-client");
+ it("builds Codex authorization requests with S256 PKCE", () => {
vi.stubEnv("CODEX_OAUTH_CLIENT_ID", "codex-client");
- vi.stubEnv(
- "CLAUDE_OAUTH_REDIRECT_URI",
- "https://app.example.com/api/auth/oauth/claude/callback",
- );
vi.stubEnv(
"CODEX_OAUTH_REDIRECT_URI",
"https://app.example.com/api/auth/oauth/codex/callback",
@@ -96,57 +78,22 @@ describe("provider OAuth", () => {
returnTo: "/settings",
});
- const claude = buildAuthorizationUrl(
- getOAuthConfiguration("claude", "https://app.example.com"),
- state,
- );
const codex = buildAuthorizationUrl(
getOAuthConfiguration("codex", "https://app.example.com"),
state,
);
- expect(claude.searchParams.get("code_challenge")).toBe(
+ expect(codex.searchParams.get("code_challenge")).toBe(
pkceChallenge(state.codeVerifier),
);
- expect(claude.searchParams.get("code_challenge_method")).toBe("S256");
- expect(claude.searchParams.get("code")).toBe("true");
- expect(claude.searchParams.get("redirect_uri")).toBe(
- "https://app.example.com/api/auth/oauth/claude/callback",
+ expect(codex.searchParams.get("code_challenge_method")).toBe("S256");
+ expect(codex.searchParams.get("redirect_uri")).toBe(
+ "https://app.example.com/api/auth/oauth/codex/callback",
);
expect(codex.searchParams.get("codex_cli_simplified_flow")).toBe("true");
expect(codex.searchParams.get("client_id")).toBe("codex-client");
});
- it("defaults Claude authorize requests to the manual Anthropic callback", () => {
- const state = createOAuthState({
- userId: "user-1",
- scopeType: "USER",
- scopeId: "user-1",
- returnTo: "/settings",
- });
- const claude = buildAuthorizationUrl(
- getOAuthConfiguration("claude", "https://app.example.com"),
- state,
- );
- expect(claude.searchParams.get("redirect_uri")).toBe(
- CLAUDE_MANUAL_REDIRECT_URI,
- );
- expect(claude.searchParams.get("client_id")).toBe(
- DEFAULT_CLAUDE_OAUTH_CLIENT_ID,
- );
- });
-
- it("parses pasted Claude authorization codes with optional state", () => {
- expect(parseManualAuthorizationCode("abc123")).toEqual({
- code: "abc123",
- returnedState: undefined,
- });
- expect(parseManualAuthorizationCode("abc123#state-value")).toEqual({
- code: "abc123",
- returnedState: "state-value",
- });
- });
-
it("exchanges a code without returning provider secrets to callers", async () => {
vi.stubEnv("CODEX_OAUTH_CLIENT_ID", "codex-client");
vi.stubEnv(
@@ -181,19 +128,15 @@ describe("provider OAuth", () => {
expect(tokens).not.toHaveProperty("clientSecret");
});
- it("posts Claude exchanges as JSON with the verified state", async () => {
+ it("posts the exchange as form encoding with the verified state", async () => {
const fetchMock = vi.fn(async () => ({
ok: true,
json: async () => ({ access_token: "access-token" }),
}));
vi.stubGlobal("fetch", fetchMock);
- const configuration = getOAuthConfiguration(
- "claude",
- "https://app.example.com",
- );
await exchangeOAuthCode(
- configuration,
+ getOAuthConfiguration("codex", "https://app.example.com"),
"authorization-code",
"code-verifier",
"state-value",
@@ -204,14 +147,15 @@ describe("provider OAuth", () => {
RequestInit,
];
expect((init.headers as Record)["content-type"]).toBe(
- "application/json",
+ "application/x-www-form-urlencoded",
);
- expect(JSON.parse(init.body as string)).toMatchObject({
+ expect(
+ Object.fromEntries(new URLSearchParams(init.body as string)),
+ ).toMatchObject({
grant_type: "authorization_code",
code: "authorization-code",
code_verifier: "code-verifier",
state: "state-value",
- redirect_uri: CLAUDE_MANUAL_REDIRECT_URI,
});
});
@@ -228,7 +172,7 @@ describe("provider OAuth", () => {
await expect(
exchangeOAuthCode(
- getOAuthConfiguration("claude", "https://app.example.com"),
+ getOAuthConfiguration("codex", "https://app.example.com"),
"authorization-code",
"code-verifier",
"state-value",
diff --git a/apps/web/lib/providers/oauth.ts b/apps/web/lib/providers/oauth.ts
index 91a16038d..cf50db80a 100644
--- a/apps/web/lib/providers/oauth.ts
+++ b/apps/web/lib/providers/oauth.ts
@@ -12,12 +12,8 @@ import type { AuthProvider, ScopeType } from "@codev/shared-types";
import { saveProviderCredential } from "./credentials";
-export type OAuthProvider = "claude" | "codex" | "cursor";
-export type OAuthFlowMode =
- | "app_callback"
- | "manual_code"
- | "device_code"
- | "cursor_deeplink";
+export type OAuthProvider = "codex" | "cursor";
+export type OAuthFlowMode = "app_callback" | "device_code" | "cursor_deeplink";
/**
* Cursor's CLI login, reproduced from `cursor-agent`'s own bundle
@@ -30,9 +26,6 @@ export type OAuthFlowMode =
export const CURSOR_LOGIN_URL_DEFAULT = "https://cursor.com/loginDeepControl";
export const CURSOR_API_BASE_URL_DEFAULT = "https://api2.cursor.sh";
-/** Public Claude Code PKCE client used by the official CLI. */
-export const DEFAULT_CLAUDE_OAUTH_CLIENT_ID =
- "9d1c250a-e61b-44d9-88ed-5944d1962f5e";
/**
* Public Codex CLI PKCE client used by the official CLI.
* This is used only by the legacy/test OAuth connection. Hosted cloud Codex
@@ -40,8 +33,6 @@ export const DEFAULT_CLAUDE_OAUTH_CLIENT_ID =
*/
export const DEFAULT_CODEX_OAUTH_CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann";
-export const CLAUDE_MANUAL_REDIRECT_URI =
- "https://platform.claude.com/oauth/code/callback";
export const CODEX_DEVICE_REDIRECT_URI =
"https://auth.openai.com/deviceauth/callback";
export const CODEX_DEVICE_VERIFICATION_URL =
@@ -183,19 +174,12 @@ function envOptional(name: string) {
}
function clientIdEnvName(provider: OAuthProvider) {
- return provider === "claude"
- ? "CLAUDE_OAUTH_CLIENT_ID"
- : provider === "codex"
- ? "CODEX_OAUTH_CLIENT_ID"
- : "CURSOR_OAUTH_CLIENT_ID";
+ return provider === "codex"
+ ? "CODEX_OAUTH_CLIENT_ID"
+ : "CURSOR_OAUTH_CLIENT_ID";
}
export function resolveOAuthClientId(provider: OAuthProvider) {
- if (provider === "claude") {
- return (
- envOptional("CLAUDE_OAUTH_CLIENT_ID") ?? DEFAULT_CLAUDE_OAUTH_CLIENT_ID
- );
- }
if (provider === "cursor") {
// Cursor's CLI login uses no client id; the poll id + PKCE verifier are
// the only secrets. Report a stable non-empty value so the "configured"
@@ -206,11 +190,6 @@ export function resolveOAuthClientId(provider: OAuthProvider) {
}
export function getOAuthFlowMode(provider: OAuthProvider): OAuthFlowMode {
- if (provider === "claude") {
- return envOptional("CLAUDE_OAUTH_REDIRECT_URI")
- ? "app_callback"
- : "manual_code";
- }
if (provider === "cursor") {
return "cursor_deeplink";
}
@@ -246,33 +225,6 @@ export function getOAuthConfiguration(
origin: string,
): OAuthConfiguration {
const flowMode = getOAuthFlowMode(provider);
- if (provider === "claude") {
- const clientId = resolveOAuthClientId(provider);
- return {
- provider: "anthropic",
- clientId,
- clientSecret: envOptional("CLAUDE_OAUTH_CLIENT_SECRET"),
- authorizeUrl: envUrl(
- "CLAUDE_OAUTH_AUTHORIZE_URL",
- "https://platform.claude.com/oauth/authorize",
- ),
- tokenUrl: envUrl(
- "CLAUDE_OAUTH_TOKEN_URL",
- "https://platform.claude.com/v1/oauth/token",
- ),
- scope: envUrl(
- "CLAUDE_OAUTH_SCOPE",
- "org:create_api_key user:profile user:inference",
- ),
- redirectUri: envUrl(
- "CLAUDE_OAUTH_REDIRECT_URI",
- flowMode === "manual_code"
- ? CLAUDE_MANUAL_REDIRECT_URI
- : `${origin}${oauthCallbackPath(provider)}`,
- ),
- flowMode,
- };
- }
if (provider === "cursor") {
return {
@@ -323,9 +275,6 @@ export function buildAuthorizationUrl(
url.searchParams.set("state", state.state);
url.searchParams.set("code_challenge", pkceChallenge(state.codeVerifier));
url.searchParams.set("code_challenge_method", "S256");
- if (configuration.provider === "anthropic") {
- url.searchParams.set("code", "true");
- }
if (configuration.provider === "openai") {
url.searchParams.set("codex_cli_simplified_flow", "true");
url.searchParams.set("id_token_add_organizations", "true");
@@ -333,21 +282,6 @@ export function buildAuthorizationUrl(
return url;
}
-export function parseManualAuthorizationCode(raw: string) {
- const trimmed = raw.trim();
- if (!trimmed) {
- throw new Error("Authorization code is required.");
- }
- const hashIndex = trimmed.indexOf("#");
- if (hashIndex >= 0) {
- return {
- code: trimmed.slice(0, hashIndex),
- returnedState: trimmed.slice(hashIndex + 1) || undefined,
- };
- }
- return { code: trimmed, returnedState: undefined };
-}
-
function expiresAtFrom(value: unknown) {
if (typeof value !== "number" || value <= 0) return undefined;
return new Date(Date.now() + value * 1_000);
@@ -375,20 +309,13 @@ export async function exchangeOAuthCode(
fields.client_secret = configuration.clientSecret;
}
- // Anthropic's `/v1/oauth/token` only accepts a JSON body and rejects the
- // form encoding the OAuth spec suggests with a bare 400.
- const useJson = configuration.provider === "anthropic";
const response = await fetch(configuration.tokenUrl, {
method: "POST",
headers: {
- "content-type": useJson
- ? "application/json"
- : "application/x-www-form-urlencoded",
+ "content-type": "application/x-www-form-urlencoded",
accept: "application/json",
},
- body: useJson
- ? JSON.stringify(fields)
- : new URLSearchParams(fields).toString(),
+ body: new URLSearchParams(fields).toString(),
cache: "no-store",
});
if (!response.ok) {
@@ -691,20 +618,4 @@ export async function persistCursorTokens(
});
}
-export async function persistOAuthTokens(
- state: OAuthState,
- configuration: OAuthConfiguration,
- tokens: Awaited>,
-) {
- await saveProviderCredential({
- scopeType: state.scopeType,
- scopeId: state.scopeId,
- provider: configuration.provider,
- credentialType: "OAUTH_TOKEN",
- accessToken: tokens.accessToken,
- refreshToken: tokens.refreshToken,
- expiresAt: tokens.expiresAt,
- });
-}
-
export { COOKIE_MAX_AGE_SECONDS, CURSOR_COOKIE_MAX_AGE_SECONDS };
diff --git a/apps/web/lib/providers/provider-connection-server.test.ts b/apps/web/lib/providers/provider-connection-server.test.ts
index e528c9482..2875cb0a2 100644
--- a/apps/web/lib/providers/provider-connection-server.test.ts
+++ b/apps/web/lib/providers/provider-connection-server.test.ts
@@ -119,6 +119,7 @@ describe("provider connection server", () => {
provenance: "browser",
enabledForRooms: true,
enabledForWorkspace: false,
+ allowInSharedWorkspaces: true,
},
{ provider: "cursor", status: "connected" },
],
diff --git a/apps/web/lib/providers/provider-connection-server.ts b/apps/web/lib/providers/provider-connection-server.ts
index f75a8efa1..18bdaac19 100644
--- a/apps/web/lib/providers/provider-connection-server.ts
+++ b/apps/web/lib/providers/provider-connection-server.ts
@@ -11,7 +11,6 @@ import {
saveOpenAICredential,
updateCredentialSurfaces,
type CredentialSurface,
- type CredentialSurfaces,
} from "./credentials";
import { isHostedClaudeConnectEnabled } from "./claude-connection-runner";
import { isHostedCodexSubscriptionEnabled } from "./hosted-codex-subscription-flag";
@@ -76,14 +75,14 @@ export async function loadProviderConnectionSnapshot(
getProviderCredentialStatus("USER", user.id, "cursor", "OAUTH_TOKEN"),
workspaceId
? getHostedCodexPublicStatus({
- scopeType: "ORGANIZATION",
+ scopeType: "WORKSPACE",
scopeId: workspaceId,
canManage: false,
})
: null,
workspaceId
? getClaudeCliTokenPublicStatus({
- scopeType: "ORGANIZATION",
+ scopeType: "WORKSPACE",
scopeId: workspaceId,
canManage: false,
})
@@ -111,8 +110,6 @@ export async function loadProviderConnectionSnapshot(
credentialType: "OAUTH_TOKEN",
lastFour: "Official runtime",
connectedVia: "browser",
- enabledForRooms: true,
- enabledForWorkspace: false,
}
: null,
cursor: cursorOAuth,
@@ -120,7 +117,9 @@ export async function loadProviderConnectionSnapshot(
claudeCliToken,
connectModes: {
codex: getOAuthFlowMode("codex"),
- claude: getOAuthFlowMode("claude"),
+ // Claude has no CoDev-run OAuth flow: the in-app button drives the
+ // official login runtime, and the fallback is `codev claude-auth`.
+ claude: "manual_code",
cursor: "cursor_deeplink",
},
hostedClaudeConnect: isHostedClaudeConnectEnabled(),
@@ -128,13 +127,10 @@ export async function loadProviderConnectionSnapshot(
...(workspaceId
? {
sharedWorkspaceLogin: {
- openai: Boolean(
- sharedCodex?.status === "connected" && sharedCodex.sharingEnabled,
- ),
- anthropic: Boolean(
- sharedClaude?.status === "connected" &&
- sharedClaude.sharingEnabled,
- ),
+ // A workspace-scoped login belongs to that workspace's members;
+ // there is no second sharing flag to consult any more.
+ openai: sharedCodex?.status === "connected",
+ anthropic: sharedClaude?.status === "connected",
},
}
: {}),
@@ -142,26 +138,24 @@ export async function loadProviderConnectionSnapshot(
}
/**
- * Save a pasted API key. `surface` is the settings section the member pasted
- * it in: a key connected there is enabled for that surface only, and the
- * member opts it into the other with a toggle. Omitted (legacy callers) means
- * both, matching how keys behaved before surfaces existed.
+ * Save a pasted API key.
+ *
+ * The settings section it was pasted in used to decide which surfaces the key
+ * was enabled for. It no longer does: where an API key can run is the
+ * registry's answer, and a key pasted in one section was never usable in the
+ * other anyway. The request may still carry `surface`; it is ignored.
*/
export async function savePersonalProviderConnection(
user: ConnectionUser,
provider: ProviderConnectionProvider,
apiKey: string,
- surface?: CredentialSurface,
): Promise {
- const enabledFor: CredentialSurfaces | undefined = surface
- ? { rooms: surface === "rooms", workspace: surface === "workspace" }
- : undefined;
if (provider === "openai") {
- await saveOpenAICredential(user.id, apiKey, enabledFor);
+ await saveOpenAICredential(user.id, apiKey);
} else if (provider === "cursor") {
- await saveCursorCredential(user.id, apiKey, enabledFor);
+ await saveCursorCredential(user.id, apiKey);
} else {
- await saveAnthropicCredential(user.id, apiKey, enabledFor);
+ await saveAnthropicCredential(user.id, apiKey);
}
return publicProviderConnectionPayload(
await loadProviderConnectionSnapshot(user),
@@ -198,7 +192,12 @@ export type PersonalCredentialKind =
| "subscription"
| "claude_cli_token";
-/** Map a settings-page surface toggle onto the concrete row it flips. */
+/**
+ * Flip whether a credential may fund a turn inside a shared workspace — the
+ * member's one remaining per-credential choice. `surface` is accepted for the
+ * existing route shape; only the workspace setting is stored, because rooms
+ * always run on the member's own credential in their own session.
+ */
export async function setPersonalCredentialSurface(
user: ConnectionUser,
input: {
@@ -208,6 +207,12 @@ export async function setPersonalCredentialSurface(
enabled: boolean;
},
): Promise {
+ if (input.surface === "rooms") {
+ // Nothing to store: a room reply always runs on the sender's own login.
+ return publicProviderConnectionPayload(
+ await loadProviderConnectionSnapshot(user),
+ );
+ }
let credentialType: CredentialType;
if (input.kind === "api_key") {
credentialType = "API_KEY";
@@ -230,9 +235,7 @@ export async function setPersonalCredentialSurface(
user.id,
input.provider,
credentialType,
- {
- [input.surface]: input.enabled,
- },
+ input.enabled,
);
return publicProviderConnectionPayload(
await loadProviderConnectionSnapshot(user),
diff --git a/apps/web/lib/providers/provider-connection-view.test.ts b/apps/web/lib/providers/provider-connection-view.test.ts
index 17ddf5ad3..f6ba17668 100644
--- a/apps/web/lib/providers/provider-connection-view.test.ts
+++ b/apps/web/lib/providers/provider-connection-view.test.ts
@@ -32,8 +32,11 @@ describe("provider connection view", () => {
suppliedBy: "CoDev Test Jordan",
scope: "personal",
provenance: "api_key",
- enabledForRooms: true,
+ // An API key is a workspace credential: the rooms executor has no
+ // API-key path, so the registry reports it as workspace-only.
+ enabledForRooms: false,
enabledForWorkspace: true,
+ allowInSharedWorkspaces: true,
});
expect(secretKeysInValue(connection)).toEqual([]);
expect(JSON.stringify(connection)).not.toMatch(/sk-live|ciphertext/i);
diff --git a/apps/web/lib/providers/provider-connection-view.ts b/apps/web/lib/providers/provider-connection-view.ts
index 6b08c6a83..afab12600 100644
--- a/apps/web/lib/providers/provider-connection-view.ts
+++ b/apps/web/lib/providers/provider-connection-view.ts
@@ -1,5 +1,25 @@
+import {
+ providerDefinition,
+ type CredentialKind,
+ type ProviderId,
+} from "./registry";
+
export type ProviderConnectionProvider = "openai" | "anthropic" | "cursor";
+/** The vendor names this view uses, mapped onto registry provider ids. */
+const VENDOR_PROVIDER: Record = {
+ openai: "codex",
+ anthropic: "claude",
+ cursor: "cursor",
+};
+
+/** The subscription-shaped credential each provider's card represents. */
+const SUBSCRIPTION_KIND: Record = {
+ codex: "codex_auth_cache",
+ claude: "claude_runtime",
+ cursor: "cursor_tokens",
+};
+
export type ProviderConnectionStatus = "connected" | "not_connected";
export type ProviderConnectionCredentialType = "API_KEY" | "OAUTH_TOKEN";
@@ -13,8 +33,13 @@ export type CredentialProvenance = "browser" | "cli" | "api_key";
/** Per-surface applicability a member toggles; the isolation + opt-in model. */
export type ProviderSurfaceFlags = {
+ /** Where this credential *can* run — the registry's answer, not a stored
+ * preference. Read-only as far as the member is concerned. */
enabledForRooms: boolean;
enabledForWorkspace: boolean;
+ /** The member's one stored choice: whether it may fund a turn inside a
+ * workspace other people can see. */
+ allowInSharedWorkspaces: boolean;
};
export type ProviderConnectionRecord = ProviderSurfaceFlags & {
@@ -116,7 +141,7 @@ export function toCliSubscriptionRecords(
connectMode: connectModes[provider] ?? connectMode,
command,
provenance: provenance === "api_key" ? null : provenance,
- ...surfaceFlags(status),
+ ...surfaceFlags(status, provider, SUBSCRIPTION_KIND[provider]),
};
});
}
@@ -127,7 +152,7 @@ export function toClaudeCliTokenRecord(
return {
status: status ? "connected" : "not_connected",
lastFour: status?.lastFour?.trim() || null,
- ...surfaceFlags(status),
+ ...surfaceFlags(status, "claude", "claude_setup_token"),
};
}
@@ -151,9 +176,7 @@ export type ProviderCredentialStatus = {
credentialType?: string | null | undefined;
lastFour?: string | null | undefined;
connectedVia?: CredentialProvenance | null | undefined;
- enabledForRooms?: boolean | undefined;
- enabledForWorkspace?: boolean | undefined;
- sharingEnabled?: boolean | undefined;
+ allowInSharedWorkspaces?: boolean | undefined;
encryptedApiKey?: string | null | undefined;
encryptedAccessToken?: string | null | undefined;
encryptedRefreshToken?: string | null | undefined;
@@ -209,15 +232,31 @@ function publicProvenance(
return null;
}
-/** A disconnected credential is enabled nowhere; a connected one defaults to
- * both surfaces when the row predates the per-surface flags. */
+/**
+ * Where a connected credential can run. These are no longer stored per row:
+ * the provider registry decides, because it is a property of the credential
+ * kind and not of the member's preferences. A disconnected credential runs
+ * nowhere.
+ */
function surfaceFlags(
status: ProviderCredentialStatus | null,
+ provider: ProviderId,
+ kind: CredentialKind,
): ProviderSurfaceFlags {
- if (!status) return { enabledForRooms: false, enabledForWorkspace: false };
+ if (!status) {
+ return {
+ enabledForRooms: false,
+ enabledForWorkspace: false,
+ allowInSharedWorkspaces: false,
+ };
+ }
+ const entry = providerDefinition(provider).kinds.find(
+ (candidate) => candidate.kind === kind,
+ );
return {
- enabledForRooms: status.enabledForRooms ?? true,
- enabledForWorkspace: status.enabledForWorkspace ?? true,
+ enabledForRooms: entry?.runs.rooms ?? false,
+ enabledForWorkspace: entry?.runs.workspace ?? false,
+ allowInSharedWorkspaces: status.allowInSharedWorkspaces ?? true,
};
}
@@ -239,7 +278,11 @@ export function toProviderConnectionRecord(input: {
suppliedBy: connected ? input.suppliedBy : null,
scope: "personal",
provenance: connected ? "api_key" : null,
- ...surfaceFlags(connected ? input.status : null),
+ ...surfaceFlags(
+ connected ? input.status : null,
+ VENDOR_PROVIDER[input.provider],
+ "api_key",
+ ),
};
}
diff --git a/apps/web/lib/providers/provider-surface-capability.test.ts b/apps/web/lib/providers/provider-surface-capability.test.ts
index e93876629..e9a1995f7 100644
--- a/apps/web/lib/providers/provider-surface-capability.test.ts
+++ b/apps/web/lib/providers/provider-surface-capability.test.ts
@@ -17,6 +17,7 @@ const OFF: ClaudeCliTokenRecord = {
lastFour: null,
enabledForRooms: false,
enabledForWorkspace: false,
+ allowInSharedWorkspaces: true,
};
function key(
@@ -34,6 +35,7 @@ function key(
provenance: "api_key",
enabledForRooms: true,
enabledForWorkspace: true,
+ allowInSharedWorkspaces: true,
...overrides,
};
}
@@ -51,6 +53,7 @@ function sub(
provenance: "browser",
enabledForRooms: true,
enabledForWorkspace: true,
+ allowInSharedWorkspaces: true,
...overrides,
};
}
@@ -83,18 +86,24 @@ describe("providerSurfaceCapability", () => {
});
});
- it("Claude and Cursor browser subscriptions power rooms only", () => {
+ it("the Claude browser runtime powers rooms only", () => {
const view = snapshot({
- cliSubscriptions: [
- sub("claude", { provenance: "browser", enabledForWorkspace: false }),
- sub("cursor", { provenance: "browser" }),
- ],
+ cliSubscriptions: [sub("claude", { provenance: "browser" })],
+ });
+ const capability = providerSurfaceCapability(view, "anthropic");
+ expect(capability.rooms).toEqual({ ready: true, via: ["browser"] });
+ expect(capability.workspace.ready).toBe(false);
+ });
+
+ it("a Cursor login powers workspaces only", () => {
+ // Rooms run Claude and Codex; `roomReplyOptions` has never offered
+ // Cursor, though the old capability table reported it as rooms-ready.
+ const view = snapshot({
+ cliSubscriptions: [sub("cursor", { provenance: "browser" })],
});
- for (const provider of ["anthropic", "cursor"] as const) {
- const capability = providerSurfaceCapability(view, provider);
- expect(capability.rooms).toEqual({ ready: true, via: ["browser"] });
- expect(capability.workspace.ready).toBe(false);
- }
+ const capability = providerSurfaceCapability(view, "cursor");
+ expect(capability.rooms.ready).toBe(false);
+ expect(capability.workspace.ready).toBe(true);
});
it("a local-CLI Codex login powers both surfaces", () => {
@@ -132,6 +141,7 @@ describe("providerSurfaceCapability", () => {
lastFour: "wxyz",
enabledForRooms: false,
enabledForWorkspace: true,
+ allowInSharedWorkspaces: true,
},
});
const capability = providerSurfaceCapability(view, "anthropic");
@@ -143,18 +153,34 @@ describe("providerSurfaceCapability", () => {
});
});
- it("honours the member's per-surface toggles", () => {
+ it("does not report rooms readiness from the Claude setup-token alone", () => {
+ // The rooms executor resolves Claude only through the browser runtime, so
+ // a member whose sole Claude login is `codev claude-auth` must not be told
+ // rooms are ready — every reply would fail with "Reconnect Claude".
const view = snapshot({
- connections: [key("openai", { enabledForWorkspace: false })],
- cliSubscriptions: [
- sub("codex", { provenance: "cli", enabledForRooms: false }),
- ],
+ cliSubscriptions: [sub("claude", { status: "not_connected" })],
+ claudeCliToken: {
+ status: "connected",
+ lastFour: "wxyz",
+ enabledForRooms: true,
+ enabledForWorkspace: true,
+ allowInSharedWorkspaces: true,
+ },
});
+ const capability = providerSurfaceCapability(view, "anthropic");
+ expect(capability.rooms).toEqual({ ready: false, via: [] });
+ expect(capability.workspace.ready).toBe(true);
+ });
+
+ it("an API key alone cannot answer in chat rooms", () => {
+ // The rooms executor runs only the subscription forms, so a key is a
+ // workspace credential no matter which settings section it was pasted in.
+ const view = snapshot({ connections: [key("openai")] });
const capability = providerSurfaceCapability(view, "openai");
expect(capability.rooms.ready).toBe(false);
expect(capability.workspace).toEqual({
ready: true,
- via: ["cli"],
+ via: ["api_key"],
source: "personal",
});
});
@@ -207,6 +233,7 @@ describe("workspaceReadyProviders", () => {
lastFour: "wxyz",
enabledForRooms: false,
enabledForWorkspace: true,
+ allowInSharedWorkspaces: true,
},
});
expect(workspaceReadyProviders(view)).toEqual(["anthropic", "openai"]);
diff --git a/apps/web/lib/providers/provider-surface-capability.ts b/apps/web/lib/providers/provider-surface-capability.ts
index 825578501..08f32a2e3 100644
--- a/apps/web/lib/providers/provider-surface-capability.ts
+++ b/apps/web/lib/providers/provider-surface-capability.ts
@@ -1,3 +1,9 @@
+import {
+ providerDefinition,
+ type CredentialKind,
+ type ExecutorSurface,
+ type ProviderId,
+} from "./registry";
import type {
CredentialProvenance,
ProviderConnectionProvider,
@@ -5,26 +11,37 @@ import type {
} from "./provider-connection-view";
/**
- * Per-provider, per-surface readiness — the single source of truth the
- * workspace page, both settings sections, and the workspace-start preflight
- * read. Derived purely from the connection snapshot.
+ * Per-provider, per-surface readiness for the settings and workspace UIs.
*
- * The rule, uniform across providers:
- * - A coding workspace runs on a shared host, so it may use a credential only
- * when the member enabled it there. Codex browser OAuth is workspace-capable
- * because it yields the same auth cache as `codex login`; other browser
- * subscription runtimes remain rooms-only.
- * - A chat room runs on the member's own credential, so it accepts a browser
- * or local-CLI subscription the member enabled for rooms.
- *
- * `ROOMS_ACCEPT_API_KEY` is off: the rooms executor (shared-chat-reply)
- * currently runs only the two subscription forms. Flip it once the executor
- * can run an API key so the settings copy and this table stay truthful.
+ * This used to be a hand-written table of per-provider exceptions, kept in
+ * step with the resolvers by hand and losing that race — a Claude
+ * setup-token was reported ready for chat rooms that could not run it. It is
+ * now a projection of the provider registry: which kinds the member has
+ * connected, intersected with the kinds each executor can run. The server
+ * resolves turns by walking the same table (`resolve.ts`), so the badge and
+ * the executor cannot disagree.
*/
-const ROOMS_ACCEPT_API_KEY = false;
export type ProviderSurface = "rooms" | "workspace";
+/** Which registry credential kind each connected slot in the snapshot is. */
+const SUBSCRIPTION_KIND: Record = {
+ codex: "codex_auth_cache",
+ claude: "claude_runtime",
+ cursor: "cursor_tokens",
+};
+
+const PROVIDER_FOR_VENDOR: Record = {
+ openai: "codex",
+ anthropic: "claude",
+ cursor: "cursor",
+};
+
+const VENDOR_SUBSCRIPTION: Record<
+ ProviderConnectionProvider,
+ "codex" | "claude" | "cursor"
+> = { openai: "codex", anthropic: "claude", cursor: "cursor" };
+
export type SurfaceReadiness = {
ready: boolean;
/** The connected methods that make this surface ready, for the UI. */
@@ -40,53 +57,61 @@ export type ProviderSurfaceCapability = Record<
SurfaceReadiness
>;
-const SUBSCRIPTION_FOR: Record<
- ProviderConnectionProvider,
- "codex" | "claude" | "cursor"
-> = { openai: "codex", anthropic: "claude", cursor: "cursor" };
-
-function readiness(via: CredentialProvenance[]): SurfaceReadiness {
- return { ready: via.length > 0, via };
-}
+/** How each credential kind is described to a member. */
+const KIND_PROVENANCE: Record = {
+ codex_auth_cache: "cli",
+ claude_setup_token: "cli",
+ claude_runtime: "browser",
+ cursor_tokens: "browser",
+ api_key: "api_key",
+};
-export function providerSurfaceCapability(
+/** The credential kinds this member has connected for a provider, read off
+ * the snapshot the settings page already loads. */
+function connectedKinds(
snapshot: ProviderConnectionSnapshot,
- provider: ProviderConnectionProvider,
-): ProviderSurfaceCapability {
- const apiKey = snapshot.connections.find((row) => row.provider === provider);
+ vendor: ProviderConnectionProvider,
+): Map {
+ const provider = PROVIDER_FOR_VENDOR[vendor];
+ const connected = new Map();
+
const subscription = snapshot.cliSubscriptions.find(
- (row) => row.provider === SUBSCRIPTION_FOR[provider],
+ (row) => row.provider === VENDOR_SUBSCRIPTION[vendor],
);
- const keyConnected = apiKey?.status === "connected";
- const subConnected = subscription?.status === "connected";
- // Claude's CLI setup-token is a second, workspace-capable login kept in its
- // own slot; the browser runtime in `cliSubscriptions` is rooms-only.
- const claudeCli =
- provider === "anthropic" && snapshot.claudeCliToken.status === "connected"
- ? snapshot.claudeCliToken
- : null;
-
- const rooms: CredentialProvenance[] = [];
- if (subConnected && subscription.enabledForRooms && subscription.provenance) {
- rooms.push(subscription.provenance);
+ if (subscription?.status === "connected") {
+ connected.set(
+ SUBSCRIPTION_KIND[provider],
+ subscription.provenance ?? KIND_PROVENANCE[SUBSCRIPTION_KIND[provider]],
+ );
}
- if (claudeCli?.enabledForRooms) rooms.push("cli");
- if (ROOMS_ACCEPT_API_KEY && keyConnected && apiKey.enabledForRooms) {
- rooms.push("api_key");
+ if (provider === "claude" && snapshot.claudeCliToken.status === "connected") {
+ connected.set("claude_setup_token", "cli");
}
+ const apiKey = snapshot.connections.find((row) => row.provider === vendor);
+ if (apiKey?.status === "connected") connected.set("api_key", "api_key");
- const personalWorkspace: CredentialProvenance[] = [];
- if (keyConnected && apiKey.enabledForWorkspace) {
- personalWorkspace.push("api_key");
- }
- if (
- subConnected &&
- subscription.enabledForWorkspace &&
- (subscription.provenance === "cli" || provider === "openai")
- ) {
- personalWorkspace.push(subscription.provenance ?? "cli");
- }
- if (claudeCli?.enabledForWorkspace) personalWorkspace.push("cli");
+ return connected;
+}
+
+function readinessFor(
+ connected: Map,
+ provider: ProviderId,
+ surface: ExecutorSurface,
+): SurfaceReadiness {
+ const via = providerDefinition(provider)
+ .kinds.filter((entry) => entry.runs[surface] && connected.has(entry.kind))
+ .map((entry) => connected.get(entry.kind)!);
+ return { ready: via.length > 0, via: [...new Set(via)] };
+}
+
+export function providerSurfaceCapability(
+ snapshot: ProviderConnectionSnapshot,
+ vendor: ProviderConnectionProvider,
+): ProviderSurfaceCapability {
+ const provider = PROVIDER_FOR_VENDOR[vendor];
+ const connected = connectedKinds(snapshot, vendor);
+ const rooms = readinessFor(connected, provider, "rooms");
+ const personalWorkspace = readinessFor(connected, provider, "workspace");
// No personal login for this workspace's host — fall back to the
// workspace's own shared (`--org`) login, if one is connected and shared.
@@ -94,20 +119,16 @@ export function providerSurfaceCapability(
// given and the viewer reached this workspace (so membership already holds).
// Cursor has no shared-login concept, so it is never a valid key here.
const sharedWorkspace =
- (provider === "anthropic" || provider === "openai") &&
- Boolean(snapshot.sharedWorkspaceLogin?.[provider]);
+ (vendor === "anthropic" || vendor === "openai") &&
+ Boolean(snapshot.sharedWorkspaceLogin?.[vendor]);
- const workspace: SurfaceReadiness =
- personalWorkspace.length > 0
- ? { ...readiness([...new Set(personalWorkspace)]), source: "personal" }
- : sharedWorkspace
- ? { ready: true, via: ["cli"], source: "shared" }
- : readiness([]);
+ const workspace: SurfaceReadiness = personalWorkspace.ready
+ ? { ...personalWorkspace, source: "personal" }
+ : sharedWorkspace
+ ? { ready: true, via: ["cli"], source: "shared" }
+ : personalWorkspace;
- return {
- rooms: readiness([...new Set(rooms)]),
- workspace,
- };
+ return { rooms, workspace };
}
/** Providers the coding workspace can actually run, in preference order. */
diff --git a/apps/web/lib/providers/refresh-workspace-provider-preflight.test.ts b/apps/web/lib/providers/refresh-workspace-provider-preflight.test.ts
index f7c0c2a23..629068894 100644
--- a/apps/web/lib/providers/refresh-workspace-provider-preflight.test.ts
+++ b/apps/web/lib/providers/refresh-workspace-provider-preflight.test.ts
@@ -21,6 +21,7 @@ describe("workspaceProviderPreflightFromPayload", () => {
lastFour: null,
enabledForRooms: false,
enabledForWorkspace: false,
+ allowInSharedWorkspaces: true,
},
hostedClaudeConnect: false,
hostedOpenAIConnect: false,
@@ -53,6 +54,7 @@ describe("refreshWorkspaceProviderPreflight", () => {
provenance: "api_key",
enabledForRooms: false,
enabledForWorkspace: true,
+ allowInSharedWorkspaces: true,
},
],
cliSubscriptions: [],
@@ -61,6 +63,7 @@ describe("refreshWorkspaceProviderPreflight", () => {
lastFour: null,
enabledForRooms: false,
enabledForWorkspace: false,
+ allowInSharedWorkspaces: true,
},
hostedClaudeConnect: false,
hostedOpenAIConnect: false,
diff --git a/apps/web/lib/providers/registry.test.ts b/apps/web/lib/providers/registry.test.ts
new file mode 100644
index 000000000..ec9da2c78
--- /dev/null
+++ b/apps/web/lib/providers/registry.test.ts
@@ -0,0 +1,108 @@
+import { describe, expect, it } from "vitest";
+
+import {
+ PROVIDER_IDS,
+ launchProfileFor,
+ providerDefinition,
+ providerRunsOn,
+ runnableKinds,
+ type ExecutorSurface,
+} from "./registry";
+
+describe("provider registry", () => {
+ it("is the only place that decides where a credential can run", () => {
+ // Codex is the exception that used to be hard-coded in four files: its
+ // browser sign-in yields the same auth cache as `codex login`, so it is
+ // the one browser credential a shared host may use.
+ expect(runnableKinds("codex", "gen2").map((entry) => entry.kind)).toEqual([
+ "codex_auth_cache",
+ "api_key",
+ ]);
+ expect(runnableKinds("claude", "rooms").map((entry) => entry.kind)).toEqual(
+ ["claude_runtime"],
+ );
+ // The setup-token is workspace-only. Reporting it as a rooms credential
+ // is exactly the bug this registry replaced.
+ expect(runnableKinds("claude", "rooms")).not.toContainEqual(
+ expect.objectContaining({ kind: "claude_setup_token" }),
+ );
+ expect(
+ runnableKinds("claude", "workspace").map((entry) => entry.kind),
+ ).toEqual(["claude_setup_token", "api_key"]);
+ });
+
+ it("knows which providers an executor supports at all", () => {
+ expect(providerRunsOn("codex", "gen2")).toBe(true);
+ // Gen 2 cannot hand a process an environment variable yet, which is the
+ // only reason Claude does not run there; flipping it is a registry edit.
+ expect(providerRunsOn("claude", "gen2")).toBe(false);
+ expect(providerRunsOn("cursor", "rooms")).toBe(false);
+ });
+
+ it("gives every provider at least one place to run", () => {
+ const surfaces: ExecutorSurface[] = ["rooms", "workspace", "gen2"];
+ for (const provider of PROVIDER_IDS) {
+ expect(
+ surfaces.some((surface) => providerRunsOn(provider, surface)),
+ ).toBe(true);
+ }
+ });
+
+ it("turns a credential into what a machine needs, per vendor", () => {
+ expect(
+ launchProfileFor("codex", {
+ kind: "codex_auth_cache",
+ authCacheJson: '{"auth_mode":"chatgpt"}',
+ }),
+ ).toEqual({
+ files: [
+ { path: ".codex/auth.json", contents: '{"auth_mode":"chatgpt"}' },
+ ],
+ // The guest expands this to the profile directory it created, which
+ // is how the caller names CODEX_HOME without knowing the path.
+ env: { CODEX_HOME: "{{profileDir}}/.codex" },
+ });
+
+ expect(
+ launchProfileFor("claude", {
+ kind: "claude_setup_token",
+ token: "sk-ant-oat01-x",
+ }),
+ ).toEqual({ env: { CLAUDE_CODE_OAUTH_TOKEN: "sk-ant-oat01-x" } });
+
+ // Codex reads a file even for a bare key, so an API key does not become
+ // an OPENAI_API_KEY environment variable the CLI would ignore.
+ const codexKey = launchProfileFor("codex", {
+ kind: "api_key",
+ apiKey: "sk-test",
+ });
+ expect(codexKey.env).toEqual({ CODEX_HOME: "{{profileDir}}/.codex" });
+ expect(JSON.parse(codexKey.files![0]!.contents)).toMatchObject({
+ auth_mode: "apikey",
+ OPENAI_API_KEY: "sk-test",
+ });
+
+ expect(
+ launchProfileFor("claude", { kind: "api_key", apiKey: "sk-ant-test" }),
+ ).toEqual({ env: { ANTHROPIC_API_KEY: "sk-ant-test" } });
+ });
+
+ it("hands over nothing for the Claude browser runtime", () => {
+ // Its credential is a logged-in profile inside a sandbox CoDev never
+ // holds, which is why it cannot reach any other host.
+ expect(
+ launchProfileFor("claude", {
+ kind: "claude_runtime",
+ connectionId: "connection-1",
+ }),
+ ).toEqual({});
+ });
+
+ it("lists every kind a provider owns, in resolution order", () => {
+ expect(providerDefinition("claude").kinds.map((k) => k.kind)).toEqual([
+ "claude_runtime",
+ "claude_setup_token",
+ "api_key",
+ ]);
+ });
+});
diff --git a/apps/web/lib/providers/registry.ts b/apps/web/lib/providers/registry.ts
new file mode 100644
index 000000000..51b17f647
--- /dev/null
+++ b/apps/web/lib/providers/registry.ts
@@ -0,0 +1,290 @@
+import type { AuthProvider } from "@codev/shared-types";
+
+/**
+ * The provider registry: one place that says what a credential *is*, where it
+ * can run, and what a machine needs on disk to use it.
+ *
+ * This exists because the same three questions used to be answered in four
+ * places that drifted apart — `surfacePredicates` in `credentials.ts`, the
+ * hand-written table in `provider-surface-capability.ts`, the ternaries in
+ * `provider-account-card.tsx`, and the `enabledFor` defaults each connect
+ * flow happened to pass. A member could be told an agent was ready on a
+ * surface whose executor could not run it, which is exactly what happened to
+ * the Claude setup-token in chat rooms.
+ *
+ * Adding a provider should be adding an entry here plus a loader in
+ * `resolve.ts` — not a new resolver, a new readiness shape, and a new column.
+ */
+
+/** A coding agent a member connects. Not the same as the credential's
+ * `provider` column, which is the vendor (`openai`, `anthropic`, `cursor`). */
+export type ProviderId = "codex" | "claude" | "cursor";
+
+/**
+ * The executors that can run a credential. `workspace` is the Gen 1 Orca IDE
+ * host and `gen2` the Firecracker instance: they are separate because they
+ * accept credentials differently. The Gen 1 host takes named per-provider
+ * fields (`StartIdeInput.claudeCodeOauthToken` and five siblings); the Gen 2
+ * guest exec route takes only `codexAuthCacheJson` and has no channel for an
+ * environment variable at all. Collapsing the two would re-create the lie
+ * this registry exists to prevent.
+ */
+export type ExecutorSurface = "rooms" | "workspace" | "gen2";
+
+export const EXECUTOR_SURFACES: readonly ExecutorSurface[] = [
+ "rooms",
+ "workspace",
+ "gen2",
+];
+
+/** How a member obtains a credential. */
+export type ConnectMethod = "browser" | "cli" | "paste";
+
+/**
+ * The concrete credential shapes CoDev holds. This is finer than "API key vs
+ * subscription" on purpose: Claude's two subscription logins are different
+ * credentials that run in different places, and calling them one thing is
+ * what produced the mismatch above.
+ */
+export type CredentialKind =
+ | "codex_auth_cache"
+ | "claude_setup_token"
+ | "claude_runtime"
+ | "cursor_tokens"
+ | "api_key";
+
+/** What a launched process needs in order to authenticate as the member.
+ * The neutral replacement for passing `codexAuthCacheJson` by name. */
+export type LaunchProfile = {
+ /** Written into the process's private profile directory, mode 0600.
+ * Paths are relative to it and may not escape it. */
+ files?: Array<{ path: string; contents: string }>;
+ /** Injected into the process environment; never onto the command line,
+ * where another member's shell could read it out of `ps`. A value may
+ * contain `{{profileDir}}`, which the guest expands to the directory it
+ * created — how a caller names `CODEX_HOME` without knowing the path. */
+ env?: Record;
+};
+
+/** The guest substitutes this for the profile directory it created; see
+ * `LaunchProfile` in `services/orchestrator/src/model.rs`. */
+export const PROFILE_DIR_TOKEN = "{{profileDir}}";
+
+/** A resolved credential's secret material, discriminated by kind. */
+export type ResolvedSecret =
+ | { kind: "codex_auth_cache"; authCacheJson: string }
+ | { kind: "claude_setup_token"; token: string }
+ /** The browser login runtime keeps its credential inside a Firecracker
+ * profile CoDev never holds; only the connection id identifies it. */
+ | { kind: "claude_runtime"; connectionId: string }
+ | { kind: "cursor_tokens"; accessToken: string; refreshToken: string }
+ | { kind: "api_key"; apiKey: string };
+
+export type ProviderCredentialKind = {
+ kind: CredentialKind;
+ label: string;
+ connect: readonly ConnectMethod[];
+ /** Which executors can actually run this credential today. */
+ runs: Readonly>;
+};
+
+export type ProviderDefinition = {
+ id: ProviderId;
+ label: string;
+ /** The vendor this provider's credentials are stored under. */
+ vendor: AuthProvider;
+ /** Credential kinds in resolution preference order. */
+ kinds: readonly ProviderCredentialKind[];
+};
+
+const CODEX: ProviderDefinition = {
+ id: "codex",
+ label: "Codex",
+ vendor: "openai",
+ kinds: [
+ {
+ kind: "codex_auth_cache",
+ label: "ChatGPT subscription",
+ // The browser device-code flow and `codev codex-auth` produce a
+ // byte-identical `auth.json` (see `codex-oauth-connection.ts`), so
+ // unlike every other browser sign-in this one does reach a shared host.
+ connect: ["browser", "cli"],
+ runs: { rooms: true, workspace: true, gen2: true },
+ },
+ {
+ kind: "api_key",
+ label: "OpenAI API key",
+ connect: ["paste"],
+ // Rooms run only the two subscription forms today; the rooms executor
+ // has no API-key path (`resolvePersonalChatSubscription`).
+ runs: { rooms: false, workspace: true, gen2: true },
+ },
+ ],
+};
+
+const CLAUDE: ProviderDefinition = {
+ id: "claude",
+ label: "Claude",
+ vendor: "anthropic",
+ kinds: [
+ {
+ kind: "claude_runtime",
+ label: "Claude subscription",
+ connect: ["browser"],
+ // Rooms-only by construction: the credential is a logged-in profile
+ // inside a per-member Firecracker snapshot, so there is nothing to hand
+ // to another host. Retired in a later step, which is what lets the
+ // setup-token below become this provider's single login.
+ runs: { rooms: true, workspace: false, gen2: false },
+ },
+ {
+ kind: "claude_setup_token",
+ label: "Claude Code setup-token",
+ connect: ["cli"],
+ // `gen2` is false only because the Gen 2 guest cannot yet be handed an
+ // environment variable — see `LaunchProfile`. Flip it with the guest
+ // change, not by adding a second resolver.
+ runs: { rooms: false, workspace: true, gen2: false },
+ },
+ {
+ kind: "api_key",
+ label: "Anthropic API key",
+ connect: ["paste"],
+ runs: { rooms: false, workspace: true, gen2: false },
+ },
+ ],
+};
+
+const CURSOR: ProviderDefinition = {
+ id: "cursor",
+ label: "Cursor",
+ vendor: "cursor",
+ kinds: [
+ {
+ kind: "cursor_tokens",
+ label: "Cursor login",
+ connect: ["browser", "paste"],
+ runs: { rooms: false, workspace: true, gen2: false },
+ },
+ {
+ kind: "api_key",
+ label: "Cursor API key",
+ connect: ["paste"],
+ runs: { rooms: false, workspace: true, gen2: false },
+ },
+ ],
+};
+
+export const PROVIDERS: Readonly> = {
+ codex: CODEX,
+ claude: CLAUDE,
+ cursor: CURSOR,
+};
+
+export const PROVIDER_IDS: readonly ProviderId[] = [
+ "codex",
+ "claude",
+ "cursor",
+];
+
+export function providerDefinition(id: ProviderId): ProviderDefinition {
+ return PROVIDERS[id];
+}
+
+/** The vendor a provider's credentials are stored under. */
+export function providerVendor(id: ProviderId): AuthProvider {
+ return PROVIDERS[id].vendor;
+}
+
+/** The provider that owns a vendor's credentials, or null for a vendor no
+ * agent runs on (`bedrock`, `azure_foundry`). */
+export function providerForVendor(vendor: string): ProviderId | null {
+ return PROVIDER_IDS.find((id) => PROVIDERS[id].vendor === vendor) ?? null;
+}
+
+/** The kinds of this provider that the given executor can run, in
+ * preference order. */
+export function runnableKinds(
+ id: ProviderId,
+ surface: ExecutorSurface,
+): readonly ProviderCredentialKind[] {
+ return PROVIDERS[id].kinds.filter((entry) => entry.runs[surface]);
+}
+
+/** Whether any of this provider's kinds can run on the given executor. A
+ * provider with none is not "not connected" — it is unsupported there, and
+ * the member should be told that instead of being sent to connect again. */
+export function providerRunsOn(
+ id: ProviderId,
+ surface: ExecutorSurface,
+): boolean {
+ return runnableKinds(id, surface).length > 0;
+}
+
+/** The `auth.json` the Codex CLI writes for plain API-key auth. Codex reads a
+ * file, not `OPENAI_API_KEY`, so an API key reaches it the same way a
+ * subscription does. */
+export function codexApiKeyAuthCache(apiKey: string): string {
+ return JSON.stringify({
+ auth_mode: "apikey",
+ OPENAI_API_KEY: apiKey,
+ tokens: null,
+ last_refresh: new Date().toISOString(),
+ });
+}
+
+const API_KEY_ENV: Readonly> = {
+ codex: "OPENAI_API_KEY",
+ claude: "ANTHROPIC_API_KEY",
+ cursor: "CURSOR_API_KEY",
+};
+
+/**
+ * What a launched agent process needs in order to authenticate as the member.
+ *
+ * One exhaustive switch, so a new credential kind cannot be added without
+ * deciding how a machine consumes it. The provider is a parameter because the
+ * same kind lands differently per vendor: Codex wants an `auth.json` even for
+ * a bare key, while Claude and Cursor want an environment variable.
+ */
+export function launchProfileFor(
+ id: ProviderId,
+ secret: ResolvedSecret,
+): LaunchProfile {
+ switch (secret.kind) {
+ case "codex_auth_cache":
+ return {
+ files: [{ path: ".codex/auth.json", contents: secret.authCacheJson }],
+ env: { CODEX_HOME: `${PROFILE_DIR_TOKEN}/.codex` },
+ };
+ case "claude_setup_token":
+ return { env: { CLAUDE_CODE_OAUTH_TOKEN: secret.token } };
+ case "cursor_tokens":
+ return {
+ files: [
+ {
+ path: ".cursor/auth.json",
+ contents: JSON.stringify({
+ accessToken: secret.accessToken,
+ refreshToken: secret.refreshToken,
+ }),
+ },
+ ],
+ };
+ case "api_key":
+ return id === "codex"
+ ? {
+ files: [
+ {
+ path: ".codex/auth.json",
+ contents: codexApiKeyAuthCache(secret.apiKey),
+ },
+ ],
+ env: { CODEX_HOME: `${PROFILE_DIR_TOKEN}/.codex` },
+ }
+ : { env: { [API_KEY_ENV[id]]: secret.apiKey } };
+ case "claude_runtime":
+ // Nothing to hand over: the credential never leaves its own sandbox.
+ return {};
+ }
+}
diff --git a/apps/web/lib/providers/resolve.test.ts b/apps/web/lib/providers/resolve.test.ts
new file mode 100644
index 000000000..23e544171
--- /dev/null
+++ b/apps/web/lib/providers/resolve.test.ts
@@ -0,0 +1,201 @@
+import { beforeEach, describe, expect, it, vi } from "vitest";
+
+const mocks = vi.hoisted(() => ({
+ resolveHosted: vi.fn(),
+ decryptMaterial: vi.fn(),
+ decryptSecret: vi.fn(),
+ claudeRuntime: vi.fn(),
+ rows: [] as Array[]>,
+ belongs: vi.fn(),
+}));
+
+vi.mock("./hosted-codex-subscription-credentials", () => ({
+ resolveHostedCodexSubscription: (...args: unknown[]) =>
+ mocks.resolveHosted(...args),
+ decryptHostedMaterial: (...args: unknown[]) => mocks.decryptMaterial(...args),
+}));
+
+vi.mock("./claude-connection-session", () => ({
+ getConnectedClaudeRuntime: (...args: unknown[]) =>
+ mocks.claudeRuntime(...args),
+}));
+
+vi.mock("../platform/kms", () => ({
+ decryptSecret: (...args: unknown[]) => mocks.decryptSecret(...args),
+}));
+
+vi.mock("./scoped-credential-sharing", () => ({
+ belongsToSharedScope: (...args: unknown[]) => mocks.belongs(...args),
+}));
+
+vi.mock("../platform/database", () => {
+ const query = {
+ from: () => query,
+ where: () => query,
+ orderBy: () => query,
+ limit: async () => mocks.rows.shift() ?? [],
+ then: (resolve: (rows: unknown[]) => unknown) =>
+ resolve(mocks.rows.shift() ?? []),
+ };
+ return { getDatabase: () => ({ select: () => query }) };
+});
+
+const { providerReadiness, resolveCredential } = await import("./resolve");
+
+const userId = "user-1";
+
+describe("resolveCredential", () => {
+ beforeEach(() => {
+ vi.resetAllMocks();
+ mocks.rows.length = 0;
+ mocks.resolveHosted.mockResolvedValue(null);
+ mocks.claudeRuntime.mockResolvedValue(null);
+ mocks.belongs.mockResolvedValue(true);
+ });
+
+ it("says a credential is connected-but-unrunnable rather than missing", async () => {
+ // The member has Claude's browser runtime, which rooms can run and a
+ // coding workspace cannot. Telling them "not connected" would send them
+ // to connect a thing they already have.
+ mocks.claudeRuntime.mockResolvedValue({ id: "connection-1" });
+
+ const rooms = await resolveCredential({
+ userId,
+ provider: "claude",
+ surface: "rooms",
+ dryRun: true,
+ });
+ expect(rooms).toMatchObject({ ok: true, kind: "claude_runtime" });
+
+ const workspace = await resolveCredential({
+ userId,
+ provider: "claude",
+ surface: "workspace",
+ dryRun: true,
+ });
+ expect(workspace).toMatchObject({
+ ok: false,
+ reason: "unsupported_here",
+ connectedKinds: ["claude_runtime"],
+ });
+ });
+
+ it("reports nothing connected as not_connected", async () => {
+ const result = await resolveCredential({
+ userId,
+ provider: "codex",
+ surface: "gen2",
+ dryRun: true,
+ });
+ expect(result).toMatchObject({
+ ok: false,
+ reason: "not_connected",
+ connectedKinds: [],
+ });
+ });
+
+ it("honours the member's shared-workspace choice, and only there", async () => {
+ mocks.resolveHosted.mockResolvedValue({
+ source: "USER",
+ credential: {
+ id: "cred-1",
+ encryptedMaterial: "enc",
+ allowInSharedWorkspaces: false,
+ },
+ });
+
+ // This is the flag the old per-surface columns only pretended to be:
+ // every resolution path reads it, so turning it off actually stops a
+ // turn instead of changing a badge.
+ const gen2 = await resolveCredential({
+ userId,
+ provider: "codex",
+ surface: "gen2",
+ dryRun: true,
+ });
+ expect(gen2).toMatchObject({
+ ok: false,
+ reason: "not_allowed_in_shared_workspaces",
+ });
+
+ // A chat room is the member's own session, so it is never gated.
+ const rooms = await resolveCredential({
+ userId,
+ provider: "codex",
+ surface: "rooms",
+ dryRun: true,
+ });
+ expect(rooms).toMatchObject({ ok: true, kind: "codex_auth_cache" });
+ });
+
+ it("never reaches a shared credential without a workspace id", async () => {
+ mocks.resolveHosted.mockResolvedValue(null);
+ await resolveCredential({
+ userId,
+ provider: "codex",
+ surface: "gen2",
+ dryRun: true,
+ });
+ // Gen 2 bills the member who asked, so it passes no workspace id and the
+ // shared lookup cannot run.
+ expect(mocks.resolveHosted).toHaveBeenCalledWith(
+ expect.not.objectContaining({ workspaceId: expect.anything() }),
+ );
+ });
+
+ it("does not decrypt anything on a dry run", async () => {
+ mocks.resolveHosted.mockResolvedValue({
+ source: "USER",
+ credential: { id: "cred-1", encryptedMaterial: "enc" },
+ });
+ await resolveCredential({
+ userId,
+ provider: "codex",
+ surface: "rooms",
+ dryRun: true,
+ });
+ expect(mocks.decryptMaterial).not.toHaveBeenCalled();
+ });
+
+ it("decrypts only when a turn actually needs the secret", async () => {
+ mocks.resolveHosted.mockResolvedValue({
+ source: "USER",
+ credential: { id: "cred-1", encryptedMaterial: "enc" },
+ });
+ mocks.decryptMaterial.mockResolvedValue({ authCacheJson: '{"a":1}' });
+ const result = await resolveCredential({
+ userId,
+ provider: "codex",
+ surface: "rooms",
+ });
+ expect(result).toMatchObject({
+ ok: true,
+ secret: { kind: "codex_auth_cache", authCacheJson: '{"a":1}' },
+ });
+ });
+});
+
+describe("providerReadiness", () => {
+ beforeEach(() => {
+ vi.resetAllMocks();
+ mocks.rows.length = 0;
+ mocks.resolveHosted.mockResolvedValue(null);
+ mocks.claudeRuntime.mockResolvedValue(null);
+ mocks.belongs.mockResolvedValue(true);
+ });
+
+ it("answers for every provider and executor from the same walk a turn takes", async () => {
+ mocks.resolveHosted.mockResolvedValue({
+ source: "USER",
+ credential: { id: "cred-1", encryptedMaterial: "enc" },
+ });
+
+ const report = await providerReadiness(userId);
+
+ expect(report.codex.rooms.ready).toBe(true);
+ expect(report.codex.gen2.ready).toBe(true);
+ expect(report.claude.rooms.ready).toBe(false);
+ expect(report.cursor.rooms.ready).toBe(false);
+ expect(mocks.decryptMaterial).not.toHaveBeenCalled();
+ });
+});
diff --git a/apps/web/lib/providers/resolve.ts b/apps/web/lib/providers/resolve.ts
new file mode 100644
index 000000000..06f0bda13
--- /dev/null
+++ b/apps/web/lib/providers/resolve.ts
@@ -0,0 +1,473 @@
+import "server-only";
+
+import { and, eq } from "drizzle-orm";
+
+import { schema } from "@codev/db";
+
+import { getDatabase } from "../platform/database";
+import { decryptSecret } from "../platform/kms";
+import {
+ decryptHostedMaterial,
+ resolveHostedCodexSubscription,
+} from "./hosted-codex-subscription-credentials";
+import {
+ EXECUTOR_SURFACES,
+ PROVIDER_IDS,
+ providerDefinition,
+ providerVendor,
+ runnableKinds,
+ type CredentialKind,
+ type ExecutorSurface,
+ type ProviderId,
+ type ResolvedSecret,
+} from "./registry";
+import { belongsToSharedScope } from "./scoped-credential-sharing";
+
+/**
+ * The one credential resolver.
+ *
+ * It replaced three that disagreed: `resolveAgentCredential` (Gen 1),
+ * `resolvePersonalChatSubscription` (rooms), and `resolveGen2Codex` (Gen 2) —
+ * none of which consulted the capability table the settings page rendered
+ * from. Readiness is now literally this function with `dryRun`, so what a
+ * member is told and what the executor does cannot drift.
+ *
+ * Resolution order is the provider's own kind order from the registry,
+ * filtered to the kinds the target executor can run.
+ */
+
+export type ResolveInput = {
+ userId: string;
+ provider: ProviderId;
+ surface: ExecutorSurface;
+ /** Enables the workspace's shared login as a fallback, and is required for
+ * any shared lookup. Membership is verified before a shared row is used. */
+ workspaceId?: string | undefined;
+ /** Skip decryption — for readiness, which needs only "would this work". */
+ dryRun?: boolean | undefined;
+};
+
+export type CredentialSource = "personal" | "shared";
+
+export type ResolvedCredentialRecord = {
+ ok: true;
+ provider: ProviderId;
+ kind: CredentialKind;
+ source: CredentialSource;
+ /** Null for a credential with no row to lease (the browser runtime). */
+ credentialId: string | null;
+ /** Absent on a dry run. */
+ secret?: ResolvedSecret;
+};
+
+export type CredentialUnavailableReason =
+ /** Nothing connected for this provider at all. */
+ | "not_connected"
+ /** Connected, but no connected kind runs on this executor. */
+ | "unsupported_here"
+ /** Connected and runnable, but the member kept it out of shared workspaces. */
+ | "not_allowed_in_shared_workspaces";
+
+export type CredentialUnavailable = {
+ ok: false;
+ provider: ProviderId;
+ reason: CredentialUnavailableReason;
+ /** Everything the member has connected for this provider, whether or not
+ * it runs here — so the UI can say "connected for chat rooms only"
+ * instead of "not set up". */
+ connectedKinds: CredentialKind[];
+};
+
+export type ResolveResult = ResolvedCredentialRecord | CredentialUnavailable;
+
+type Loaded = {
+ credentialId: string | null;
+ source: CredentialSource;
+ /** Whether the member allows this credential inside a shared workspace. */
+ allowInSharedWorkspaces: boolean;
+ read: () => Promise;
+};
+
+/* -------------------------------------------------------------------------
+ * Loaders: one per credential kind. A new provider adds one of these and an
+ * entry in the registry — nothing else.
+ * ---------------------------------------------------------------------- */
+
+async function loadCodexAuthCache(input: ResolveInput): Promise {
+ const hosted = await resolveHostedCodexSubscription({
+ userId: input.userId,
+ ...(input.workspaceId ? { workspaceId: input.workspaceId } : {}),
+ });
+ if (!hosted?.credential.encryptedMaterial) return null;
+ const material = hosted.credential.encryptedMaterial;
+ return {
+ credentialId: hosted.credential.id,
+ source: hosted.source === "WORKSPACE" ? "shared" : "personal",
+ allowInSharedWorkspaces:
+ hosted.credential.allowInSharedWorkspaces !== false,
+ read: async () => {
+ const decrypted = await decryptHostedMaterial(material);
+ return decrypted.authCacheJson
+ ? { kind: "codex_auth_cache", authCacheJson: decrypted.authCacheJson }
+ : null;
+ },
+ };
+}
+
+type CredentialRow = typeof schema.providerCredentials.$inferSelect;
+
+async function findRow(
+ scopeType: "USER" | "WORKSPACE" | "WORKSPACE",
+ scopeId: string,
+ vendor: string,
+ credentialType: "API_KEY" | "OAUTH_TOKEN",
+): Promise {
+ const [row] = await getDatabase()
+ .select()
+ .from(schema.providerCredentials)
+ .where(
+ and(
+ eq(schema.providerCredentials.scopeType, scopeType),
+ eq(schema.providerCredentials.scopeId, scopeId),
+ eq(schema.providerCredentials.provider, vendor as never),
+ eq(schema.providerCredentials.credentialType, credentialType),
+ eq(schema.providerCredentials.isConnected, true),
+ eq(schema.providerCredentials.status, "active"),
+ ),
+ )
+ .limit(1);
+ return row ?? null;
+}
+
+/** Personal row wins; a shared one needs both its sharing flag and real
+ * membership. Mirrors `resolvePersonalOrSharedCredential`. */
+async function findPersonalOrShared(
+ input: ResolveInput,
+ vendor: string,
+ credentialType: "API_KEY" | "OAUTH_TOKEN",
+ accept: (row: CredentialRow) => boolean = () => true,
+): Promise<{ row: CredentialRow; source: CredentialSource } | null> {
+ const personal = await findRow("USER", input.userId, vendor, credentialType);
+ if (personal && accept(personal)) {
+ return { row: personal, source: "personal" };
+ }
+ if (!input.workspaceId) return null;
+ const shared = await findRow(
+ "WORKSPACE",
+ input.workspaceId,
+ vendor,
+ credentialType,
+ );
+ if (
+ shared &&
+ accept(shared) &&
+ (await belongsToSharedScope(input.userId, input.workspaceId))
+ ) {
+ return { row: shared, source: "shared" };
+ }
+ return null;
+}
+
+function loadedFromRow(
+ found: { row: CredentialRow; source: CredentialSource },
+ read: (row: CredentialRow) => Promise,
+): Loaded {
+ return {
+ credentialId: found.row.id,
+ source: found.source,
+ // NOT NULL default true in the schema; `!== false` keeps a row read
+ // through a partial projection from reading as "denied".
+ allowInSharedWorkspaces: found.row.allowInSharedWorkspaces !== false,
+ read: () => read(found.row),
+ };
+}
+
+async function loadClaudeSetupToken(
+ input: ResolveInput,
+): Promise {
+ // Only a CLI-stamped token is a setup-token; a browser-era Anthropic OAuth
+ // row is a retired credential that must never become an API bearer.
+ const found = await findPersonalOrShared(
+ input,
+ "anthropic",
+ "OAUTH_TOKEN",
+ (row) => row.connectedVia === "cli" && Boolean(row.encryptedAccessToken),
+ );
+ if (!found) return null;
+ return loadedFromRow(found, async (row) => {
+ const token = await decryptCredential(row.encryptedAccessToken);
+ return token ? { kind: "claude_setup_token", token } : null;
+ });
+}
+
+async function loadClaudeRuntime(input: ResolveInput): Promise {
+ const { getConnectedClaudeRuntime } =
+ await import("./claude-connection-session");
+ const connection = await getConnectedClaudeRuntime(input.userId);
+ if (!connection) return null;
+ return {
+ credentialId: connection.id,
+ source: "personal",
+ // The browser runtime is never shared, and its turns run inside the
+ // member's own sandbox, so there is nothing for this gate to protect.
+ allowInSharedWorkspaces: true,
+ read: async () => ({
+ kind: "claude_runtime",
+ connectionId: connection.id,
+ }),
+ };
+}
+
+async function loadCursorTokens(input: ResolveInput): Promise {
+ const found = await findPersonalOrShared(
+ input,
+ "cursor",
+ "OAUTH_TOKEN",
+ (row) => Boolean(row.encryptedAccessToken && row.encryptedRefreshToken),
+ );
+ if (!found) return null;
+ return loadedFromRow(found, async (row) => {
+ const [accessToken, refreshToken] = await Promise.all([
+ decryptCredential(row.encryptedAccessToken),
+ decryptCredential(row.encryptedRefreshToken),
+ ]);
+ return accessToken && refreshToken
+ ? { kind: "cursor_tokens", accessToken, refreshToken }
+ : null;
+ });
+}
+
+async function loadApiKey(input: ResolveInput): Promise {
+ const found = await findPersonalOrShared(
+ input,
+ providerVendor(input.provider),
+ "API_KEY",
+ (row) => Boolean(row.encryptedApiKey),
+ );
+ if (!found) return null;
+ return loadedFromRow(found, async (row) => {
+ const apiKey = await decryptCredential(row.encryptedApiKey);
+ return apiKey ? { kind: "api_key", apiKey } : null;
+ });
+}
+
+const CREDENTIAL_CONTEXT = {
+ application: "codev",
+ purpose: "provider-credential",
+};
+
+async function decryptCredential(encrypted: string | null) {
+ if (!encrypted) return null;
+ try {
+ return await decryptSecret(encrypted, CREDENTIAL_CONTEXT);
+ } catch {
+ // Rows written before the KMS migration bound an encryption context.
+ try {
+ return await decryptSecret(encrypted);
+ } catch {
+ return null;
+ }
+ }
+}
+
+const LOADERS: Record<
+ CredentialKind,
+ (input: ResolveInput) => Promise
+> = {
+ codex_auth_cache: loadCodexAuthCache,
+ claude_setup_token: loadClaudeSetupToken,
+ claude_runtime: loadClaudeRuntime,
+ cursor_tokens: loadCursorTokens,
+ api_key: loadApiKey,
+};
+
+/* ---------------------------------------------------------------------- */
+
+/** Every kind this member has connected for a provider, ignoring where it
+ * can run — the input to an honest "connected, but not here" message. The
+ * list comes from the registry so it cannot fall out of step with it. */
+async function connectedKinds(input: ResolveInput): Promise {
+ const found = await Promise.all(
+ providerDefinition(input.provider).kinds.map(async (entry) =>
+ (await LOADERS[entry.kind](input)) ? entry.kind : null,
+ ),
+ );
+ return found.filter((kind): kind is CredentialKind => kind !== null);
+}
+
+/**
+ * Resolve the credential a turn should run on, or say precisely why it
+ * cannot. Never throws for an absent credential: an executor turns the
+ * reason into its own message.
+ */
+export async function resolveCredential(
+ input: ResolveInput,
+): Promise {
+ const runnable = runnableKinds(input.provider, input.surface);
+ let blockedBySharing = false;
+
+ for (const entry of runnable) {
+ const loaded = await LOADERS[entry.kind](input);
+ if (!loaded) continue;
+ // The member's own credential funds the turn, so they decide whether it
+ // may be spent inside a workspace other people can see.
+ if (input.surface !== "rooms" && !loaded.allowInSharedWorkspaces) {
+ blockedBySharing = true;
+ continue;
+ }
+ if (input.dryRun) {
+ return {
+ ok: true,
+ provider: input.provider,
+ kind: entry.kind,
+ source: loaded.source,
+ credentialId: loaded.credentialId,
+ };
+ }
+ const secret = await loaded.read();
+ if (!secret) continue;
+ return {
+ ok: true,
+ provider: input.provider,
+ kind: entry.kind,
+ source: loaded.source,
+ credentialId: loaded.credentialId,
+ secret,
+ };
+ }
+
+ const connected = await connectedKinds(input);
+ return {
+ ok: false,
+ provider: input.provider,
+ reason: blockedBySharing
+ ? "not_allowed_in_shared_workspaces"
+ : connected.length > 0
+ ? "unsupported_here"
+ : "not_connected",
+ connectedKinds: connected,
+ };
+}
+
+/** `resolveCredential` for a turn that is about to run: the secret, or a
+ * thrown error carrying the member-facing reason. */
+export async function requireCredential(
+ input: Omit,
+): Promise {
+ const result = await resolveCredential(input);
+ if (!result.ok) throw new CredentialUnavailableError(result);
+ if (!result.secret) {
+ throw new CredentialUnavailableError({
+ ok: false,
+ provider: input.provider,
+ reason: "not_connected",
+ connectedKinds: [],
+ });
+ }
+ return result as ResolvedCredentialRecord & { secret: ResolvedSecret };
+}
+
+export class CredentialUnavailableError extends Error {
+ readonly status = 409;
+ readonly code = "provider_connection_required";
+ readonly reason: CredentialUnavailableReason;
+ readonly provider: ProviderId;
+ readonly connectedKinds: CredentialKind[];
+
+ constructor(unavailable: CredentialUnavailable) {
+ super(describeUnavailable(unavailable));
+ this.name = "CredentialUnavailableError";
+ this.reason = unavailable.reason;
+ this.provider = unavailable.provider;
+ this.connectedKinds = unavailable.connectedKinds;
+ }
+}
+
+const PROVIDER_LABEL: Record = {
+ codex: "Codex",
+ claude: "Claude",
+ cursor: "Cursor",
+};
+
+export function describeUnavailable(
+ unavailable: CredentialUnavailable,
+): string {
+ const label = PROVIDER_LABEL[unavailable.provider];
+ switch (unavailable.reason) {
+ case "not_connected":
+ return `Connect ${label} in Settings to run it here.`;
+ case "unsupported_here":
+ // Naming this case matters: the member *has* connected the agent and
+ // would read "not set up" as a bug.
+ return `Your ${label} connection cannot run here yet. Connect a login this surface supports in Settings.`;
+ case "not_allowed_in_shared_workspaces":
+ return `${label} is set to stay out of shared workspaces. Allow it in Settings to run it here.`;
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+export type ProviderReadiness = {
+ ready: boolean;
+ kind: CredentialKind | null;
+ source: CredentialSource | null;
+ reason: CredentialUnavailableReason | null;
+ connectedKinds: CredentialKind[];
+};
+
+export type ReadinessReport = Record<
+ ProviderId,
+ Record
+>;
+
+function toReadiness(result: ResolveResult): ProviderReadiness {
+ return result.ok
+ ? {
+ ready: true,
+ kind: result.kind,
+ source: result.source,
+ reason: null,
+ connectedKinds: [result.kind],
+ }
+ : {
+ ready: false,
+ kind: null,
+ source: null,
+ reason: result.reason,
+ connectedKinds: result.connectedKinds,
+ };
+}
+
+/**
+ * What every readiness surface renders from: the same walk a turn performs,
+ * without decrypting anything. There is no second table to keep in step.
+ */
+export async function providerReadiness(
+ userId: string,
+ workspaceId?: string,
+): Promise {
+ const entries = await Promise.all(
+ PROVIDER_IDS.map(async (provider) => {
+ const surfaces = await Promise.all(
+ EXECUTOR_SURFACES.map(async (surface) => {
+ const result = await resolveCredential({
+ userId,
+ provider,
+ surface,
+ ...(workspaceId ? { workspaceId } : {}),
+ dryRun: true,
+ });
+ return [surface, toReadiness(result)] as const;
+ }),
+ );
+ return [
+ provider,
+ Object.fromEntries(surfaces) as Record<
+ ExecutorSurface,
+ ProviderReadiness
+ >,
+ ] as const;
+ }),
+ );
+ return Object.fromEntries(entries) as ReadinessReport;
+}
diff --git a/apps/web/lib/providers/scoped-credential-sharing.test.ts b/apps/web/lib/providers/scoped-credential-sharing.test.ts
index 333c8dde3..661c75b10 100644
--- a/apps/web/lib/providers/scoped-credential-sharing.test.ts
+++ b/apps/web/lib/providers/scoped-credential-sharing.test.ts
@@ -15,19 +15,9 @@ vi.mock("../platform/database", () => ({
}),
}));
-import {
- defaultSharingEnabled,
- resolvePersonalOrSharedCredential,
-} from "./scoped-credential-sharing";
+import { resolvePersonalOrSharedCredential } from "./scoped-credential-sharing";
-describe("defaultSharingEnabled", () => {
- it("is true for an ORGANIZATION scope, false for USER", () => {
- expect(defaultSharingEnabled("ORGANIZATION")).toBe(true);
- expect(defaultSharingEnabled("USER")).toBe(false);
- });
-});
-
-type FixtureCredential = { id: string; sharingEnabled: boolean };
+type FixtureCredential = { id: string };
describe("resolvePersonalOrSharedCredential", () => {
beforeEach(() => mocks.belongs.mockReset());
@@ -36,50 +26,38 @@ describe("resolvePersonalOrSharedCredential", () => {
const result = await resolvePersonalOrSharedCredential(
{ userId: "u1", workspaceId: "w1" },
{
- findPersonal: async () => ({ id: "personal", sharingEnabled: false }),
- findShared: async () => ({ id: "shared", sharingEnabled: true }),
+ findPersonal: async () => ({ id: "personal" }),
+ findShared: async () => ({ id: "shared" }),
},
);
expect(result).toEqual({
- credential: { id: "personal", sharingEnabled: false },
+ credential: { id: "personal" },
source: "USER",
});
});
- it("falls back to the shared credential only when it is marked shared and the member belongs to that workspace", async () => {
+ it("falls back to the workspace's credential only for a member of that workspace", async () => {
mocks.belongs.mockReturnValue(true);
const result = await resolvePersonalOrSharedCredential(
{ userId: "u1", workspaceId: "w1" },
{
findPersonal: async () => null,
- findShared: async () => ({ id: "shared", sharingEnabled: true }),
+ findShared: async () => ({ id: "shared" }),
},
);
expect(result).toEqual({
- credential: { id: "shared", sharingEnabled: true },
- source: "ORGANIZATION",
+ credential: { id: "shared" },
+ source: "WORKSPACE",
});
});
- it("refuses a shared credential that was not marked shared, even for a member", async () => {
- mocks.belongs.mockReturnValue(true);
- const result = await resolvePersonalOrSharedCredential(
- { userId: "u1", workspaceId: "w1" },
- {
- findPersonal: async () => null,
- findShared: async () => ({ id: "shared", sharingEnabled: false }),
- },
- );
- expect(result).toBeNull();
- });
-
it("refuses a shared credential for someone who does not belong to that workspace", async () => {
mocks.belongs.mockReturnValue(false);
const result = await resolvePersonalOrSharedCredential(
{ userId: "outsider", workspaceId: "w1" },
{
findPersonal: async () => null,
- findShared: async () => ({ id: "shared", sharingEnabled: true }),
+ findShared: async () => ({ id: "shared" }),
},
);
expect(result).toBeNull();
diff --git a/apps/web/lib/providers/scoped-credential-sharing.ts b/apps/web/lib/providers/scoped-credential-sharing.ts
index 1b52ba033..9afd8ae01 100644
--- a/apps/web/lib/providers/scoped-credential-sharing.ts
+++ b/apps/web/lib/providers/scoped-credential-sharing.ts
@@ -7,23 +7,28 @@ import { schema } from "@codev/db";
import { getDatabase } from "../platform/database";
/**
- * The personal-vs-shared-workspace-login pattern, factored out so every
- * provider (Codex's hosted subscription, Claude's CLI setup-token, and
- * whatever comes next) resolves it identically instead of re-deriving it.
+ * The personal-or-workspace credential rule, in one place so every provider
+ * resolves it identically.
*
- * A "shared" credential is not a separate kind of entity — it is a row scoped
- * to a specific workspace (`scopeType: "ORGANIZATION"`, `scopeId` = that
- * workspace's id — "organization" here just means "every member of this
- * workspace", resolved from workspaces the connecting member owns) rather
- * than to one person. The rule, the same for every provider: a member's own
- * login wins; failing that, the workspace's shared login is used only if it
- * was explicitly marked shared *and* the member actually belongs to that
- * workspace. Provider-specific extras (Codex's busy/claim lock, Claude's
- * `connectedVia === 'cli'` requirement) are layered on top by the caller —
- * this only decides *whose* credential to look at.
+ * There used to be two conventions for "shared" in the same table:
+ * `scopeType: "WORKSPACE"` for the older fallback key pool, and
+ * `scopeType: "ORGANIZATION"` with the *workspace's* id as its scope id for
+ * the `--org` logins — which meant reading a row required knowing which
+ * mechanism had written it, and `defaultSharingEnabled` existed only to tell
+ * the two apart. They are now one scope: a `WORKSPACE`-scoped credential
+ * belongs to that workspace's members.
+ *
+ * The `sharing_enabled` column went with it. No caller ever set it; it was
+ * always the default implied by the scope, so it recorded nothing a member
+ * had decided. What a member does decide — whether their *personal*
+ * credential may fund a turn in a workspace others can see — is
+ * `allow_in_shared_workspaces`, applied by `resolveCredential`.
+ *
+ * The rule: a member's own login wins; failing that, the workspace's login,
+ * and only for a member who actually belongs to that workspace.
*/
-export type ScopedCredentialSource = "USER" | "ORGANIZATION";
+export type ScopedCredentialSource = "USER" | "WORKSPACE";
export type ScopedCredentialResult = {
credential: T;
@@ -48,15 +53,11 @@ export async function belongsToSharedScope(
}
/**
- * Personal row wins; otherwise the workspace's shared row, gated by both
- * `sharingEnabled` on that row and actual membership. `findPersonal`/
- * `findShared` do the provider-specific query (and any provider-specific
- * filtering, e.g. Codex's busy check) — this function only sequences them and
- * applies the one gate every provider shares.
+ * Personal row wins; otherwise the workspace's row, gated by membership.
+ * `findPersonal`/`findShared` do the provider-specific query — this only
+ * sequences them and applies the one gate every provider shares.
*/
-export async function resolvePersonalOrSharedCredential<
- T extends { sharingEnabled: boolean | null },
->(
+export async function resolvePersonalOrSharedCredential(
input: { userId: string; workspaceId?: string | undefined },
lookup: {
findPersonal: (userId: string) => Promise;
@@ -67,23 +68,8 @@ export async function resolvePersonalOrSharedCredential<
if (personal) return { credential: personal, source: "USER" };
if (!input.workspaceId) return null;
const shared = await lookup.findShared(input.workspaceId);
- if (
- shared?.sharingEnabled &&
- (await belongsToSharedScope(input.userId, input.workspaceId))
- ) {
- return { credential: shared, source: "ORGANIZATION" };
+ if (shared && (await belongsToSharedScope(input.userId, input.workspaceId))) {
+ return { credential: shared, source: "WORKSPACE" };
}
return null;
}
-
-/** The default a caller applies unless a member explicitly overrides it: a
- * workspace-scoped login is shared by default (that is the point of
- * connecting one that way), a personal one is not. Takes the full credential
- * scope type — a plain fallback key can be "WORKSPACE"-scoped too, which is a
- * different, older mechanism (`WorkspaceCredentialForm`) and is never shared
- * by this rule. */
-export function defaultSharingEnabled(
- scopeType: "USER" | "WORKSPACE" | "ORGANIZATION",
-): boolean {
- return scopeType === "ORGANIZATION";
-}
diff --git a/apps/web/lib/runtime/orca-host.test.ts b/apps/web/lib/runtime/orca-host.test.ts
index 1236f8d91..e989df9f1 100644
--- a/apps/web/lib/runtime/orca-host.test.ts
+++ b/apps/web/lib/runtime/orca-host.test.ts
@@ -298,7 +298,7 @@ describe("ensureOrcaSession", () => {
return {
credential: {
connectedVia,
- enabledForWorkspace: true,
+ allowInSharedWorkspaces: true,
encryptedMaterial: "enc",
},
source: "USER" as const,
diff --git a/apps/web/lib/runtime/orca-host.ts b/apps/web/lib/runtime/orca-host.ts
index 61c65a872..7644bf232 100644
--- a/apps/web/lib/runtime/orca-host.ts
+++ b/apps/web/lib/runtime/orca-host.ts
@@ -202,7 +202,7 @@ async function resolveCodexAuthCacheForIde(
// either provenance is valid when the member enabled it for workspaces.
if (
!hosted ||
- !hosted.credential.enabledForWorkspace ||
+ !hosted.credential.allowInSharedWorkspaces ||
!hosted.credential.encryptedMaterial
) {
return undefined;
diff --git a/apps/web/test-support/azure-arm-compute.ts b/apps/web/test-support/azure-arm-compute.ts
new file mode 100644
index 000000000..edfe6a015
--- /dev/null
+++ b/apps/web/test-support/azure-arm-compute.ts
@@ -0,0 +1,22 @@
+/**
+ * Test double for `@azure/arm-compute` — see `azure-keyvault-keys.ts`. No
+ * test provisions a VM; reaching the management plane throws.
+ */
+export class ComputeManagementClient {
+ constructor(
+ readonly credential: unknown,
+ readonly subscriptionId: string,
+ ) {}
+
+ get virtualMachines(): never {
+ throw new Error("Azure Compute is not available in tests.");
+ }
+
+ get disks(): never {
+ throw new Error("Azure Compute is not available in tests.");
+ }
+
+ get snapshots(): never {
+ throw new Error("Azure Compute is not available in tests.");
+ }
+}
diff --git a/apps/web/test-support/azure-identity.ts b/apps/web/test-support/azure-identity.ts
new file mode 100644
index 000000000..26d9c17f4
--- /dev/null
+++ b/apps/web/test-support/azure-identity.ts
@@ -0,0 +1,26 @@
+/**
+ * Test double for `@azure/identity` — see `azure-keyvault-keys.ts` for why
+ * the real package cannot be imported under Vitest. No test authenticates
+ * against Azure; a credential that is actually used throws rather than
+ * silently reaching the network.
+ */
+export type TokenCredential = {
+ getToken: () => Promise<{ token: string; expiresOnTimestamp: number }>;
+};
+
+function unavailable(): never {
+ throw new Error("Azure credentials are not available in tests.");
+}
+
+export class DefaultAzureCredential {
+ getToken = unavailable;
+}
+
+export class ClientAssertionCredential {
+ constructor(
+ readonly tenantId: string,
+ readonly clientId: string,
+ readonly getAssertion: () => Promise,
+ ) {}
+ getToken = unavailable;
+}
diff --git a/apps/web/test-support/azure-keyvault-keys.ts b/apps/web/test-support/azure-keyvault-keys.ts
new file mode 100644
index 000000000..932ad5f01
--- /dev/null
+++ b/apps/web/test-support/azure-keyvault-keys.ts
@@ -0,0 +1,28 @@
+/**
+ * Test double for `@azure/keyvault-keys`.
+ *
+ * The real package's ESM entry takes a named import from its own CommonJS
+ * state module (`../commonjs/state-cjs.js`), which Node cannot synthesise —
+ * so every test whose imports reached `lib/platform/azure-kms` died at import
+ * time, which is most of `lib/providers`. Inlining it for Vite only moved the
+ * failure into the package's TypeScript source.
+ *
+ * No test signs anything against a real Key Vault: `lib/platform/kms` selects
+ * the Azure path from configuration, and the unit tests exercise the local
+ * path. This stub keeps the module graph loadable and fails loudly if a test
+ * ever does reach the vault.
+ */
+export class CryptographyClient {
+ constructor(
+ readonly keyId: string,
+ readonly credential: unknown,
+ ) {}
+
+ wrapKey(): never {
+ throw new Error("Azure Key Vault is not available in tests.");
+ }
+
+ unwrapKey(): never {
+ throw new Error("Azure Key Vault is not available in tests.");
+ }
+}
diff --git a/apps/web/vitest.config.ts b/apps/web/vitest.config.ts
index 963c97155..0627065ad 100644
--- a/apps/web/vitest.config.ts
+++ b/apps/web/vitest.config.ts
@@ -7,6 +7,15 @@ const alias = {
"server-only": fileURLToPath(
new URL("./test-support/server-only.ts", import.meta.url),
),
+ "@azure/keyvault-keys": fileURLToPath(
+ new URL("./test-support/azure-keyvault-keys.ts", import.meta.url),
+ ),
+ "@azure/identity": fileURLToPath(
+ new URL("./test-support/azure-identity.ts", import.meta.url),
+ ),
+ "@azure/arm-compute": fileURLToPath(
+ new URL("./test-support/azure-arm-compute.ts", import.meta.url),
+ ),
};
/**
diff --git a/apps/web/workflows/agent-session-steps.ts b/apps/web/workflows/agent-session-steps.ts
index 57552e8a6..351618734 100644
--- a/apps/web/workflows/agent-session-steps.ts
+++ b/apps/web/workflows/agent-session-steps.ts
@@ -20,10 +20,11 @@ export async function pollCodexTurnStep(
workspaceId: string,
codexSessionId: string,
after: number,
+ seat?: { credentialId: string; turnId: string },
) {
"use step";
const { pollCodexTurn } = await import("@/lib/agents/agent-runtime");
- return pollCodexTurn(workspaceId, codexSessionId, after);
+ return pollCodexTurn(workspaceId, codexSessionId, after, seat);
}
export async function finishCodexTurnStep(
@@ -40,10 +41,11 @@ export async function cancelCodexTurnStep(
workspaceId: string,
codexSessionId: string,
credentialId: string,
+ turnId: string,
) {
"use step";
const { cancelCodexTurn } = await import("@/lib/agents/agent-runtime");
- return cancelCodexTurn(workspaceId, codexSessionId, credentialId);
+ return cancelCodexTurn(workspaceId, codexSessionId, credentialId, turnId);
}
export async function failAgentSessionStep(sessionId: string, message: string) {
diff --git a/apps/web/workflows/agent-session.ts b/apps/web/workflows/agent-session.ts
index 15a6ba15b..6ac900344 100644
--- a/apps/web/workflows/agent-session.ts
+++ b/apps/web/workflows/agent-session.ts
@@ -89,10 +89,18 @@ async function runCodexTurnToCompletion(prepared: {
const parts: Uint8Array[] = [];
for (;;) {
if (await checkTurnInterruptedStep(turnId)) {
- await cancelCodexTurnStep(workspaceId, codexSessionId, credentialId);
+ await cancelCodexTurnStep(
+ workspaceId,
+ codexSessionId,
+ credentialId,
+ turnId,
+ );
return;
}
- const poll = await pollCodexTurnStep(workspaceId, codexSessionId, after);
+ const poll = await pollCodexTurnStep(workspaceId, codexSessionId, after, {
+ credentialId,
+ turnId,
+ });
after = poll.nextSequence;
for (const chunk of poll.chunks) {
parts.push(decodeBase64(chunk.dataBase64));
diff --git a/packages/contracts/src/gen2.ts b/packages/contracts/src/gen2.ts
index c80448fc4..c7f869152 100644
--- a/packages/contracts/src/gen2.ts
+++ b/packages/contracts/src/gen2.ts
@@ -492,6 +492,48 @@ export const gen2TerminalPollResponseSchema = z.object({
exitCode: z.number().int().nullable(),
});
+/*
+ * Superset agent-session mapping, per docs/SUPERSET_AGENT_SESSION_PLAN.md
+ * Phase 1. This is the durable run row CoDev owns as the source of truth;
+ * it is an internal/service-boundary shape, not what the browser receives --
+ * a redacted view is defined when the browser integration (Phase 6) lands.
+ * It never carries credential material, only a connection id and a
+ * revision fingerprint.
+ */
+export const gen2SupersetRunStatusSchema = z.enum([
+ "creating",
+ "running",
+ "stopping",
+ "finished",
+ "failed",
+ "recovery_required",
+]);
+
+export const gen2SupersetRunSchema = z.object({
+ id: identifierSchema,
+ workspaceId: identifierSchema,
+ chatId: identifierSchema.nullable(),
+ createdBy: identifierSchema,
+ worktreeId: gen2SupersetWorktreeIdSchema,
+ hostWorkspaceId: z.string().min(1).nullable(),
+ hostTerminalId: z.string().min(1).nullable(),
+ hostAgentSessionId: z.string().min(1).nullable(),
+ provider: z.string().min(1),
+ connectionId: identifierSchema.nullable(),
+ credentialRevision: z.string().min(1).nullable(),
+ status: gen2SupersetRunStatusSchema,
+ leaseClaimed: z.boolean(),
+ exitReason: z.string().nullable(),
+ recoveryCount: z.number().int().nonnegative(),
+ idempotencyKey: z.string().min(1),
+ lastError: z.string().nullable(),
+ createdAt: timestampSchema,
+ updatedAt: timestampSchema,
+});
+
+export type Gen2SupersetRunStatus = z.infer;
+export type Gen2SupersetRun = z.infer;
+
export type Gen2Repository = z.infer;
export type Gen2WorkspaceStatus = z.infer;
export type Gen2WorkspaceRole = z.infer;
diff --git a/packages/db/drizzle/0057_sloppy_zodiak.sql b/packages/db/drizzle/0057_sloppy_zodiak.sql
new file mode 100644
index 000000000..b2a7922c0
--- /dev/null
+++ b/packages/db/drizzle/0057_sloppy_zodiak.sql
@@ -0,0 +1,44 @@
+CREATE TYPE "public"."gen2_superset_run_status" AS ENUM('creating', 'running', 'stopping', 'finished', 'failed', 'recovery_required');--> statement-breakpoint
+CREATE TABLE "gen2_superset_run_events" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "run_id" uuid NOT NULL,
+ "workspace_id" uuid NOT NULL,
+ "actor_id" uuid,
+ "type" text NOT NULL,
+ "result" text NOT NULL,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
+);
+--> statement-breakpoint
+CREATE TABLE "gen2_superset_runs" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "workspace_id" uuid NOT NULL,
+ "chat_id" uuid,
+ "created_by" uuid NOT NULL,
+ "worktree_id" text NOT NULL,
+ "host_workspace_id" text,
+ "host_terminal_id" text,
+ "host_agent_session_id" text,
+ "provider" "credential_provider" NOT NULL,
+ "connection_id" uuid,
+ "credential_revision" text,
+ "status" "gen2_superset_run_status" DEFAULT 'creating' NOT NULL,
+ "lease_claimed" boolean DEFAULT false NOT NULL,
+ "exit_reason" text,
+ "recovery_count" integer DEFAULT 0 NOT NULL,
+ "idempotency_key" text NOT NULL,
+ "last_error" text,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
+);
+--> statement-breakpoint
+ALTER TABLE "gen2_superset_run_events" ADD CONSTRAINT "gen2_superset_run_events_run_id_gen2_superset_runs_id_fk" FOREIGN KEY ("run_id") REFERENCES "public"."gen2_superset_runs"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "gen2_superset_run_events" ADD CONSTRAINT "gen2_superset_run_events_workspace_id_gen2_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."gen2_workspaces"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "gen2_superset_run_events" ADD CONSTRAINT "gen2_superset_run_events_actor_id_users_id_fk" FOREIGN KEY ("actor_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "gen2_superset_runs" ADD CONSTRAINT "gen2_superset_runs_workspace_id_gen2_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."gen2_workspaces"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "gen2_superset_runs" ADD CONSTRAINT "gen2_superset_runs_chat_id_gen2_chats_id_fk" FOREIGN KEY ("chat_id") REFERENCES "public"."gen2_chats"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "gen2_superset_runs" ADD CONSTRAINT "gen2_superset_runs_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "gen2_superset_runs" ADD CONSTRAINT "gen2_superset_runs_connection_id_provider_credentials_id_fk" FOREIGN KEY ("connection_id") REFERENCES "public"."provider_credentials"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
+CREATE INDEX "gen2_superset_run_events_run_created_idx" ON "gen2_superset_run_events" USING btree ("run_id","created_at");--> statement-breakpoint
+CREATE UNIQUE INDEX "gen2_superset_runs_workspace_idempotency_idx" ON "gen2_superset_runs" USING btree ("workspace_id","idempotency_key");--> statement-breakpoint
+CREATE INDEX "gen2_superset_runs_workspace_status_idx" ON "gen2_superset_runs" USING btree ("workspace_id","status");--> statement-breakpoint
+CREATE INDEX "gen2_superset_runs_chat_idx" ON "gen2_superset_runs" USING btree ("chat_id","created_at");
\ No newline at end of file
diff --git a/packages/db/drizzle/0058_milky_ultimates.sql b/packages/db/drizzle/0058_milky_ultimates.sql
new file mode 100644
index 000000000..7ede82798
--- /dev/null
+++ b/packages/db/drizzle/0058_milky_ultimates.sql
@@ -0,0 +1,4 @@
+ALTER TABLE "provider_credentials" ADD COLUMN "allow_in_shared_workspaces" boolean DEFAULT true NOT NULL;--> statement-breakpoint
+-- Carry over the intent of the column this replaces: a member who had turned
+-- a credential off for coding workspaces keeps it out of shared ones.
+UPDATE "provider_credentials" SET "allow_in_shared_workspaces" = false WHERE "enabled_for_workspace" = false;
diff --git a/packages/db/drizzle/0059_flippant_zuras.sql b/packages/db/drizzle/0059_flippant_zuras.sql
new file mode 100644
index 000000000..68ebaa6f3
--- /dev/null
+++ b/packages/db/drizzle/0059_flippant_zuras.sql
@@ -0,0 +1,2 @@
+ALTER TABLE "provider_credentials" DROP COLUMN "enabled_for_rooms";--> statement-breakpoint
+ALTER TABLE "provider_credentials" DROP COLUMN "enabled_for_workspace";
\ No newline at end of file
diff --git a/packages/db/drizzle/0060_empty_may_parker.sql b/packages/db/drizzle/0060_empty_may_parker.sql
new file mode 100644
index 000000000..c90293ebd
--- /dev/null
+++ b/packages/db/drizzle/0060_empty_may_parker.sql
@@ -0,0 +1,15 @@
+CREATE TABLE "provider_credential_runs" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "credential_id" uuid NOT NULL,
+ "user_id" uuid NOT NULL,
+ "surface" text NOT NULL,
+ "ref" text NOT NULL,
+ "heartbeat_at" timestamp with time zone DEFAULT now() NOT NULL,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
+);
+--> statement-breakpoint
+ALTER TABLE "provider_credential_runs" ADD CONSTRAINT "provider_credential_runs_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+CREATE UNIQUE INDEX "provider_credential_runs_credential_idx" ON "provider_credential_runs" USING btree ("credential_id");--> statement-breakpoint
+CREATE INDEX "provider_credential_runs_ref_idx" ON "provider_credential_runs" USING btree ("ref");--> statement-breakpoint
+ALTER TABLE "provider_credentials" DROP COLUMN "unavailable_until";
\ No newline at end of file
diff --git a/packages/db/drizzle/0061_bored_paladin.sql b/packages/db/drizzle/0061_bored_paladin.sql
new file mode 100644
index 000000000..d31d4f81b
--- /dev/null
+++ b/packages/db/drizzle/0061_bored_paladin.sql
@@ -0,0 +1,25 @@
+-- Collapse the two spellings of "shared" onto one scope before narrowing the
+-- type. An ORGANIZATION credential's scope id was already a workspace id, so
+-- this is a relabel, not a move. Drop any row that would collide with a
+-- WORKSPACE row already holding that (workspace, provider, type): the older
+-- fallback-pool entry is the one the resolvers have been reading.
+DELETE FROM "provider_credentials" AS organization
+USING "provider_credentials" AS workspace
+WHERE organization."scope_type" = 'ORGANIZATION'
+ AND workspace."scope_type" = 'WORKSPACE'
+ AND workspace."scope_id" = organization."scope_id"
+ AND workspace."provider" = organization."provider"
+ AND workspace."credential_type" = organization."credential_type";--> statement-breakpoint
+UPDATE "provider_credentials" SET "scope_type" = 'WORKSPACE' WHERE "scope_type" = 'ORGANIZATION';--> statement-breakpoint
+UPDATE "provider_credential_events" SET "scope_type" = 'WORKSPACE' WHERE "scope_type" = 'ORGANIZATION';--> statement-breakpoint
+UPDATE "claude_connection_sessions" SET "scope_type" = 'WORKSPACE' WHERE "scope_type" = 'ORGANIZATION';--> statement-breakpoint
+ALTER TABLE "claude_connection_sessions" ALTER COLUMN "scope_type" SET DATA TYPE text;--> statement-breakpoint
+ALTER TABLE "claude_connection_sessions" ALTER COLUMN "scope_type" SET DEFAULT 'USER'::text;--> statement-breakpoint
+ALTER TABLE "provider_credential_events" ALTER COLUMN "scope_type" SET DATA TYPE text;--> statement-breakpoint
+ALTER TABLE "provider_credentials" ALTER COLUMN "scope_type" SET DATA TYPE text;--> statement-breakpoint
+DROP TYPE "public"."credential_scope_type";--> statement-breakpoint
+CREATE TYPE "public"."credential_scope_type" AS ENUM('USER', 'WORKSPACE');--> statement-breakpoint
+ALTER TABLE "claude_connection_sessions" ALTER COLUMN "scope_type" SET DEFAULT 'USER'::"public"."credential_scope_type";--> statement-breakpoint
+ALTER TABLE "claude_connection_sessions" ALTER COLUMN "scope_type" SET DATA TYPE "public"."credential_scope_type" USING "scope_type"::"public"."credential_scope_type";--> statement-breakpoint
+ALTER TABLE "provider_credential_events" ALTER COLUMN "scope_type" SET DATA TYPE "public"."credential_scope_type" USING "scope_type"::"public"."credential_scope_type";--> statement-breakpoint
+ALTER TABLE "provider_credentials" ALTER COLUMN "scope_type" SET DATA TYPE "public"."credential_scope_type" USING "scope_type"::"public"."credential_scope_type";
\ No newline at end of file
diff --git a/packages/db/drizzle/0062_left_timeslip.sql b/packages/db/drizzle/0062_left_timeslip.sql
new file mode 100644
index 000000000..32a605cc3
--- /dev/null
+++ b/packages/db/drizzle/0062_left_timeslip.sql
@@ -0,0 +1 @@
+ALTER TABLE "provider_credentials" DROP COLUMN "sharing_enabled";
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/0055_snapshot.json b/packages/db/drizzle/meta/0055_snapshot.json
new file mode 100644
index 000000000..1352acf6a
--- /dev/null
+++ b/packages/db/drizzle/meta/0055_snapshot.json
@@ -0,0 +1,9393 @@
+{
+ "id": "e64fbbe2-1baa-4535-bff9-6ed4775ac8c7",
+ "prevId": "1674b5e5-d9da-486a-b8f2-26ec5255f90b",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.access_requests": {
+ "name": "access_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_login": {
+ "name": "github_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "persona": {
+ "name": "persona",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building": {
+ "name": "building",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "referrer": {
+ "name": "referrer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ip_hash": {
+ "name": "ip_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "access_request_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "invited_at": {
+ "name": "invited_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invite_token_hash": {
+ "name": "invite_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invite_token_expires_at": {
+ "name": "invite_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "access_requests_email_idx": {
+ "name": "access_requests_email_idx",
+ "columns": [
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_status_created_idx": {
+ "name": "access_requests_status_created_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_ip_created_idx": {
+ "name": "access_requests_ip_created_idx",
+ "columns": [
+ {
+ "expression": "ip_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_invite_token_hash_idx": {
+ "name": "access_requests_invite_token_hash_idx",
+ "columns": [
+ {
+ "expression": "invite_token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_briefs": {
+ "name": "agent_briefs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "approach_summary": {
+ "name": "approach_summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "plan_steps": {
+ "name": "plan_steps",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "current_step": {
+ "name": "current_step",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "files_likely_to_touch": {
+ "name": "files_likely_to_touch",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "keywords": {
+ "name": "keywords",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_brief_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'planning'"
+ },
+ "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_briefs_session_idx": {
+ "name": "agent_briefs_session_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_briefs_workspace_status_idx": {
+ "name": "agent_briefs_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_briefs_workspace_id_workspaces_id_fk": {
+ "name": "agent_briefs_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_briefs",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_briefs_session_id_agent_sessions_id_fk": {
+ "name": "agent_briefs_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_briefs",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_events": {
+ "name": "agent_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "turn_id": {
+ "name": "turn_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_events_idempotency_idx": {
+ "name": "agent_events_idempotency_idx",
+ "columns": [
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_events_session_created_idx": {
+ "name": "agent_events_session_created_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_events_workspace_id_workspaces_id_fk": {
+ "name": "agent_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_events_session_id_agent_sessions_id_fk": {
+ "name": "agent_events_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_events_turn_id_agent_turns_id_fk": {
+ "name": "agent_events_turn_id_agent_turns_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "agent_turns",
+ "columnsFrom": [
+ "turn_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_session_import_artifacts": {
+ "name": "agent_session_import_artifacts",
+ "schema": "",
+ "columns": {
+ "import_id": {
+ "name": "import_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "media_type": {
+ "name": "media_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plaintext_sha256": {
+ "name": "plaintext_sha256",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plaintext_bytes": {
+ "name": "plaintext_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_payload": {
+ "name": "encrypted_payload",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_session_import_artifacts_created_idx": {
+ "name": "agent_session_import_artifacts_created_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_session_import_artifacts_import_id_agent_session_imports_id_fk": {
+ "name": "agent_session_import_artifacts_import_id_agent_session_imports_id_fk",
+ "tableFrom": "agent_session_import_artifacts",
+ "tableTo": "agent_session_imports",
+ "columnsFrom": [
+ "import_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_session_imports": {
+ "name": "agent_session_imports",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "imported_by": {
+ "name": "imported_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_import_id": {
+ "name": "parent_import_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_session_id": {
+ "name": "agent_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_provider": {
+ "name": "source_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_session_id": {
+ "name": "external_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capsule_schema_version": {
+ "name": "capsule_schema_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capsule_sha256": {
+ "name": "capsule_sha256",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_session_import_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'storing'"
+ },
+ "repository_status": {
+ "name": "repository_status",
+ "type": "repository_restore_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "continuation_mode": {
+ "name": "continuation_mode",
+ "type": "session_continuation_mode",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_session_imports_idempotency_idx": {
+ "name": "agent_session_imports_idempotency_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_workspace_status_idx": {
+ "name": "agent_session_imports_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_importer_idx": {
+ "name": "agent_session_imports_importer_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_source_idx": {
+ "name": "agent_session_imports_source_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_parent_idx": {
+ "name": "agent_session_imports_parent_idx",
+ "columns": [
+ {
+ "expression": "parent_import_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_active_writer_idx": {
+ "name": "agent_session_imports_active_writer_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_session_imports\".\"continuation_mode\" = 'native_resume' and \"agent_session_imports\".\"status\" in ('launching', 'active') and \"agent_session_imports\".\"deleted_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_session_imports_organization_id_organizations_id_fk": {
+ "name": "agent_session_imports_organization_id_organizations_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_workspace_id_workspaces_id_fk": {
+ "name": "agent_session_imports_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_imported_by_users_id_fk": {
+ "name": "agent_session_imports_imported_by_users_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "users",
+ "columnsFrom": [
+ "imported_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_parent_import_id_agent_session_imports_id_fk": {
+ "name": "agent_session_imports_parent_import_id_agent_session_imports_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "agent_session_imports",
+ "columnsFrom": [
+ "parent_import_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_worktree_id_worktrees_id_fk": {
+ "name": "agent_session_imports_worktree_id_worktrees_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_agent_session_id_agent_sessions_id_fk": {
+ "name": "agent_session_imports_agent_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "agent_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_sessions": {
+ "name": "agent_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_number": {
+ "name": "issue_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'Agent'"
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'gpt-5'"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'openai'"
+ },
+ "kind": {
+ "name": "kind",
+ "type": "agent_session_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'managed'"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_session_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'idle'"
+ },
+ "workflow_run_id": {
+ "name": "workflow_run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "interrupted_at": {
+ "name": "interrupted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_sessions_workspace_issue_idx": {
+ "name": "agent_sessions_workspace_issue_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "issue_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_sessions_workspace_status_idx": {
+ "name": "agent_sessions_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_sessions_workspace_id_workspaces_id_fk": {
+ "name": "agent_sessions_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_sessions_worktree_id_worktrees_id_fk": {
+ "name": "agent_sessions_worktree_id_worktrees_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_sessions_created_by_users_id_fk": {
+ "name": "agent_sessions_created_by_users_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_turns": {
+ "name": "agent_turns",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attachments": {
+ "name": "attachments",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_turn_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "workflow_run_id": {
+ "name": "workflow_run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_id": {
+ "name": "response_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output": {
+ "name": "output",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finished_at": {
+ "name": "finished_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_turns_session_created_idx": {
+ "name": "agent_turns_session_created_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_turns_session_id_agent_sessions_id_fk": {
+ "name": "agent_turns_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_turns",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_turns_author_id_users_id_fk": {
+ "name": "agent_turns_author_id_users_id_fk",
+ "tableFrom": "agent_turns",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.brain_entries": {
+ "name": "brain_entries",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "brain_entry_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "paths": {
+ "name": "paths",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "keywords": {
+ "name": "keywords",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "supersedes_id": {
+ "name": "supersedes_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "brain_entries_workspace_created_idx": {
+ "name": "brain_entries_workspace_created_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "brain_entries_workspace_kind_idx": {
+ "name": "brain_entries_workspace_kind_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "brain_entries_workspace_id_workspaces_id_fk": {
+ "name": "brain_entries_workspace_id_workspaces_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_entries_session_id_agent_sessions_id_fk": {
+ "name": "brain_entries_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "brain_entries_author_id_users_id_fk": {
+ "name": "brain_entries_author_id_users_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.brain_overlaps": {
+ "name": "brain_overlaps",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "left_session_id": {
+ "name": "left_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "right_session_id": {
+ "name": "right_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "brain_overlap_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "score": {
+ "name": "score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "evidence": {
+ "name": "evidence",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "rationale": {
+ "name": "rationale",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "status": {
+ "name": "status",
+ "type": "brain_overlap_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "detected_at": {
+ "name": "detected_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": {
+ "brain_overlaps_pair_kind_idx": {
+ "name": "brain_overlaps_pair_kind_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "left_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "right_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "brain_overlaps_workspace_status_idx": {
+ "name": "brain_overlaps_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "brain_overlaps_workspace_id_workspaces_id_fk": {
+ "name": "brain_overlaps_workspace_id_workspaces_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_overlaps_left_session_id_agent_sessions_id_fk": {
+ "name": "brain_overlaps_left_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "left_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_overlaps_right_session_id_agent_sessions_id_fk": {
+ "name": "brain_overlaps_right_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "right_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.claude_connection_sessions": {
+ "name": "claude_connection_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'USER'"
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "claude_connection_session_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'starting'"
+ },
+ "runner_id": {
+ "name": "runner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "authorize_url": {
+ "name": "authorize_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_reason": {
+ "name": "failure_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "claude_connection_sessions_user_idx": {
+ "name": "claude_connection_sessions_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "claude_connection_sessions_expiry_idx": {
+ "name": "claude_connection_sessions_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "claude_connection_sessions_user_id_users_id_fk": {
+ "name": "claude_connection_sessions_user_id_users_id_fk",
+ "tableFrom": "claude_connection_sessions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cli_access_tokens": {
+ "name": "cli_access_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'CoDev CLI'"
+ },
+ "client_type": {
+ "name": "client_type",
+ "type": "cli_client_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'cli'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_used_at": {
+ "name": "last_used_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "cli_access_tokens_token_hash_idx": {
+ "name": "cli_access_tokens_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_access_tokens_user_idx": {
+ "name": "cli_access_tokens_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_access_tokens_expiry_idx": {
+ "name": "cli_access_tokens_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cli_access_tokens_user_id_users_id_fk": {
+ "name": "cli_access_tokens_user_id_users_id_fk",
+ "tableFrom": "cli_access_tokens",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cli_device_authorizations": {
+ "name": "cli_device_authorizations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "device_code_hash": {
+ "name": "device_code_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_code": {
+ "name": "user_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "cli_device_authorization_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "client_type": {
+ "name": "client_type",
+ "type": "cli_client_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'cli'"
+ },
+ "approved_by": {
+ "name": "approved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "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": {
+ "cli_device_authorizations_device_code_idx": {
+ "name": "cli_device_authorizations_device_code_idx",
+ "columns": [
+ {
+ "expression": "device_code_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_device_authorizations_user_code_idx": {
+ "name": "cli_device_authorizations_user_code_idx",
+ "columns": [
+ {
+ "expression": "user_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_device_authorizations_expiry_idx": {
+ "name": "cli_device_authorizations_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cli_device_authorizations_approved_by_users_id_fk": {
+ "name": "cli_device_authorizations_approved_by_users_id_fk",
+ "tableFrom": "cli_device_authorizations",
+ "tableTo": "users",
+ "columnsFrom": [
+ "approved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.collaboration_conflict_resolutions": {
+ "name": "collaboration_conflict_resolutions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resolved_by": {
+ "name": "resolved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "strategy": {
+ "name": "strategy",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "snapshot_revision": {
+ "name": "snapshot_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result_revision": {
+ "name": "result_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "collaboration_conflict_resolutions_document_idx": {
+ "name": "collaboration_conflict_resolutions_document_idx",
+ "columns": [
+ {
+ "expression": "worktree_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "collaboration_conflict_resolutions_worktree_id_worktrees_id_fk": {
+ "name": "collaboration_conflict_resolutions_worktree_id_worktrees_id_fk",
+ "tableFrom": "collaboration_conflict_resolutions",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "collaboration_conflict_resolutions_resolved_by_users_id_fk": {
+ "name": "collaboration_conflict_resolutions_resolved_by_users_id_fk",
+ "tableFrom": "collaboration_conflict_resolutions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "resolved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversation_artifacts": {
+ "name": "conversation_artifacts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_url": {
+ "name": "source_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "downloadable": {
+ "name": "downloadable",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversation_artifacts_conversation_idx": {
+ "name": "conversation_artifacts_conversation_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "conversation_artifacts_message_idx": {
+ "name": "conversation_artifacts_message_idx",
+ "columns": [
+ {
+ "expression": "message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversation_artifacts_conversation_id_conversations_id_fk": {
+ "name": "conversation_artifacts_conversation_id_conversations_id_fk",
+ "tableFrom": "conversation_artifacts",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "conversation_artifacts_message_id_conversation_messages_id_fk": {
+ "name": "conversation_artifacts_message_id_conversation_messages_id_fk",
+ "tableFrom": "conversation_artifacts",
+ "tableTo": "conversation_messages",
+ "columnsFrom": [
+ "message_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversation_messages": {
+ "name": "conversation_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence": {
+ "name": "sequence",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_user_id": {
+ "name": "author_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_name": {
+ "name": "author_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_content_type": {
+ "name": "source_content_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_created_at": {
+ "name": "source_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversation_messages_sequence_idx": {
+ "name": "conversation_messages_sequence_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sequence",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversation_messages_conversation_id_conversations_id_fk": {
+ "name": "conversation_messages_conversation_id_conversations_id_fk",
+ "tableFrom": "conversation_messages",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "conversation_messages_author_user_id_users_id_fk": {
+ "name": "conversation_messages_author_user_id_users_id_fk",
+ "tableFrom": "conversation_messages",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversations": {
+ "name": "conversations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'imported'"
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_provider": {
+ "name": "source_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_external_id": {
+ "name": "source_external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_url": {
+ "name": "source_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_model": {
+ "name": "source_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_updated_at": {
+ "name": "source_updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "warnings": {
+ "name": "warnings",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversations_owner_updated_idx": {
+ "name": "conversations_owner_updated_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "conversations_owner_source_idx": {
+ "name": "conversations_owner_source_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_external_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversations_owner_id_users_id_fk": {
+ "name": "conversations_owner_id_users_id_fk",
+ "tableFrom": "conversations",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.coordination_messages": {
+ "name": "coordination_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "from_session_id": {
+ "name": "from_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "to_session_id": {
+ "name": "to_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "correlation_id": {
+ "name": "correlation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "response_to_id": {
+ "name": "response_to_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "coordination_message_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "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": {
+ "coordination_messages_target_status_idx": {
+ "name": "coordination_messages_target_status_idx",
+ "columns": [
+ {
+ "expression": "to_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "coordination_messages_workspace_id_workspaces_id_fk": {
+ "name": "coordination_messages_workspace_id_workspaces_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coordination_messages_from_session_id_agent_sessions_id_fk": {
+ "name": "coordination_messages_from_session_id_agent_sessions_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "from_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coordination_messages_to_session_id_agent_sessions_id_fk": {
+ "name": "coordination_messages_to_session_id_agent_sessions_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "to_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.design_partner_feedback": {
+ "name": "design_partner_feedback",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "category": {
+ "name": "category",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rating": {
+ "name": "rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "page": {
+ "name": "page",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "release": {
+ "name": "release",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'new'"
+ },
+ "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": {
+ "design_partner_feedback_user_created_idx": {
+ "name": "design_partner_feedback_user_created_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "design_partner_feedback_status_created_idx": {
+ "name": "design_partner_feedback_status_created_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "design_partner_feedback_user_id_users_id_fk": {
+ "name": "design_partner_feedback_user_id_users_id_fk",
+ "tableFrom": "design_partner_feedback",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "design_partner_feedback_workspace_id_workspaces_id_fk": {
+ "name": "design_partner_feedback_workspace_id_workspaces_id_fk",
+ "tableFrom": "design_partner_feedback",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.feature_override_audit_events": {
+ "name": "feature_override_audit_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_user_id": {
+ "name": "target_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_user_id": {
+ "name": "actor_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "feature_override_audit_action",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "previous_enabled": {
+ "name": "previous_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "previous_expires_at": {
+ "name": "previous_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "feature_override_audit_org_created_idx": {
+ "name": "feature_override_audit_org_created_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "feature_override_audit_user_created_idx": {
+ "name": "feature_override_audit_user_created_idx",
+ "columns": [
+ {
+ "expression": "target_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "feature_override_audit_events_organization_id_organizations_id_fk": {
+ "name": "feature_override_audit_events_organization_id_organizations_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "feature_override_audit_events_target_user_id_users_id_fk": {
+ "name": "feature_override_audit_events_target_user_id_users_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "target_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "feature_override_audit_events_actor_user_id_users_id_fk": {
+ "name": "feature_override_audit_events_actor_user_id_users_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_agent_turns": {
+ "name": "gen2_agent_turns",
+ "schema": "",
+ "columns": {
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "output": {
+ "name": "output",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "pending_base64": {
+ "name": "pending_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "exited": {
+ "name": "exited",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "reply_message_id": {
+ "name": "reply_message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_agent_turns_chat_idx": {
+ "name": "gen2_agent_turns_chat_idx",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_agent_turns_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_agent_turns_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_chat_id_gen2_chats_id_fk": {
+ "name": "gen2_agent_turns_chat_id_gen2_chats_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_chats",
+ "columnsFrom": [
+ "chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_user_id_users_id_fk": {
+ "name": "gen2_agent_turns_user_id_users_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_reply_message_id_gen2_chat_messages_id_fk": {
+ "name": "gen2_agent_turns_reply_message_id_gen2_chat_messages_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_chat_messages",
+ "columnsFrom": [
+ "reply_message_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_chat_messages": {
+ "name": "gen2_chat_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "items": {
+ "name": "items",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_chat_messages_chat_idx": {
+ "name": "gen2_chat_messages_chat_idx",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_chat_messages_chat_id_gen2_chats_id_fk": {
+ "name": "gen2_chat_messages_chat_id_gen2_chats_id_fk",
+ "tableFrom": "gen2_chat_messages",
+ "tableTo": "gen2_chats",
+ "columnsFrom": [
+ "chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_chats": {
+ "name": "gen2_chats",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_chats_workspace_updated_idx": {
+ "name": "gen2_chats_workspace_updated_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_chats_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_chats_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_chats",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_chats_created_by_user_id_users_id_fk": {
+ "name": "gen2_chats_created_by_user_id_users_id_fk",
+ "tableFrom": "gen2_chats",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_workspace_members": {
+ "name": "gen2_workspace_members",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "gen2_workspace_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'editor'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_workspace_members_user_idx": {
+ "name": "gen2_workspace_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_workspace_members_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_workspace_members_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_workspace_members",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_workspace_members_user_id_users_id_fk": {
+ "name": "gen2_workspace_members_user_id_users_id_fk",
+ "tableFrom": "gen2_workspace_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "gen2_workspace_members_workspace_id_user_id_pk": {
+ "name": "gen2_workspace_members_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_workspaces": {
+ "name": "gen2_workspaces",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "gen2_workspace_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "sandbox_id": {
+ "name": "sandbox_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_token_hash": {
+ "name": "active_invite_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_created_by_user_id": {
+ "name": "active_invite_created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_role": {
+ "name": "active_invite_role",
+ "type": "gen2_workspace_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_created_at": {
+ "name": "active_invite_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_expires_at": {
+ "name": "active_invite_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_installation_id": {
+ "name": "github_installation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository": {
+ "name": "repository",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_private": {
+ "name": "repository_private",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "default_branch": {
+ "name": "default_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_workspaces_owner_idx": {
+ "name": "gen2_workspaces_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "gen2_workspaces_active_invite_token_hash_idx": {
+ "name": "gen2_workspaces_active_invite_token_hash_idx",
+ "columns": [
+ {
+ "expression": "active_invite_token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_workspaces_owner_id_users_id_fk": {
+ "name": "gen2_workspaces_owner_id_users_id_fk",
+ "tableFrom": "gen2_workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "gen2_workspaces_active_invite_created_by_user_id_users_id_fk": {
+ "name": "gen2_workspaces_active_invite_created_by_user_id_users_id_fk",
+ "tableFrom": "gen2_workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "active_invite_created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_yjs_documents": {
+ "name": "gen2_yjs_documents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "update_base64": {
+ "name": "update_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state_vector_base64": {
+ "name": "state_vector_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_contents": {
+ "name": "filesystem_contents",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_conflict": {
+ "name": "has_conflict",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "conflict_filesystem_revision": {
+ "name": "conflict_filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_detected_at": {
+ "name": "conflict_detected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_yjs_documents_workspace_path_idx": {
+ "name": "gen2_yjs_documents_workspace_path_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_yjs_documents_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_yjs_documents_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_yjs_documents",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_connections": {
+ "name": "github_connections",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "encrypted_access_token": {
+ "name": "encrypted_access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_refresh_token": {
+ "name": "encrypted_refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'bearer'"
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "github_connections_access_expiry_idx": {
+ "name": "github_connections_access_expiry_idx",
+ "columns": [
+ {
+ "expression": "access_token_expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "github_connections_user_id_users_id_fk": {
+ "name": "github_connections_user_id_users_id_fk",
+ "tableFrom": "github_connections",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_issue_assignments": {
+ "name": "github_issue_assignments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_number": {
+ "name": "issue_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_issue_id": {
+ "name": "github_issue_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "github_issue_assignments_repository_issue_idx": {
+ "name": "github_issue_assignments_repository_issue_idx",
+ "columns": [
+ {
+ "expression": "github_repository_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "issue_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "github_issue_assignments_session_idx": {
+ "name": "github_issue_assignments_session_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "github_issue_assignments_workspace_idx": {
+ "name": "github_issue_assignments_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "github_issue_assignments_workspace_id_workspaces_id_fk": {
+ "name": "github_issue_assignments_workspace_id_workspaces_id_fk",
+ "tableFrom": "github_issue_assignments",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "github_issue_assignments_session_id_agent_sessions_id_fk": {
+ "name": "github_issue_assignments_session_id_agent_sessions_id_fk",
+ "tableFrom": "github_issue_assignments",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.mobile_push_tokens": {
+ "name": "mobile_push_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expo_push_token": {
+ "name": "expo_push_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "mobile_platform",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "device_id": {
+ "name": "device_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_seen_at": {
+ "name": "last_seen_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": {
+ "mobile_push_tokens_token_idx": {
+ "name": "mobile_push_tokens_token_idx",
+ "columns": [
+ {
+ "expression": "expo_push_token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "mobile_push_tokens_user_idx": {
+ "name": "mobile_push_tokens_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mobile_push_tokens_user_id_users_id_fk": {
+ "name": "mobile_push_tokens_user_id_users_id_fk",
+ "tableFrom": "mobile_push_tokens",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_feature_overrides": {
+ "name": "organization_feature_overrides",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "organization_feature_overrides_organization_id_organizations_id_fk": {
+ "name": "organization_feature_overrides_organization_id_organizations_id_fk",
+ "tableFrom": "organization_feature_overrides",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_feature_overrides_created_by_users_id_fk": {
+ "name": "organization_feature_overrides_created_by_users_id_fk",
+ "tableFrom": "organization_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "organization_feature_overrides_organization_id_feature_pk": {
+ "name": "organization_feature_overrides_organization_id_feature_pk",
+ "columns": [
+ "organization_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_members": {
+ "name": "organization_members",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "organization_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organization_members_user_idx": {
+ "name": "organization_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organization_members_organization_id_organizations_id_fk": {
+ "name": "organization_members_organization_id_organizations_id_fk",
+ "tableFrom": "organization_members",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_members_user_id_users_id_fk": {
+ "name": "organization_members_user_id_users_id_fk",
+ "tableFrom": "organization_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "organization_members_organization_id_user_id_pk": {
+ "name": "organization_members_organization_id_user_id_pk",
+ "columns": [
+ "organization_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_subscriptions": {
+ "name": "organization_subscriptions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "organization_subscription_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_customer_id": {
+ "name": "provider_customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_subscription_id": {
+ "name": "provider_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_period_end": {
+ "name": "current_period_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "canceled_at": {
+ "name": "canceled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organization_subscriptions_org_idx": {
+ "name": "organization_subscriptions_org_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "organization_subscriptions_provider_idx": {
+ "name": "organization_subscriptions_provider_idx",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organization_subscriptions_organization_id_organizations_id_fk": {
+ "name": "organization_subscriptions_organization_id_organizations_id_fk",
+ "tableFrom": "organization_subscriptions",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_subscriptions_plan_id_plans_id_fk": {
+ "name": "organization_subscriptions_plan_id_plans_id_fk",
+ "tableFrom": "organization_subscriptions",
+ "tableTo": "plans",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organizations": {
+ "name": "organizations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organizations_slug_idx": {
+ "name": "organizations_slug_idx",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.page_views": {
+ "name": "page_views",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "referrer": {
+ "name": "referrer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ip_hash": {
+ "name": "ip_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "page_views_created_idx": {
+ "name": "page_views_created_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "page_views_user_created_idx": {
+ "name": "page_views_user_created_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "page_views_path_created_idx": {
+ "name": "page_views_path_created_idx",
+ "columns": [
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "page_views_user_id_users_id_fk": {
+ "name": "page_views_user_id_users_id_fk",
+ "tableFrom": "page_views",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.path_claims": {
+ "name": "path_claims",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path_glob": {
+ "name": "path_glob",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "intent": {
+ "name": "intent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "claim_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "path_claims_session_status_idx": {
+ "name": "path_claims_session_status_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "path_claims_expiry_idx": {
+ "name": "path_claims_expiry_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "path_claims_session_id_agent_sessions_id_fk": {
+ "name": "path_claims_session_id_agent_sessions_id_fk",
+ "tableFrom": "path_claims",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan_entitlements": {
+ "name": "plan_entitlements",
+ "schema": "",
+ "columns": {
+ "plan_id": {
+ "name": "plan_id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "plan_entitlements_plan_id_plans_id_fk": {
+ "name": "plan_entitlements_plan_id_plans_id_fk",
+ "tableFrom": "plan_entitlements",
+ "tableTo": "plans",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "plan_entitlements_plan_id_feature_pk": {
+ "name": "plan_entitlements_plan_id_feature_pk",
+ "columns": [
+ "plan_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plans": {
+ "name": "plans",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.provider_credential_events": {
+ "name": "provider_credential_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "credential_provider",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result": {
+ "name": "result",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "provider_credential_events_credential_created_idx": {
+ "name": "provider_credential_events_credential_created_idx",
+ "columns": [
+ {
+ "expression": "credential_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credential_events_actor_created_idx": {
+ "name": "provider_credential_events_actor_created_idx",
+ "columns": [
+ {
+ "expression": "actor_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "provider_credential_events_actor_id_users_id_fk": {
+ "name": "provider_credential_events_actor_id_users_id_fk",
+ "tableFrom": "provider_credential_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "provider_credential_events_workspace_id_workspaces_id_fk": {
+ "name": "provider_credential_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "provider_credential_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.provider_credentials": {
+ "name": "provider_credentials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "credential_provider",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_type": {
+ "name": "credential_type",
+ "type": "credential_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "priority_order": {
+ "name": "priority_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "encrypted_api_key": {
+ "name": "encrypted_api_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_access_token": {
+ "name": "encrypted_access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_refresh_token": {
+ "name": "encrypted_refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "endpoint_url": {
+ "name": "endpoint_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "aws_role_arn": {
+ "name": "aws_role_arn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_connected": {
+ "name": "is_connected",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_four": {
+ "name": "last_four",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "provider_credential_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "provider_subject_hash": {
+ "name": "provider_subject_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_material": {
+ "name": "encrypted_material",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_refreshed_at": {
+ "name": "last_refreshed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sharing_enabled": {
+ "name": "sharing_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "unavailable_until": {
+ "name": "unavailable_until",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "connected_via": {
+ "name": "connected_via",
+ "type": "credential_connected_via",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled_for_rooms": {
+ "name": "enabled_for_rooms",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "enabled_for_workspace": {
+ "name": "enabled_for_workspace",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "provider_credentials_scope_provider_type_idx": {
+ "name": "provider_credentials_scope_provider_type_idx",
+ "columns": [
+ {
+ "expression": "scope_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scope_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "credential_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credentials_scope_provider_priority_idx": {
+ "name": "provider_credentials_scope_provider_priority_idx",
+ "columns": [
+ {
+ "expression": "scope_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scope_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "priority_order",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credentials_status_idx": {
+ "name": "provider_credentials_status_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "provider_credentials_created_by_users_id_fk": {
+ "name": "provider_credentials_created_by_users_id_fk",
+ "tableFrom": "provider_credentials",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.published_branches": {
+ "name": "published_branches",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "published_by": {
+ "name": "published_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "branch_name": {
+ "name": "branch_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "publication_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "source_head_sha": {
+ "name": "source_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "commit_sha": {
+ "name": "commit_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_id": {
+ "name": "repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "remote_ref": {
+ "name": "remote_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "html_url": {
+ "name": "html_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pull_request_number": {
+ "name": "pull_request_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pull_request_url": {
+ "name": "pull_request_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "request_id": {
+ "name": "request_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "published_at": {
+ "name": "published_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "published_branches_workspace_name_idx": {
+ "name": "published_branches_workspace_name_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "branch_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "published_branches_workspace_request_idx": {
+ "name": "published_branches_workspace_request_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "request_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "published_branches_workspace_status_idx": {
+ "name": "published_branches_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "published_branches_workspace_id_workspaces_id_fk": {
+ "name": "published_branches_workspace_id_workspaces_id_fk",
+ "tableFrom": "published_branches",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "published_branches_published_by_users_id_fk": {
+ "name": "published_branches_published_by_users_id_fk",
+ "tableFrom": "published_branches",
+ "tableTo": "users",
+ "columnsFrom": [
+ "published_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.runtime_hosts": {
+ "name": "runtime_hosts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "runtime_address": {
+ "name": "runtime_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifecycle_state": {
+ "name": "lifecycle_state",
+ "type": "runtime_host_lifecycle",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'provisioning'"
+ },
+ "max_workspace_slots": {
+ "name": "max_workspace_slots",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 4
+ },
+ "free_workspace_slots": {
+ "name": "free_workspace_slots",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 4
+ },
+ "image_version": {
+ "name": "image_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_heartbeat_at": {
+ "name": "last_heartbeat_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "draining_at": {
+ "name": "draining_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "runtime_hosts_provider_id_idx": {
+ "name": "runtime_hosts_provider_id_idx",
+ "columns": [
+ {
+ "expression": "provider_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "runtime_hosts_runtime_address_idx": {
+ "name": "runtime_hosts_runtime_address_idx",
+ "columns": [
+ {
+ "expression": "runtime_address",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "runtime_hosts_capacity_idx": {
+ "name": "runtime_hosts_capacity_idx",
+ "columns": [
+ {
+ "expression": "lifecycle_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "free_workspace_slots",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sandbox_runtime_intervals": {
+ "name": "sandbox_runtime_intervals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ended_at": {
+ "name": "ended_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "sandbox_runtime_intervals_user_open_idx": {
+ "name": "sandbox_runtime_intervals_user_open_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "ended_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "sandbox_runtime_intervals_workspace_open_idx": {
+ "name": "sandbox_runtime_intervals_workspace_open_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "ended_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "sandbox_runtime_intervals_user_id_users_id_fk": {
+ "name": "sandbox_runtime_intervals_user_id_users_id_fk",
+ "tableFrom": "sandbox_runtime_intervals",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sandbox_runtime_intervals_workspace_id_workspaces_id_fk": {
+ "name": "sandbox_runtime_intervals_workspace_id_workspaces_id_fk",
+ "tableFrom": "sandbox_runtime_intervals",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chat_invites": {
+ "name": "shared_chat_invites",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "shared_chat_id": {
+ "name": "shared_chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_token": {
+ "name": "encrypted_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_by": {
+ "name": "accepted_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chat_invites_token_hash_idx": {
+ "name": "shared_chat_invites_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "shared_chat_invites_room_idx": {
+ "name": "shared_chat_invites_room_idx",
+ "columns": [
+ {
+ "expression": "shared_chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chat_invites_shared_chat_id_shared_chats_id_fk": {
+ "name": "shared_chat_invites_shared_chat_id_shared_chats_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "shared_chats",
+ "columnsFrom": [
+ "shared_chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_invites_created_by_users_id_fk": {
+ "name": "shared_chat_invites_created_by_users_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_invites_accepted_by_users_id_fk": {
+ "name": "shared_chat_invites_accepted_by_users_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "accepted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chat_members": {
+ "name": "shared_chat_members",
+ "schema": "",
+ "columns": {
+ "shared_chat_id": {
+ "name": "shared_chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chat_members_user_idx": {
+ "name": "shared_chat_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chat_members_shared_chat_id_shared_chats_id_fk": {
+ "name": "shared_chat_members_shared_chat_id_shared_chats_id_fk",
+ "tableFrom": "shared_chat_members",
+ "tableTo": "shared_chats",
+ "columnsFrom": [
+ "shared_chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_members_user_id_users_id_fk": {
+ "name": "shared_chat_members_user_id_users_id_fk",
+ "tableFrom": "shared_chat_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "shared_chat_members_shared_chat_id_user_id_pk": {
+ "name": "shared_chat_members_shared_chat_id_user_id_pk",
+ "columns": [
+ "shared_chat_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chats": {
+ "name": "shared_chats",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chats_conversation_idx": {
+ "name": "shared_chats_conversation_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "shared_chats_owner_updated_idx": {
+ "name": "shared_chats_owner_updated_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chats_conversation_id_conversations_id_fk": {
+ "name": "shared_chats_conversation_id_conversations_id_fk",
+ "tableFrom": "shared_chats",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chats_owner_id_users_id_fk": {
+ "name": "shared_chats_owner_id_users_id_fk",
+ "tableFrom": "shared_chats",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_compute_usage": {
+ "name": "user_compute_usage",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "minutes_used": {
+ "name": "minutes_used",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_compute_usage_user_id_users_id_fk": {
+ "name": "user_compute_usage_user_id_users_id_fk",
+ "tableFrom": "user_compute_usage",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_environment_variables": {
+ "name": "user_environment_variables",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_value": {
+ "name": "encrypted_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_four": {
+ "name": "last_four",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_environment_variables_user_name_idx": {
+ "name": "user_environment_variables_user_name_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_environment_variables_user_updated_idx": {
+ "name": "user_environment_variables_user_updated_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_environment_variables_user_id_users_id_fk": {
+ "name": "user_environment_variables_user_id_users_id_fk",
+ "tableFrom": "user_environment_variables",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_feature_overrides": {
+ "name": "user_feature_overrides",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_feature_overrides_user_idx": {
+ "name": "user_feature_overrides_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_feature_overrides_organization_id_organizations_id_fk": {
+ "name": "user_feature_overrides_organization_id_organizations_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_feature_overrides_user_id_users_id_fk": {
+ "name": "user_feature_overrides_user_id_users_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_feature_overrides_created_by_users_id_fk": {
+ "name": "user_feature_overrides_created_by_users_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "user_feature_overrides_organization_id_user_id_feature_pk": {
+ "name": "user_feature_overrides_organization_id_user_id_feature_pk",
+ "columns": [
+ "organization_id",
+ "user_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.users": {
+ "name": "users",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "github_user_id": {
+ "name": "github_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "google_user_id": {
+ "name": "google_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "clerk_user_id": {
+ "name": "clerk_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "login": {
+ "name": "login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password_hash": {
+ "name": "password_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avatar_url": {
+ "name": "avatar_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_admin": {
+ "name": "is_admin",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "users_github_user_id_idx": {
+ "name": "users_github_user_id_idx",
+ "columns": [
+ {
+ "expression": "github_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_google_user_id_idx": {
+ "name": "users_google_user_id_idx",
+ "columns": [
+ {
+ "expression": "google_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_clerk_user_id_idx": {
+ "name": "users_clerk_user_id_idx",
+ "columns": [
+ {
+ "expression": "clerk_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_login_idx": {
+ "name": "users_login_idx",
+ "columns": [
+ {
+ "expression": "login",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channel_messages": {
+ "name": "workspace_channel_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_kind": {
+ "name": "author_kind",
+ "type": "channel_message_author_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_label": {
+ "name": "author_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_session_id": {
+ "name": "agent_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mentions": {
+ "name": "mentions",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "mentions_agent": {
+ "name": "mentions_agent",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channel_messages_channel_idx": {
+ "name": "workspace_channel_messages_channel_idx",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_channel_messages_workspace_idx": {
+ "name": "workspace_channel_messages_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channel_messages_channel_id_workspace_channels_id_fk": {
+ "name": "workspace_channel_messages_channel_id_workspace_channels_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "workspace_channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_workspace_id_workspaces_id_fk": {
+ "name": "workspace_channel_messages_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_author_id_users_id_fk": {
+ "name": "workspace_channel_messages_author_id_users_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_agent_session_id_agent_sessions_id_fk": {
+ "name": "workspace_channel_messages_agent_session_id_agent_sessions_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "agent_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channel_reads": {
+ "name": "workspace_channel_reads",
+ "schema": "",
+ "columns": {
+ "channel_id": {
+ "name": "channel_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_read_at": {
+ "name": "last_read_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channel_reads_user_idx": {
+ "name": "workspace_channel_reads_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channel_reads_channel_id_workspace_channels_id_fk": {
+ "name": "workspace_channel_reads_channel_id_workspace_channels_id_fk",
+ "tableFrom": "workspace_channel_reads",
+ "tableTo": "workspace_channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_reads_user_id_users_id_fk": {
+ "name": "workspace_channel_reads_user_id_users_id_fk",
+ "tableFrom": "workspace_channel_reads",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_channel_reads_channel_id_user_id_pk": {
+ "name": "workspace_channel_reads_channel_id_user_id_pk",
+ "columns": [
+ "channel_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channels": {
+ "name": "workspace_channels",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "topic": {
+ "name": "topic",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_access": {
+ "name": "agent_access",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channels_workspace_slug_idx": {
+ "name": "workspace_channels_workspace_slug_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_channels_workspace_idx": {
+ "name": "workspace_channels_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "archived_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channels_workspace_id_workspaces_id_fk": {
+ "name": "workspace_channels_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_channels",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channels_created_by_users_id_fk": {
+ "name": "workspace_channels_created_by_users_id_fk",
+ "tableFrom": "workspace_channels",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_leases": {
+ "name": "workspace_chat_leases",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "holder_id": {
+ "name": "holder_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lease_token": {
+ "name": "lease_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_leases_expiry_idx": {
+ "name": "workspace_chat_leases_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_leases_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_leases_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_leases",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_leases_holder_id_users_id_fk": {
+ "name": "workspace_chat_leases_holder_id_users_id_fk",
+ "tableFrom": "workspace_chat_leases",
+ "tableTo": "users",
+ "columnsFrom": [
+ "holder_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_chat_leases_workspace_id_chat_id_pk": {
+ "name": "workspace_chat_leases_workspace_id_chat_id_pk",
+ "columns": [
+ "workspace_id",
+ "chat_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_participants": {
+ "name": "workspace_chat_participants",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_participants_expiry_idx": {
+ "name": "workspace_chat_participants_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_participants_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_participants_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_participants",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_participants_user_id_users_id_fk": {
+ "name": "workspace_chat_participants_user_id_users_id_fk",
+ "tableFrom": "workspace_chat_participants",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_chat_participants_workspace_id_chat_id_user_id_client_id_pk": {
+ "name": "workspace_chat_participants_workspace_id_chat_id_user_id_client_id_pk",
+ "columns": [
+ "workspace_id",
+ "chat_id",
+ "user_id",
+ "client_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_prompt_receipts": {
+ "name": "workspace_chat_prompt_receipts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_message_id": {
+ "name": "client_message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attachments": {
+ "name": "attachments",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "effort": {
+ "name": "effort",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_prompt_receipts_client_message_idx": {
+ "name": "workspace_chat_prompt_receipts_client_message_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "client_message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_chat_prompt_receipts_chat_created_idx": {
+ "name": "workspace_chat_prompt_receipts_chat_created_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_prompt_receipts_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_prompt_receipts_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_prompt_receipts",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_prompt_receipts_author_id_users_id_fk": {
+ "name": "workspace_chat_prompt_receipts_author_id_users_id_fk",
+ "tableFrom": "workspace_chat_prompt_receipts",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_events": {
+ "name": "workspace_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence": {
+ "name": "sequence",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_events_sequence_idx": {
+ "name": "workspace_events_sequence_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sequence",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_events_workspace_id_workspaces_id_fk": {
+ "name": "workspace_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_events_actor_id_users_id_fk": {
+ "name": "workspace_events_actor_id_users_id_fk",
+ "tableFrom": "workspace_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_invites": {
+ "name": "workspace_invites",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "invitee_email": {
+ "name": "invitee_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invitee_login": {
+ "name": "invitee_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_role": {
+ "name": "access_role",
+ "type": "workspace_access_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'viewer'"
+ },
+ "allow_link": {
+ "name": "allow_link",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_by": {
+ "name": "accepted_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_invites_token_hash_idx": {
+ "name": "workspace_invites_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_invites_workspace_idx": {
+ "name": "workspace_invites_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_invites_workspace_id_workspaces_id_fk": {
+ "name": "workspace_invites_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_invites_created_by_users_id_fk": {
+ "name": "workspace_invites_created_by_users_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_invites_accepted_by_users_id_fk": {
+ "name": "workspace_invites_accepted_by_users_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "accepted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_member_statuses": {
+ "name": "workspace_member_statuses",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emoji": {
+ "name": "emoji",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "headline": {
+ "name": "headline",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_member_statuses_workspace_idx": {
+ "name": "workspace_member_statuses_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_member_statuses_workspace_id_workspaces_id_fk": {
+ "name": "workspace_member_statuses_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_member_statuses",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_member_statuses_user_id_users_id_fk": {
+ "name": "workspace_member_statuses_user_id_users_id_fk",
+ "tableFrom": "workspace_member_statuses",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_member_statuses_workspace_id_user_id_pk": {
+ "name": "workspace_member_statuses_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_members": {
+ "name": "workspace_members",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "member_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "access_role": {
+ "name": "access_role",
+ "type": "workspace_access_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'viewer'"
+ },
+ "can_terminal": {
+ "name": "can_terminal",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "can_merge": {
+ "name": "can_merge",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_members_user_idx": {
+ "name": "workspace_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_members_workspace_id_workspaces_id_fk": {
+ "name": "workspace_members_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_members",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_members_user_id_users_id_fk": {
+ "name": "workspace_members_user_id_users_id_fk",
+ "tableFrom": "workspace_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_members_workspace_id_user_id_pk": {
+ "name": "workspace_members_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_runtime_assignments": {
+ "name": "workspace_runtime_assignments",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "host_id": {
+ "name": "host_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "generation": {
+ "name": "generation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "fencing_token": {
+ "name": "fencing_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "disk_id": {
+ "name": "disk_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "disk_lun": {
+ "name": "disk_lun",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "runtime_state": {
+ "name": "runtime_state",
+ "type": "workspace_runtime_assignment_state",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'assigned'"
+ },
+ "last_used_at": {
+ "name": "last_used_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": {
+ "workspace_runtime_assignments_host_state_idx": {
+ "name": "workspace_runtime_assignments_host_state_idx",
+ "columns": [
+ {
+ "expression": "host_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "runtime_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_runtime_assignments_state_updated_idx": {
+ "name": "workspace_runtime_assignments_state_updated_idx",
+ "columns": [
+ {
+ "expression": "runtime_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_runtime_assignments_workspace_id_workspaces_id_fk": {
+ "name": "workspace_runtime_assignments_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_runtime_assignments",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_runtime_assignments_host_id_runtime_hosts_id_fk": {
+ "name": "workspace_runtime_assignments_host_id_runtime_hosts_id_fk",
+ "tableFrom": "workspace_runtime_assignments",
+ "tableTo": "runtime_hosts",
+ "columnsFrom": [
+ "host_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_runtimes": {
+ "name": "workspace_runtimes",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "sandbox_id": {
+ "name": "sandbox_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "backend": {
+ "name": "backend",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'firecracker'"
+ },
+ "status": {
+ "name": "status",
+ "type": "sandbox_runtime_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'provisioning'"
+ },
+ "provisioned_head_sha": {
+ "name": "provisioned_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "snapshot_ref": {
+ "name": "snapshot_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_heartbeat_at": {
+ "name": "last_heartbeat_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hibernated_at": {
+ "name": "hibernated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provisioned_at": {
+ "name": "provisioned_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stopped_at": {
+ "name": "stopped_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_runtimes_status_updated_idx": {
+ "name": "workspace_runtimes_status_updated_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_runtimes_workspace_id_workspaces_id_fk": {
+ "name": "workspace_runtimes_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_runtimes",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "workspace_runtimes_sandbox_id_unique": {
+ "name": "workspace_runtimes_sandbox_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "sandbox_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_snapshots": {
+ "name": "workspace_snapshots",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "snapshot": {
+ "name": "snapshot",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_bytes": {
+ "name": "total_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_snapshots_updated_idx": {
+ "name": "workspace_snapshots_updated_idx",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_snapshots_workspace_id_workspaces_id_fk": {
+ "name": "workspace_snapshots_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_snapshots",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_state_documents": {
+ "name": "workspace_state_documents",
+ "schema": "",
+ "columns": {
+ "document_name": {
+ "name": "document_name",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state": {
+ "name": "state",
+ "type": "bytea",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_state_documents_workspace_idx": {
+ "name": "workspace_state_documents_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_state_documents_workspace_id_workspaces_id_fk": {
+ "name": "workspace_state_documents_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_state_documents",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspaces": {
+ "name": "workspaces",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_installation_id": {
+ "name": "github_installation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository": {
+ "name": "repository",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repository_visibility": {
+ "name": "repository_visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "default_branch": {
+ "name": "default_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "workspace_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "last_activity_at": {
+ "name": "last_activity_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "hibernate_at": {
+ "name": "hibernate_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspaces_owner_idx": {
+ "name": "workspaces_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_organization_idx": {
+ "name": "workspaces_organization_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_repository_idx": {
+ "name": "workspaces_repository_idx",
+ "columns": [
+ {
+ "expression": "github_repository_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_status_expiry_idx": {
+ "name": "workspaces_status_expiry_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_deleted_idx": {
+ "name": "workspaces_deleted_idx",
+ "columns": [
+ {
+ "expression": "deleted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspaces_owner_id_users_id_fk": {
+ "name": "workspaces_owner_id_users_id_fk",
+ "tableFrom": "workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "workspaces_organization_id_organizations_id_fk": {
+ "name": "workspaces_organization_id_organizations_id_fk",
+ "tableFrom": "workspaces",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.worktrees": {
+ "name": "worktrees",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "worktree_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "worktree_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "review_head_sha": {
+ "name": "review_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_base_sha": {
+ "name": "review_base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_diff_digest": {
+ "name": "review_diff_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_by": {
+ "name": "reviewed_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_at": {
+ "name": "reviewed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "merged_at": {
+ "name": "merged_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "discarded_at": {
+ "name": "discarded_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "worktrees_workspace_name_idx": {
+ "name": "worktrees_workspace_name_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "worktrees_workspace_status_idx": {
+ "name": "worktrees_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "worktrees_workspace_id_workspaces_id_fk": {
+ "name": "worktrees_workspace_id_workspaces_id_fk",
+ "tableFrom": "worktrees",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "worktrees_reviewed_by_users_id_fk": {
+ "name": "worktrees_reviewed_by_users_id_fk",
+ "tableFrom": "worktrees",
+ "tableTo": "users",
+ "columnsFrom": [
+ "reviewed_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.yjs_snapshots": {
+ "name": "yjs_snapshots",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "update_base64": {
+ "name": "update_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state_vector_base64": {
+ "name": "state_vector_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_contents": {
+ "name": "filesystem_contents",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_conflict": {
+ "name": "has_conflict",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "conflict_filesystem_revision": {
+ "name": "conflict_filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_detected_at": {
+ "name": "conflict_detected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolved_at": {
+ "name": "conflict_resolved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolved_by": {
+ "name": "conflict_resolved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolution": {
+ "name": "conflict_resolution",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "yjs_snapshots_worktree_path_idx": {
+ "name": "yjs_snapshots_worktree_path_idx",
+ "columns": [
+ {
+ "expression": "worktree_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "yjs_snapshots_worktree_id_worktrees_id_fk": {
+ "name": "yjs_snapshots_worktree_id_worktrees_id_fk",
+ "tableFrom": "yjs_snapshots",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "yjs_snapshots_conflict_resolved_by_users_id_fk": {
+ "name": "yjs_snapshots_conflict_resolved_by_users_id_fk",
+ "tableFrom": "yjs_snapshots",
+ "tableTo": "users",
+ "columnsFrom": [
+ "conflict_resolved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {
+ "public.access_request_status": {
+ "name": "access_request_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "invited",
+ "declined"
+ ]
+ },
+ "public.agent_brief_status": {
+ "name": "agent_brief_status",
+ "schema": "public",
+ "values": [
+ "planning",
+ "active",
+ "blocked",
+ "paused",
+ "done"
+ ]
+ },
+ "public.agent_session_import_status": {
+ "name": "agent_session_import_status",
+ "schema": "public",
+ "values": [
+ "storing",
+ "stored",
+ "restoring",
+ "ready",
+ "launching",
+ "active",
+ "failed",
+ "deleted"
+ ]
+ },
+ "public.agent_session_kind": {
+ "name": "agent_session_kind",
+ "schema": "public",
+ "values": [
+ "managed",
+ "cli"
+ ]
+ },
+ "public.agent_session_status": {
+ "name": "agent_session_status",
+ "schema": "public",
+ "values": [
+ "idle",
+ "running",
+ "waiting",
+ "completed",
+ "interrupted",
+ "failed"
+ ]
+ },
+ "public.agent_turn_status": {
+ "name": "agent_turn_status",
+ "schema": "public",
+ "values": [
+ "queued",
+ "running",
+ "completed",
+ "interrupted",
+ "failed"
+ ]
+ },
+ "public.brain_entry_kind": {
+ "name": "brain_entry_kind",
+ "schema": "public",
+ "values": [
+ "decision",
+ "attempt",
+ "dead_end",
+ "finding",
+ "convention",
+ "handoff"
+ ]
+ },
+ "public.brain_overlap_kind": {
+ "name": "brain_overlap_kind",
+ "schema": "public",
+ "values": [
+ "duplicate_intent",
+ "file_overlap",
+ "claim_contest"
+ ]
+ },
+ "public.brain_overlap_status": {
+ "name": "brain_overlap_status",
+ "schema": "public",
+ "values": [
+ "open",
+ "acknowledged",
+ "resolved"
+ ]
+ },
+ "public.channel_message_author_kind": {
+ "name": "channel_message_author_kind",
+ "schema": "public",
+ "values": [
+ "member",
+ "agent",
+ "system"
+ ]
+ },
+ "public.claim_status": {
+ "name": "claim_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "released",
+ "expired",
+ "contested"
+ ]
+ },
+ "public.claude_connection_session_status": {
+ "name": "claude_connection_session_status",
+ "schema": "public",
+ "values": [
+ "starting",
+ "awaiting_code",
+ "exchanging",
+ "connected",
+ "failed"
+ ]
+ },
+ "public.cli_client_type": {
+ "name": "cli_client_type",
+ "schema": "public",
+ "values": [
+ "cli",
+ "mobile"
+ ]
+ },
+ "public.cli_device_authorization_status": {
+ "name": "cli_device_authorization_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "approved",
+ "denied"
+ ]
+ },
+ "public.credential_connected_via": {
+ "name": "credential_connected_via",
+ "schema": "public",
+ "values": [
+ "browser",
+ "cli",
+ "api_key"
+ ]
+ },
+ "public.credential_provider": {
+ "name": "credential_provider",
+ "schema": "public",
+ "values": [
+ "anthropic",
+ "openai",
+ "bedrock",
+ "azure_foundry",
+ "cursor",
+ "custom"
+ ]
+ },
+ "public.credential_scope_type": {
+ "name": "credential_scope_type",
+ "schema": "public",
+ "values": [
+ "USER",
+ "WORKSPACE",
+ "ORGANIZATION"
+ ]
+ },
+ "public.credential_type": {
+ "name": "credential_type",
+ "schema": "public",
+ "values": [
+ "API_KEY",
+ "OAUTH_TOKEN",
+ "AWS_BEDROCK_ROLE",
+ "AZURE_ENDPOINT",
+ "HOSTED_CODEX_SUBSCRIPTION"
+ ]
+ },
+ "public.feature_key": {
+ "name": "feature_key",
+ "schema": "public",
+ "values": [
+ "hosted_codex_subscription"
+ ]
+ },
+ "public.feature_override_audit_action": {
+ "name": "feature_override_audit_action",
+ "schema": "public",
+ "values": [
+ "created",
+ "updated",
+ "deleted"
+ ]
+ },
+ "public.gen2_workspace_role": {
+ "name": "gen2_workspace_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "editor",
+ "viewer"
+ ]
+ },
+ "public.gen2_workspace_status": {
+ "name": "gen2_workspace_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "provisioning",
+ "ready",
+ "failed",
+ "stopped",
+ "deleting"
+ ]
+ },
+ "public.member_role": {
+ "name": "member_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "member"
+ ]
+ },
+ "public.coordination_message_status": {
+ "name": "coordination_message_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "delivered",
+ "resolved"
+ ]
+ },
+ "public.mobile_platform": {
+ "name": "mobile_platform",
+ "schema": "public",
+ "values": [
+ "ios",
+ "android"
+ ]
+ },
+ "public.organization_role": {
+ "name": "organization_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "admin",
+ "billing_admin",
+ "member"
+ ]
+ },
+ "public.organization_subscription_status": {
+ "name": "organization_subscription_status",
+ "schema": "public",
+ "values": [
+ "trialing",
+ "active",
+ "past_due",
+ "canceled"
+ ]
+ },
+ "public.provider_credential_status": {
+ "name": "provider_credential_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "reauthorization_required",
+ "revoked",
+ "failed"
+ ]
+ },
+ "public.publication_status": {
+ "name": "publication_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "published",
+ "failed"
+ ]
+ },
+ "public.repository_restore_status": {
+ "name": "repository_restore_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "matched",
+ "restored",
+ "conflicted",
+ "unavailable",
+ "transcript_only"
+ ]
+ },
+ "public.runtime_host_lifecycle": {
+ "name": "runtime_host_lifecycle",
+ "schema": "public",
+ "values": [
+ "provisioning",
+ "ready",
+ "draining",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.sandbox_runtime_status": {
+ "name": "sandbox_runtime_status",
+ "schema": "public",
+ "values": [
+ "provisioning",
+ "ready",
+ "hibernated",
+ "stopping",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.session_continuation_mode": {
+ "name": "session_continuation_mode",
+ "schema": "public",
+ "values": [
+ "managed",
+ "native_resume"
+ ]
+ },
+ "public.subscription_plan": {
+ "name": "subscription_plan",
+ "schema": "public",
+ "values": [
+ "free",
+ "pro",
+ "team",
+ "enterprise"
+ ]
+ },
+ "public.workspace_access_role": {
+ "name": "workspace_access_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "co_steer",
+ "reviewer",
+ "viewer"
+ ]
+ },
+ "public.workspace_runtime_assignment_state": {
+ "name": "workspace_runtime_assignment_state",
+ "schema": "public",
+ "values": [
+ "assigned",
+ "starting",
+ "ready",
+ "draining",
+ "lost"
+ ]
+ },
+ "public.workspace_status": {
+ "name": "workspace_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "provisioning",
+ "ready",
+ "hibernated",
+ "stopping",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.worktree_kind": {
+ "name": "worktree_kind",
+ "schema": "public",
+ "values": [
+ "integration",
+ "agent"
+ ]
+ },
+ "public.worktree_status": {
+ "name": "worktree_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "frozen",
+ "merged",
+ "discarded"
+ ]
+ }
+ },
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
diff --git a/packages/db/drizzle/meta/0056_snapshot.json b/packages/db/drizzle/meta/0056_snapshot.json
new file mode 100644
index 000000000..734d7dad4
--- /dev/null
+++ b/packages/db/drizzle/meta/0056_snapshot.json
@@ -0,0 +1,9406 @@
+{
+ "id": "ebf33200-4429-4e6d-b884-26eabd3e663c",
+ "prevId": "e64fbbe2-1baa-4535-bff9-6ed4775ac8c7",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.access_requests": {
+ "name": "access_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_login": {
+ "name": "github_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "persona": {
+ "name": "persona",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building": {
+ "name": "building",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "referrer": {
+ "name": "referrer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ip_hash": {
+ "name": "ip_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "access_request_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "invited_at": {
+ "name": "invited_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invite_token_hash": {
+ "name": "invite_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invite_token_expires_at": {
+ "name": "invite_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "access_requests_email_idx": {
+ "name": "access_requests_email_idx",
+ "columns": [
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_status_created_idx": {
+ "name": "access_requests_status_created_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_ip_created_idx": {
+ "name": "access_requests_ip_created_idx",
+ "columns": [
+ {
+ "expression": "ip_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_invite_token_hash_idx": {
+ "name": "access_requests_invite_token_hash_idx",
+ "columns": [
+ {
+ "expression": "invite_token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_briefs": {
+ "name": "agent_briefs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "approach_summary": {
+ "name": "approach_summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "plan_steps": {
+ "name": "plan_steps",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "current_step": {
+ "name": "current_step",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "files_likely_to_touch": {
+ "name": "files_likely_to_touch",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "keywords": {
+ "name": "keywords",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_brief_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'planning'"
+ },
+ "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_briefs_session_idx": {
+ "name": "agent_briefs_session_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_briefs_workspace_status_idx": {
+ "name": "agent_briefs_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_briefs_workspace_id_workspaces_id_fk": {
+ "name": "agent_briefs_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_briefs",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_briefs_session_id_agent_sessions_id_fk": {
+ "name": "agent_briefs_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_briefs",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_events": {
+ "name": "agent_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "turn_id": {
+ "name": "turn_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_events_idempotency_idx": {
+ "name": "agent_events_idempotency_idx",
+ "columns": [
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_events_session_created_idx": {
+ "name": "agent_events_session_created_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_events_workspace_id_workspaces_id_fk": {
+ "name": "agent_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_events_session_id_agent_sessions_id_fk": {
+ "name": "agent_events_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_events_turn_id_agent_turns_id_fk": {
+ "name": "agent_events_turn_id_agent_turns_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "agent_turns",
+ "columnsFrom": [
+ "turn_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_session_import_artifacts": {
+ "name": "agent_session_import_artifacts",
+ "schema": "",
+ "columns": {
+ "import_id": {
+ "name": "import_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "media_type": {
+ "name": "media_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plaintext_sha256": {
+ "name": "plaintext_sha256",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plaintext_bytes": {
+ "name": "plaintext_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_payload": {
+ "name": "encrypted_payload",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_session_import_artifacts_created_idx": {
+ "name": "agent_session_import_artifacts_created_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_session_import_artifacts_import_id_agent_session_imports_id_fk": {
+ "name": "agent_session_import_artifacts_import_id_agent_session_imports_id_fk",
+ "tableFrom": "agent_session_import_artifacts",
+ "tableTo": "agent_session_imports",
+ "columnsFrom": [
+ "import_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_session_imports": {
+ "name": "agent_session_imports",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "imported_by": {
+ "name": "imported_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_import_id": {
+ "name": "parent_import_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_session_id": {
+ "name": "agent_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_provider": {
+ "name": "source_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_session_id": {
+ "name": "external_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capsule_schema_version": {
+ "name": "capsule_schema_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capsule_sha256": {
+ "name": "capsule_sha256",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_session_import_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'storing'"
+ },
+ "repository_status": {
+ "name": "repository_status",
+ "type": "repository_restore_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "continuation_mode": {
+ "name": "continuation_mode",
+ "type": "session_continuation_mode",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_session_imports_idempotency_idx": {
+ "name": "agent_session_imports_idempotency_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_workspace_status_idx": {
+ "name": "agent_session_imports_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_importer_idx": {
+ "name": "agent_session_imports_importer_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_source_idx": {
+ "name": "agent_session_imports_source_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_parent_idx": {
+ "name": "agent_session_imports_parent_idx",
+ "columns": [
+ {
+ "expression": "parent_import_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_active_writer_idx": {
+ "name": "agent_session_imports_active_writer_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_session_imports\".\"continuation_mode\" = 'native_resume' and \"agent_session_imports\".\"status\" in ('launching', 'active') and \"agent_session_imports\".\"deleted_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_session_imports_organization_id_organizations_id_fk": {
+ "name": "agent_session_imports_organization_id_organizations_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_workspace_id_workspaces_id_fk": {
+ "name": "agent_session_imports_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_imported_by_users_id_fk": {
+ "name": "agent_session_imports_imported_by_users_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "users",
+ "columnsFrom": [
+ "imported_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_parent_import_id_agent_session_imports_id_fk": {
+ "name": "agent_session_imports_parent_import_id_agent_session_imports_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "agent_session_imports",
+ "columnsFrom": [
+ "parent_import_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_worktree_id_worktrees_id_fk": {
+ "name": "agent_session_imports_worktree_id_worktrees_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_agent_session_id_agent_sessions_id_fk": {
+ "name": "agent_session_imports_agent_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "agent_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_sessions": {
+ "name": "agent_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_number": {
+ "name": "issue_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'Agent'"
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'gpt-5'"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'openai'"
+ },
+ "kind": {
+ "name": "kind",
+ "type": "agent_session_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'managed'"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_session_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'idle'"
+ },
+ "workflow_run_id": {
+ "name": "workflow_run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "interrupted_at": {
+ "name": "interrupted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_sessions_workspace_issue_idx": {
+ "name": "agent_sessions_workspace_issue_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "issue_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_sessions_workspace_status_idx": {
+ "name": "agent_sessions_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_sessions_workspace_id_workspaces_id_fk": {
+ "name": "agent_sessions_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_sessions_worktree_id_worktrees_id_fk": {
+ "name": "agent_sessions_worktree_id_worktrees_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_sessions_created_by_users_id_fk": {
+ "name": "agent_sessions_created_by_users_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_turns": {
+ "name": "agent_turns",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attachments": {
+ "name": "attachments",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_turn_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "workflow_run_id": {
+ "name": "workflow_run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_id": {
+ "name": "response_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output": {
+ "name": "output",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finished_at": {
+ "name": "finished_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_turns_session_created_idx": {
+ "name": "agent_turns_session_created_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_turns_session_id_agent_sessions_id_fk": {
+ "name": "agent_turns_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_turns",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_turns_author_id_users_id_fk": {
+ "name": "agent_turns_author_id_users_id_fk",
+ "tableFrom": "agent_turns",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.brain_entries": {
+ "name": "brain_entries",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "brain_entry_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "paths": {
+ "name": "paths",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "keywords": {
+ "name": "keywords",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "supersedes_id": {
+ "name": "supersedes_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "brain_entries_workspace_created_idx": {
+ "name": "brain_entries_workspace_created_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "brain_entries_workspace_kind_idx": {
+ "name": "brain_entries_workspace_kind_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "brain_entries_workspace_id_workspaces_id_fk": {
+ "name": "brain_entries_workspace_id_workspaces_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_entries_session_id_agent_sessions_id_fk": {
+ "name": "brain_entries_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "brain_entries_author_id_users_id_fk": {
+ "name": "brain_entries_author_id_users_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.brain_overlaps": {
+ "name": "brain_overlaps",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "left_session_id": {
+ "name": "left_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "right_session_id": {
+ "name": "right_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "brain_overlap_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "score": {
+ "name": "score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "evidence": {
+ "name": "evidence",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "rationale": {
+ "name": "rationale",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "status": {
+ "name": "status",
+ "type": "brain_overlap_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "detected_at": {
+ "name": "detected_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": {
+ "brain_overlaps_pair_kind_idx": {
+ "name": "brain_overlaps_pair_kind_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "left_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "right_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "brain_overlaps_workspace_status_idx": {
+ "name": "brain_overlaps_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "brain_overlaps_workspace_id_workspaces_id_fk": {
+ "name": "brain_overlaps_workspace_id_workspaces_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_overlaps_left_session_id_agent_sessions_id_fk": {
+ "name": "brain_overlaps_left_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "left_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_overlaps_right_session_id_agent_sessions_id_fk": {
+ "name": "brain_overlaps_right_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "right_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.claude_connection_sessions": {
+ "name": "claude_connection_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'USER'"
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "claude_connection_session_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'starting'"
+ },
+ "runner_id": {
+ "name": "runner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "authorize_url": {
+ "name": "authorize_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_reason": {
+ "name": "failure_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "claude_connection_sessions_user_idx": {
+ "name": "claude_connection_sessions_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "claude_connection_sessions_expiry_idx": {
+ "name": "claude_connection_sessions_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "claude_connection_sessions_user_id_users_id_fk": {
+ "name": "claude_connection_sessions_user_id_users_id_fk",
+ "tableFrom": "claude_connection_sessions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cli_access_tokens": {
+ "name": "cli_access_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'CoDev CLI'"
+ },
+ "client_type": {
+ "name": "client_type",
+ "type": "cli_client_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'cli'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_used_at": {
+ "name": "last_used_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "cli_access_tokens_token_hash_idx": {
+ "name": "cli_access_tokens_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_access_tokens_user_idx": {
+ "name": "cli_access_tokens_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_access_tokens_expiry_idx": {
+ "name": "cli_access_tokens_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cli_access_tokens_user_id_users_id_fk": {
+ "name": "cli_access_tokens_user_id_users_id_fk",
+ "tableFrom": "cli_access_tokens",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cli_device_authorizations": {
+ "name": "cli_device_authorizations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "device_code_hash": {
+ "name": "device_code_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_code": {
+ "name": "user_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "cli_device_authorization_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "client_type": {
+ "name": "client_type",
+ "type": "cli_client_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'cli'"
+ },
+ "approved_by": {
+ "name": "approved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "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": {
+ "cli_device_authorizations_device_code_idx": {
+ "name": "cli_device_authorizations_device_code_idx",
+ "columns": [
+ {
+ "expression": "device_code_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_device_authorizations_user_code_idx": {
+ "name": "cli_device_authorizations_user_code_idx",
+ "columns": [
+ {
+ "expression": "user_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_device_authorizations_expiry_idx": {
+ "name": "cli_device_authorizations_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cli_device_authorizations_approved_by_users_id_fk": {
+ "name": "cli_device_authorizations_approved_by_users_id_fk",
+ "tableFrom": "cli_device_authorizations",
+ "tableTo": "users",
+ "columnsFrom": [
+ "approved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.collaboration_conflict_resolutions": {
+ "name": "collaboration_conflict_resolutions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resolved_by": {
+ "name": "resolved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "strategy": {
+ "name": "strategy",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "snapshot_revision": {
+ "name": "snapshot_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result_revision": {
+ "name": "result_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "collaboration_conflict_resolutions_document_idx": {
+ "name": "collaboration_conflict_resolutions_document_idx",
+ "columns": [
+ {
+ "expression": "worktree_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "collaboration_conflict_resolutions_worktree_id_worktrees_id_fk": {
+ "name": "collaboration_conflict_resolutions_worktree_id_worktrees_id_fk",
+ "tableFrom": "collaboration_conflict_resolutions",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "collaboration_conflict_resolutions_resolved_by_users_id_fk": {
+ "name": "collaboration_conflict_resolutions_resolved_by_users_id_fk",
+ "tableFrom": "collaboration_conflict_resolutions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "resolved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversation_artifacts": {
+ "name": "conversation_artifacts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_url": {
+ "name": "source_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "downloadable": {
+ "name": "downloadable",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversation_artifacts_conversation_idx": {
+ "name": "conversation_artifacts_conversation_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "conversation_artifacts_message_idx": {
+ "name": "conversation_artifacts_message_idx",
+ "columns": [
+ {
+ "expression": "message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversation_artifacts_conversation_id_conversations_id_fk": {
+ "name": "conversation_artifacts_conversation_id_conversations_id_fk",
+ "tableFrom": "conversation_artifacts",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "conversation_artifacts_message_id_conversation_messages_id_fk": {
+ "name": "conversation_artifacts_message_id_conversation_messages_id_fk",
+ "tableFrom": "conversation_artifacts",
+ "tableTo": "conversation_messages",
+ "columnsFrom": [
+ "message_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversation_messages": {
+ "name": "conversation_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence": {
+ "name": "sequence",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_user_id": {
+ "name": "author_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_name": {
+ "name": "author_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_content_type": {
+ "name": "source_content_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_created_at": {
+ "name": "source_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversation_messages_sequence_idx": {
+ "name": "conversation_messages_sequence_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sequence",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversation_messages_conversation_id_conversations_id_fk": {
+ "name": "conversation_messages_conversation_id_conversations_id_fk",
+ "tableFrom": "conversation_messages",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "conversation_messages_author_user_id_users_id_fk": {
+ "name": "conversation_messages_author_user_id_users_id_fk",
+ "tableFrom": "conversation_messages",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversations": {
+ "name": "conversations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'imported'"
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_provider": {
+ "name": "source_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_external_id": {
+ "name": "source_external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_url": {
+ "name": "source_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_model": {
+ "name": "source_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_updated_at": {
+ "name": "source_updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "warnings": {
+ "name": "warnings",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversations_owner_updated_idx": {
+ "name": "conversations_owner_updated_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "conversations_owner_source_idx": {
+ "name": "conversations_owner_source_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_external_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversations_owner_id_users_id_fk": {
+ "name": "conversations_owner_id_users_id_fk",
+ "tableFrom": "conversations",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.coordination_messages": {
+ "name": "coordination_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "from_session_id": {
+ "name": "from_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "to_session_id": {
+ "name": "to_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "correlation_id": {
+ "name": "correlation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "response_to_id": {
+ "name": "response_to_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "coordination_message_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "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": {
+ "coordination_messages_target_status_idx": {
+ "name": "coordination_messages_target_status_idx",
+ "columns": [
+ {
+ "expression": "to_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "coordination_messages_workspace_id_workspaces_id_fk": {
+ "name": "coordination_messages_workspace_id_workspaces_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coordination_messages_from_session_id_agent_sessions_id_fk": {
+ "name": "coordination_messages_from_session_id_agent_sessions_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "from_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coordination_messages_to_session_id_agent_sessions_id_fk": {
+ "name": "coordination_messages_to_session_id_agent_sessions_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "to_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.design_partner_feedback": {
+ "name": "design_partner_feedback",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "category": {
+ "name": "category",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rating": {
+ "name": "rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "page": {
+ "name": "page",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "release": {
+ "name": "release",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'new'"
+ },
+ "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": {
+ "design_partner_feedback_user_created_idx": {
+ "name": "design_partner_feedback_user_created_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "design_partner_feedback_status_created_idx": {
+ "name": "design_partner_feedback_status_created_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "design_partner_feedback_user_id_users_id_fk": {
+ "name": "design_partner_feedback_user_id_users_id_fk",
+ "tableFrom": "design_partner_feedback",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "design_partner_feedback_workspace_id_workspaces_id_fk": {
+ "name": "design_partner_feedback_workspace_id_workspaces_id_fk",
+ "tableFrom": "design_partner_feedback",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.feature_override_audit_events": {
+ "name": "feature_override_audit_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_user_id": {
+ "name": "target_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_user_id": {
+ "name": "actor_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "feature_override_audit_action",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "previous_enabled": {
+ "name": "previous_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "previous_expires_at": {
+ "name": "previous_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "feature_override_audit_org_created_idx": {
+ "name": "feature_override_audit_org_created_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "feature_override_audit_user_created_idx": {
+ "name": "feature_override_audit_user_created_idx",
+ "columns": [
+ {
+ "expression": "target_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "feature_override_audit_events_organization_id_organizations_id_fk": {
+ "name": "feature_override_audit_events_organization_id_organizations_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "feature_override_audit_events_target_user_id_users_id_fk": {
+ "name": "feature_override_audit_events_target_user_id_users_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "target_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "feature_override_audit_events_actor_user_id_users_id_fk": {
+ "name": "feature_override_audit_events_actor_user_id_users_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_agent_turns": {
+ "name": "gen2_agent_turns",
+ "schema": "",
+ "columns": {
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "output": {
+ "name": "output",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "pending_base64": {
+ "name": "pending_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "exited": {
+ "name": "exited",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "reply_message_id": {
+ "name": "reply_message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_agent_turns_chat_idx": {
+ "name": "gen2_agent_turns_chat_idx",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_agent_turns_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_agent_turns_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_chat_id_gen2_chats_id_fk": {
+ "name": "gen2_agent_turns_chat_id_gen2_chats_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_chats",
+ "columnsFrom": [
+ "chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_user_id_users_id_fk": {
+ "name": "gen2_agent_turns_user_id_users_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_reply_message_id_gen2_chat_messages_id_fk": {
+ "name": "gen2_agent_turns_reply_message_id_gen2_chat_messages_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_chat_messages",
+ "columnsFrom": [
+ "reply_message_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_chat_messages": {
+ "name": "gen2_chat_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "items": {
+ "name": "items",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_chat_messages_chat_idx": {
+ "name": "gen2_chat_messages_chat_idx",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_chat_messages_chat_id_gen2_chats_id_fk": {
+ "name": "gen2_chat_messages_chat_id_gen2_chats_id_fk",
+ "tableFrom": "gen2_chat_messages",
+ "tableTo": "gen2_chats",
+ "columnsFrom": [
+ "chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_chats": {
+ "name": "gen2_chats",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_chats_workspace_updated_idx": {
+ "name": "gen2_chats_workspace_updated_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_chats_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_chats_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_chats",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_chats_created_by_user_id_users_id_fk": {
+ "name": "gen2_chats_created_by_user_id_users_id_fk",
+ "tableFrom": "gen2_chats",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_workspace_members": {
+ "name": "gen2_workspace_members",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "gen2_workspace_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'editor'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_workspace_members_user_idx": {
+ "name": "gen2_workspace_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_workspace_members_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_workspace_members_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_workspace_members",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_workspace_members_user_id_users_id_fk": {
+ "name": "gen2_workspace_members_user_id_users_id_fk",
+ "tableFrom": "gen2_workspace_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "gen2_workspace_members_workspace_id_user_id_pk": {
+ "name": "gen2_workspace_members_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_workspaces": {
+ "name": "gen2_workspaces",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "gen2_workspace_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "sandbox_id": {
+ "name": "sandbox_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_token_hash": {
+ "name": "active_invite_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_created_by_user_id": {
+ "name": "active_invite_created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_role": {
+ "name": "active_invite_role",
+ "type": "gen2_workspace_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_created_at": {
+ "name": "active_invite_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_expires_at": {
+ "name": "active_invite_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_installation_id": {
+ "name": "github_installation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository": {
+ "name": "repository",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_private": {
+ "name": "repository_private",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "default_branch": {
+ "name": "default_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_workspaces_owner_idx": {
+ "name": "gen2_workspaces_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "gen2_workspaces_active_invite_token_hash_idx": {
+ "name": "gen2_workspaces_active_invite_token_hash_idx",
+ "columns": [
+ {
+ "expression": "active_invite_token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_workspaces_owner_id_users_id_fk": {
+ "name": "gen2_workspaces_owner_id_users_id_fk",
+ "tableFrom": "gen2_workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "gen2_workspaces_active_invite_created_by_user_id_users_id_fk": {
+ "name": "gen2_workspaces_active_invite_created_by_user_id_users_id_fk",
+ "tableFrom": "gen2_workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "active_invite_created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_yjs_documents": {
+ "name": "gen2_yjs_documents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'main'"
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "update_base64": {
+ "name": "update_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state_vector_base64": {
+ "name": "state_vector_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_contents": {
+ "name": "filesystem_contents",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_conflict": {
+ "name": "has_conflict",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "conflict_filesystem_revision": {
+ "name": "conflict_filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_detected_at": {
+ "name": "conflict_detected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_yjs_documents_workspace_worktree_path_idx": {
+ "name": "gen2_yjs_documents_workspace_worktree_path_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "worktree_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_yjs_documents_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_yjs_documents_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_yjs_documents",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_connections": {
+ "name": "github_connections",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "encrypted_access_token": {
+ "name": "encrypted_access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_refresh_token": {
+ "name": "encrypted_refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'bearer'"
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "github_connections_access_expiry_idx": {
+ "name": "github_connections_access_expiry_idx",
+ "columns": [
+ {
+ "expression": "access_token_expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "github_connections_user_id_users_id_fk": {
+ "name": "github_connections_user_id_users_id_fk",
+ "tableFrom": "github_connections",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_issue_assignments": {
+ "name": "github_issue_assignments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_number": {
+ "name": "issue_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_issue_id": {
+ "name": "github_issue_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "github_issue_assignments_repository_issue_idx": {
+ "name": "github_issue_assignments_repository_issue_idx",
+ "columns": [
+ {
+ "expression": "github_repository_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "issue_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "github_issue_assignments_session_idx": {
+ "name": "github_issue_assignments_session_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "github_issue_assignments_workspace_idx": {
+ "name": "github_issue_assignments_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "github_issue_assignments_workspace_id_workspaces_id_fk": {
+ "name": "github_issue_assignments_workspace_id_workspaces_id_fk",
+ "tableFrom": "github_issue_assignments",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "github_issue_assignments_session_id_agent_sessions_id_fk": {
+ "name": "github_issue_assignments_session_id_agent_sessions_id_fk",
+ "tableFrom": "github_issue_assignments",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.mobile_push_tokens": {
+ "name": "mobile_push_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expo_push_token": {
+ "name": "expo_push_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "mobile_platform",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "device_id": {
+ "name": "device_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_seen_at": {
+ "name": "last_seen_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": {
+ "mobile_push_tokens_token_idx": {
+ "name": "mobile_push_tokens_token_idx",
+ "columns": [
+ {
+ "expression": "expo_push_token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "mobile_push_tokens_user_idx": {
+ "name": "mobile_push_tokens_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mobile_push_tokens_user_id_users_id_fk": {
+ "name": "mobile_push_tokens_user_id_users_id_fk",
+ "tableFrom": "mobile_push_tokens",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_feature_overrides": {
+ "name": "organization_feature_overrides",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "organization_feature_overrides_organization_id_organizations_id_fk": {
+ "name": "organization_feature_overrides_organization_id_organizations_id_fk",
+ "tableFrom": "organization_feature_overrides",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_feature_overrides_created_by_users_id_fk": {
+ "name": "organization_feature_overrides_created_by_users_id_fk",
+ "tableFrom": "organization_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "organization_feature_overrides_organization_id_feature_pk": {
+ "name": "organization_feature_overrides_organization_id_feature_pk",
+ "columns": [
+ "organization_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_members": {
+ "name": "organization_members",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "organization_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organization_members_user_idx": {
+ "name": "organization_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organization_members_organization_id_organizations_id_fk": {
+ "name": "organization_members_organization_id_organizations_id_fk",
+ "tableFrom": "organization_members",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_members_user_id_users_id_fk": {
+ "name": "organization_members_user_id_users_id_fk",
+ "tableFrom": "organization_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "organization_members_organization_id_user_id_pk": {
+ "name": "organization_members_organization_id_user_id_pk",
+ "columns": [
+ "organization_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_subscriptions": {
+ "name": "organization_subscriptions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "organization_subscription_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_customer_id": {
+ "name": "provider_customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_subscription_id": {
+ "name": "provider_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_period_end": {
+ "name": "current_period_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "canceled_at": {
+ "name": "canceled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organization_subscriptions_org_idx": {
+ "name": "organization_subscriptions_org_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "organization_subscriptions_provider_idx": {
+ "name": "organization_subscriptions_provider_idx",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organization_subscriptions_organization_id_organizations_id_fk": {
+ "name": "organization_subscriptions_organization_id_organizations_id_fk",
+ "tableFrom": "organization_subscriptions",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_subscriptions_plan_id_plans_id_fk": {
+ "name": "organization_subscriptions_plan_id_plans_id_fk",
+ "tableFrom": "organization_subscriptions",
+ "tableTo": "plans",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organizations": {
+ "name": "organizations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organizations_slug_idx": {
+ "name": "organizations_slug_idx",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.page_views": {
+ "name": "page_views",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "referrer": {
+ "name": "referrer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ip_hash": {
+ "name": "ip_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "page_views_created_idx": {
+ "name": "page_views_created_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "page_views_user_created_idx": {
+ "name": "page_views_user_created_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "page_views_path_created_idx": {
+ "name": "page_views_path_created_idx",
+ "columns": [
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "page_views_user_id_users_id_fk": {
+ "name": "page_views_user_id_users_id_fk",
+ "tableFrom": "page_views",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.path_claims": {
+ "name": "path_claims",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path_glob": {
+ "name": "path_glob",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "intent": {
+ "name": "intent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "claim_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "path_claims_session_status_idx": {
+ "name": "path_claims_session_status_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "path_claims_expiry_idx": {
+ "name": "path_claims_expiry_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "path_claims_session_id_agent_sessions_id_fk": {
+ "name": "path_claims_session_id_agent_sessions_id_fk",
+ "tableFrom": "path_claims",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan_entitlements": {
+ "name": "plan_entitlements",
+ "schema": "",
+ "columns": {
+ "plan_id": {
+ "name": "plan_id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "plan_entitlements_plan_id_plans_id_fk": {
+ "name": "plan_entitlements_plan_id_plans_id_fk",
+ "tableFrom": "plan_entitlements",
+ "tableTo": "plans",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "plan_entitlements_plan_id_feature_pk": {
+ "name": "plan_entitlements_plan_id_feature_pk",
+ "columns": [
+ "plan_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plans": {
+ "name": "plans",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.provider_credential_events": {
+ "name": "provider_credential_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "credential_provider",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result": {
+ "name": "result",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "provider_credential_events_credential_created_idx": {
+ "name": "provider_credential_events_credential_created_idx",
+ "columns": [
+ {
+ "expression": "credential_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credential_events_actor_created_idx": {
+ "name": "provider_credential_events_actor_created_idx",
+ "columns": [
+ {
+ "expression": "actor_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "provider_credential_events_actor_id_users_id_fk": {
+ "name": "provider_credential_events_actor_id_users_id_fk",
+ "tableFrom": "provider_credential_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "provider_credential_events_workspace_id_workspaces_id_fk": {
+ "name": "provider_credential_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "provider_credential_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.provider_credentials": {
+ "name": "provider_credentials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "credential_provider",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_type": {
+ "name": "credential_type",
+ "type": "credential_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "priority_order": {
+ "name": "priority_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "encrypted_api_key": {
+ "name": "encrypted_api_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_access_token": {
+ "name": "encrypted_access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_refresh_token": {
+ "name": "encrypted_refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "endpoint_url": {
+ "name": "endpoint_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "aws_role_arn": {
+ "name": "aws_role_arn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_connected": {
+ "name": "is_connected",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_four": {
+ "name": "last_four",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "provider_credential_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "provider_subject_hash": {
+ "name": "provider_subject_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_material": {
+ "name": "encrypted_material",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_refreshed_at": {
+ "name": "last_refreshed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sharing_enabled": {
+ "name": "sharing_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "unavailable_until": {
+ "name": "unavailable_until",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "connected_via": {
+ "name": "connected_via",
+ "type": "credential_connected_via",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled_for_rooms": {
+ "name": "enabled_for_rooms",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "enabled_for_workspace": {
+ "name": "enabled_for_workspace",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "provider_credentials_scope_provider_type_idx": {
+ "name": "provider_credentials_scope_provider_type_idx",
+ "columns": [
+ {
+ "expression": "scope_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scope_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "credential_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credentials_scope_provider_priority_idx": {
+ "name": "provider_credentials_scope_provider_priority_idx",
+ "columns": [
+ {
+ "expression": "scope_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scope_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "priority_order",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credentials_status_idx": {
+ "name": "provider_credentials_status_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "provider_credentials_created_by_users_id_fk": {
+ "name": "provider_credentials_created_by_users_id_fk",
+ "tableFrom": "provider_credentials",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.published_branches": {
+ "name": "published_branches",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "published_by": {
+ "name": "published_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "branch_name": {
+ "name": "branch_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "publication_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "source_head_sha": {
+ "name": "source_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "commit_sha": {
+ "name": "commit_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_id": {
+ "name": "repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "remote_ref": {
+ "name": "remote_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "html_url": {
+ "name": "html_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pull_request_number": {
+ "name": "pull_request_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pull_request_url": {
+ "name": "pull_request_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "request_id": {
+ "name": "request_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "published_at": {
+ "name": "published_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "published_branches_workspace_name_idx": {
+ "name": "published_branches_workspace_name_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "branch_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "published_branches_workspace_request_idx": {
+ "name": "published_branches_workspace_request_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "request_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "published_branches_workspace_status_idx": {
+ "name": "published_branches_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "published_branches_workspace_id_workspaces_id_fk": {
+ "name": "published_branches_workspace_id_workspaces_id_fk",
+ "tableFrom": "published_branches",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "published_branches_published_by_users_id_fk": {
+ "name": "published_branches_published_by_users_id_fk",
+ "tableFrom": "published_branches",
+ "tableTo": "users",
+ "columnsFrom": [
+ "published_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.runtime_hosts": {
+ "name": "runtime_hosts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "runtime_address": {
+ "name": "runtime_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifecycle_state": {
+ "name": "lifecycle_state",
+ "type": "runtime_host_lifecycle",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'provisioning'"
+ },
+ "max_workspace_slots": {
+ "name": "max_workspace_slots",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 4
+ },
+ "free_workspace_slots": {
+ "name": "free_workspace_slots",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 4
+ },
+ "image_version": {
+ "name": "image_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_heartbeat_at": {
+ "name": "last_heartbeat_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "draining_at": {
+ "name": "draining_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "runtime_hosts_provider_id_idx": {
+ "name": "runtime_hosts_provider_id_idx",
+ "columns": [
+ {
+ "expression": "provider_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "runtime_hosts_runtime_address_idx": {
+ "name": "runtime_hosts_runtime_address_idx",
+ "columns": [
+ {
+ "expression": "runtime_address",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "runtime_hosts_capacity_idx": {
+ "name": "runtime_hosts_capacity_idx",
+ "columns": [
+ {
+ "expression": "lifecycle_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "free_workspace_slots",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sandbox_runtime_intervals": {
+ "name": "sandbox_runtime_intervals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ended_at": {
+ "name": "ended_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "sandbox_runtime_intervals_user_open_idx": {
+ "name": "sandbox_runtime_intervals_user_open_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "ended_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "sandbox_runtime_intervals_workspace_open_idx": {
+ "name": "sandbox_runtime_intervals_workspace_open_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "ended_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "sandbox_runtime_intervals_user_id_users_id_fk": {
+ "name": "sandbox_runtime_intervals_user_id_users_id_fk",
+ "tableFrom": "sandbox_runtime_intervals",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sandbox_runtime_intervals_workspace_id_workspaces_id_fk": {
+ "name": "sandbox_runtime_intervals_workspace_id_workspaces_id_fk",
+ "tableFrom": "sandbox_runtime_intervals",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chat_invites": {
+ "name": "shared_chat_invites",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "shared_chat_id": {
+ "name": "shared_chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_token": {
+ "name": "encrypted_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_by": {
+ "name": "accepted_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chat_invites_token_hash_idx": {
+ "name": "shared_chat_invites_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "shared_chat_invites_room_idx": {
+ "name": "shared_chat_invites_room_idx",
+ "columns": [
+ {
+ "expression": "shared_chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chat_invites_shared_chat_id_shared_chats_id_fk": {
+ "name": "shared_chat_invites_shared_chat_id_shared_chats_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "shared_chats",
+ "columnsFrom": [
+ "shared_chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_invites_created_by_users_id_fk": {
+ "name": "shared_chat_invites_created_by_users_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_invites_accepted_by_users_id_fk": {
+ "name": "shared_chat_invites_accepted_by_users_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "accepted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chat_members": {
+ "name": "shared_chat_members",
+ "schema": "",
+ "columns": {
+ "shared_chat_id": {
+ "name": "shared_chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chat_members_user_idx": {
+ "name": "shared_chat_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chat_members_shared_chat_id_shared_chats_id_fk": {
+ "name": "shared_chat_members_shared_chat_id_shared_chats_id_fk",
+ "tableFrom": "shared_chat_members",
+ "tableTo": "shared_chats",
+ "columnsFrom": [
+ "shared_chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_members_user_id_users_id_fk": {
+ "name": "shared_chat_members_user_id_users_id_fk",
+ "tableFrom": "shared_chat_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "shared_chat_members_shared_chat_id_user_id_pk": {
+ "name": "shared_chat_members_shared_chat_id_user_id_pk",
+ "columns": [
+ "shared_chat_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chats": {
+ "name": "shared_chats",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chats_conversation_idx": {
+ "name": "shared_chats_conversation_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "shared_chats_owner_updated_idx": {
+ "name": "shared_chats_owner_updated_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chats_conversation_id_conversations_id_fk": {
+ "name": "shared_chats_conversation_id_conversations_id_fk",
+ "tableFrom": "shared_chats",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chats_owner_id_users_id_fk": {
+ "name": "shared_chats_owner_id_users_id_fk",
+ "tableFrom": "shared_chats",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_compute_usage": {
+ "name": "user_compute_usage",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "minutes_used": {
+ "name": "minutes_used",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_compute_usage_user_id_users_id_fk": {
+ "name": "user_compute_usage_user_id_users_id_fk",
+ "tableFrom": "user_compute_usage",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_environment_variables": {
+ "name": "user_environment_variables",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_value": {
+ "name": "encrypted_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_four": {
+ "name": "last_four",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_environment_variables_user_name_idx": {
+ "name": "user_environment_variables_user_name_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_environment_variables_user_updated_idx": {
+ "name": "user_environment_variables_user_updated_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_environment_variables_user_id_users_id_fk": {
+ "name": "user_environment_variables_user_id_users_id_fk",
+ "tableFrom": "user_environment_variables",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_feature_overrides": {
+ "name": "user_feature_overrides",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_feature_overrides_user_idx": {
+ "name": "user_feature_overrides_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_feature_overrides_organization_id_organizations_id_fk": {
+ "name": "user_feature_overrides_organization_id_organizations_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_feature_overrides_user_id_users_id_fk": {
+ "name": "user_feature_overrides_user_id_users_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_feature_overrides_created_by_users_id_fk": {
+ "name": "user_feature_overrides_created_by_users_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "user_feature_overrides_organization_id_user_id_feature_pk": {
+ "name": "user_feature_overrides_organization_id_user_id_feature_pk",
+ "columns": [
+ "organization_id",
+ "user_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.users": {
+ "name": "users",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "github_user_id": {
+ "name": "github_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "google_user_id": {
+ "name": "google_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "clerk_user_id": {
+ "name": "clerk_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "login": {
+ "name": "login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password_hash": {
+ "name": "password_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avatar_url": {
+ "name": "avatar_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_admin": {
+ "name": "is_admin",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "users_github_user_id_idx": {
+ "name": "users_github_user_id_idx",
+ "columns": [
+ {
+ "expression": "github_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_google_user_id_idx": {
+ "name": "users_google_user_id_idx",
+ "columns": [
+ {
+ "expression": "google_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_clerk_user_id_idx": {
+ "name": "users_clerk_user_id_idx",
+ "columns": [
+ {
+ "expression": "clerk_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_login_idx": {
+ "name": "users_login_idx",
+ "columns": [
+ {
+ "expression": "login",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channel_messages": {
+ "name": "workspace_channel_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_kind": {
+ "name": "author_kind",
+ "type": "channel_message_author_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_label": {
+ "name": "author_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_session_id": {
+ "name": "agent_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mentions": {
+ "name": "mentions",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "mentions_agent": {
+ "name": "mentions_agent",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channel_messages_channel_idx": {
+ "name": "workspace_channel_messages_channel_idx",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_channel_messages_workspace_idx": {
+ "name": "workspace_channel_messages_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channel_messages_channel_id_workspace_channels_id_fk": {
+ "name": "workspace_channel_messages_channel_id_workspace_channels_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "workspace_channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_workspace_id_workspaces_id_fk": {
+ "name": "workspace_channel_messages_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_author_id_users_id_fk": {
+ "name": "workspace_channel_messages_author_id_users_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_agent_session_id_agent_sessions_id_fk": {
+ "name": "workspace_channel_messages_agent_session_id_agent_sessions_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "agent_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channel_reads": {
+ "name": "workspace_channel_reads",
+ "schema": "",
+ "columns": {
+ "channel_id": {
+ "name": "channel_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_read_at": {
+ "name": "last_read_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channel_reads_user_idx": {
+ "name": "workspace_channel_reads_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channel_reads_channel_id_workspace_channels_id_fk": {
+ "name": "workspace_channel_reads_channel_id_workspace_channels_id_fk",
+ "tableFrom": "workspace_channel_reads",
+ "tableTo": "workspace_channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_reads_user_id_users_id_fk": {
+ "name": "workspace_channel_reads_user_id_users_id_fk",
+ "tableFrom": "workspace_channel_reads",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_channel_reads_channel_id_user_id_pk": {
+ "name": "workspace_channel_reads_channel_id_user_id_pk",
+ "columns": [
+ "channel_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channels": {
+ "name": "workspace_channels",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "topic": {
+ "name": "topic",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_access": {
+ "name": "agent_access",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channels_workspace_slug_idx": {
+ "name": "workspace_channels_workspace_slug_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_channels_workspace_idx": {
+ "name": "workspace_channels_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "archived_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channels_workspace_id_workspaces_id_fk": {
+ "name": "workspace_channels_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_channels",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channels_created_by_users_id_fk": {
+ "name": "workspace_channels_created_by_users_id_fk",
+ "tableFrom": "workspace_channels",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_leases": {
+ "name": "workspace_chat_leases",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "holder_id": {
+ "name": "holder_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lease_token": {
+ "name": "lease_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_leases_expiry_idx": {
+ "name": "workspace_chat_leases_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_leases_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_leases_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_leases",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_leases_holder_id_users_id_fk": {
+ "name": "workspace_chat_leases_holder_id_users_id_fk",
+ "tableFrom": "workspace_chat_leases",
+ "tableTo": "users",
+ "columnsFrom": [
+ "holder_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_chat_leases_workspace_id_chat_id_pk": {
+ "name": "workspace_chat_leases_workspace_id_chat_id_pk",
+ "columns": [
+ "workspace_id",
+ "chat_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_participants": {
+ "name": "workspace_chat_participants",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_participants_expiry_idx": {
+ "name": "workspace_chat_participants_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_participants_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_participants_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_participants",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_participants_user_id_users_id_fk": {
+ "name": "workspace_chat_participants_user_id_users_id_fk",
+ "tableFrom": "workspace_chat_participants",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_chat_participants_workspace_id_chat_id_user_id_client_id_pk": {
+ "name": "workspace_chat_participants_workspace_id_chat_id_user_id_client_id_pk",
+ "columns": [
+ "workspace_id",
+ "chat_id",
+ "user_id",
+ "client_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_prompt_receipts": {
+ "name": "workspace_chat_prompt_receipts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_message_id": {
+ "name": "client_message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attachments": {
+ "name": "attachments",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "effort": {
+ "name": "effort",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_prompt_receipts_client_message_idx": {
+ "name": "workspace_chat_prompt_receipts_client_message_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "client_message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_chat_prompt_receipts_chat_created_idx": {
+ "name": "workspace_chat_prompt_receipts_chat_created_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_prompt_receipts_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_prompt_receipts_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_prompt_receipts",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_prompt_receipts_author_id_users_id_fk": {
+ "name": "workspace_chat_prompt_receipts_author_id_users_id_fk",
+ "tableFrom": "workspace_chat_prompt_receipts",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_events": {
+ "name": "workspace_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence": {
+ "name": "sequence",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_events_sequence_idx": {
+ "name": "workspace_events_sequence_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sequence",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_events_workspace_id_workspaces_id_fk": {
+ "name": "workspace_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_events_actor_id_users_id_fk": {
+ "name": "workspace_events_actor_id_users_id_fk",
+ "tableFrom": "workspace_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_invites": {
+ "name": "workspace_invites",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "invitee_email": {
+ "name": "invitee_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invitee_login": {
+ "name": "invitee_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_role": {
+ "name": "access_role",
+ "type": "workspace_access_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'viewer'"
+ },
+ "allow_link": {
+ "name": "allow_link",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_by": {
+ "name": "accepted_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_invites_token_hash_idx": {
+ "name": "workspace_invites_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_invites_workspace_idx": {
+ "name": "workspace_invites_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_invites_workspace_id_workspaces_id_fk": {
+ "name": "workspace_invites_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_invites_created_by_users_id_fk": {
+ "name": "workspace_invites_created_by_users_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_invites_accepted_by_users_id_fk": {
+ "name": "workspace_invites_accepted_by_users_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "accepted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_member_statuses": {
+ "name": "workspace_member_statuses",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emoji": {
+ "name": "emoji",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "headline": {
+ "name": "headline",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_member_statuses_workspace_idx": {
+ "name": "workspace_member_statuses_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_member_statuses_workspace_id_workspaces_id_fk": {
+ "name": "workspace_member_statuses_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_member_statuses",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_member_statuses_user_id_users_id_fk": {
+ "name": "workspace_member_statuses_user_id_users_id_fk",
+ "tableFrom": "workspace_member_statuses",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_member_statuses_workspace_id_user_id_pk": {
+ "name": "workspace_member_statuses_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_members": {
+ "name": "workspace_members",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "member_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "access_role": {
+ "name": "access_role",
+ "type": "workspace_access_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'viewer'"
+ },
+ "can_terminal": {
+ "name": "can_terminal",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "can_merge": {
+ "name": "can_merge",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_members_user_idx": {
+ "name": "workspace_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_members_workspace_id_workspaces_id_fk": {
+ "name": "workspace_members_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_members",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_members_user_id_users_id_fk": {
+ "name": "workspace_members_user_id_users_id_fk",
+ "tableFrom": "workspace_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_members_workspace_id_user_id_pk": {
+ "name": "workspace_members_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_runtime_assignments": {
+ "name": "workspace_runtime_assignments",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "host_id": {
+ "name": "host_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "generation": {
+ "name": "generation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "fencing_token": {
+ "name": "fencing_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "disk_id": {
+ "name": "disk_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "disk_lun": {
+ "name": "disk_lun",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "runtime_state": {
+ "name": "runtime_state",
+ "type": "workspace_runtime_assignment_state",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'assigned'"
+ },
+ "last_used_at": {
+ "name": "last_used_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": {
+ "workspace_runtime_assignments_host_state_idx": {
+ "name": "workspace_runtime_assignments_host_state_idx",
+ "columns": [
+ {
+ "expression": "host_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "runtime_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_runtime_assignments_state_updated_idx": {
+ "name": "workspace_runtime_assignments_state_updated_idx",
+ "columns": [
+ {
+ "expression": "runtime_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_runtime_assignments_workspace_id_workspaces_id_fk": {
+ "name": "workspace_runtime_assignments_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_runtime_assignments",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_runtime_assignments_host_id_runtime_hosts_id_fk": {
+ "name": "workspace_runtime_assignments_host_id_runtime_hosts_id_fk",
+ "tableFrom": "workspace_runtime_assignments",
+ "tableTo": "runtime_hosts",
+ "columnsFrom": [
+ "host_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_runtimes": {
+ "name": "workspace_runtimes",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "sandbox_id": {
+ "name": "sandbox_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "backend": {
+ "name": "backend",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'firecracker'"
+ },
+ "status": {
+ "name": "status",
+ "type": "sandbox_runtime_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'provisioning'"
+ },
+ "provisioned_head_sha": {
+ "name": "provisioned_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "snapshot_ref": {
+ "name": "snapshot_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_heartbeat_at": {
+ "name": "last_heartbeat_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hibernated_at": {
+ "name": "hibernated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provisioned_at": {
+ "name": "provisioned_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stopped_at": {
+ "name": "stopped_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_runtimes_status_updated_idx": {
+ "name": "workspace_runtimes_status_updated_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_runtimes_workspace_id_workspaces_id_fk": {
+ "name": "workspace_runtimes_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_runtimes",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "workspace_runtimes_sandbox_id_unique": {
+ "name": "workspace_runtimes_sandbox_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "sandbox_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_snapshots": {
+ "name": "workspace_snapshots",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "snapshot": {
+ "name": "snapshot",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_bytes": {
+ "name": "total_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_snapshots_updated_idx": {
+ "name": "workspace_snapshots_updated_idx",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_snapshots_workspace_id_workspaces_id_fk": {
+ "name": "workspace_snapshots_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_snapshots",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_state_documents": {
+ "name": "workspace_state_documents",
+ "schema": "",
+ "columns": {
+ "document_name": {
+ "name": "document_name",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state": {
+ "name": "state",
+ "type": "bytea",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_state_documents_workspace_idx": {
+ "name": "workspace_state_documents_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_state_documents_workspace_id_workspaces_id_fk": {
+ "name": "workspace_state_documents_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_state_documents",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspaces": {
+ "name": "workspaces",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_installation_id": {
+ "name": "github_installation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository": {
+ "name": "repository",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repository_visibility": {
+ "name": "repository_visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "default_branch": {
+ "name": "default_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "workspace_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "last_activity_at": {
+ "name": "last_activity_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "hibernate_at": {
+ "name": "hibernate_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspaces_owner_idx": {
+ "name": "workspaces_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_organization_idx": {
+ "name": "workspaces_organization_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_repository_idx": {
+ "name": "workspaces_repository_idx",
+ "columns": [
+ {
+ "expression": "github_repository_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_status_expiry_idx": {
+ "name": "workspaces_status_expiry_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_deleted_idx": {
+ "name": "workspaces_deleted_idx",
+ "columns": [
+ {
+ "expression": "deleted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspaces_owner_id_users_id_fk": {
+ "name": "workspaces_owner_id_users_id_fk",
+ "tableFrom": "workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "workspaces_organization_id_organizations_id_fk": {
+ "name": "workspaces_organization_id_organizations_id_fk",
+ "tableFrom": "workspaces",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.worktrees": {
+ "name": "worktrees",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "worktree_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "worktree_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "review_head_sha": {
+ "name": "review_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_base_sha": {
+ "name": "review_base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_diff_digest": {
+ "name": "review_diff_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_by": {
+ "name": "reviewed_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_at": {
+ "name": "reviewed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "merged_at": {
+ "name": "merged_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "discarded_at": {
+ "name": "discarded_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "worktrees_workspace_name_idx": {
+ "name": "worktrees_workspace_name_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "worktrees_workspace_status_idx": {
+ "name": "worktrees_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "worktrees_workspace_id_workspaces_id_fk": {
+ "name": "worktrees_workspace_id_workspaces_id_fk",
+ "tableFrom": "worktrees",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "worktrees_reviewed_by_users_id_fk": {
+ "name": "worktrees_reviewed_by_users_id_fk",
+ "tableFrom": "worktrees",
+ "tableTo": "users",
+ "columnsFrom": [
+ "reviewed_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.yjs_snapshots": {
+ "name": "yjs_snapshots",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "update_base64": {
+ "name": "update_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state_vector_base64": {
+ "name": "state_vector_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_contents": {
+ "name": "filesystem_contents",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_conflict": {
+ "name": "has_conflict",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "conflict_filesystem_revision": {
+ "name": "conflict_filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_detected_at": {
+ "name": "conflict_detected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolved_at": {
+ "name": "conflict_resolved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolved_by": {
+ "name": "conflict_resolved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolution": {
+ "name": "conflict_resolution",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "yjs_snapshots_worktree_path_idx": {
+ "name": "yjs_snapshots_worktree_path_idx",
+ "columns": [
+ {
+ "expression": "worktree_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "yjs_snapshots_worktree_id_worktrees_id_fk": {
+ "name": "yjs_snapshots_worktree_id_worktrees_id_fk",
+ "tableFrom": "yjs_snapshots",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "yjs_snapshots_conflict_resolved_by_users_id_fk": {
+ "name": "yjs_snapshots_conflict_resolved_by_users_id_fk",
+ "tableFrom": "yjs_snapshots",
+ "tableTo": "users",
+ "columnsFrom": [
+ "conflict_resolved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {
+ "public.access_request_status": {
+ "name": "access_request_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "invited",
+ "declined"
+ ]
+ },
+ "public.agent_brief_status": {
+ "name": "agent_brief_status",
+ "schema": "public",
+ "values": [
+ "planning",
+ "active",
+ "blocked",
+ "paused",
+ "done"
+ ]
+ },
+ "public.agent_session_import_status": {
+ "name": "agent_session_import_status",
+ "schema": "public",
+ "values": [
+ "storing",
+ "stored",
+ "restoring",
+ "ready",
+ "launching",
+ "active",
+ "failed",
+ "deleted"
+ ]
+ },
+ "public.agent_session_kind": {
+ "name": "agent_session_kind",
+ "schema": "public",
+ "values": [
+ "managed",
+ "cli"
+ ]
+ },
+ "public.agent_session_status": {
+ "name": "agent_session_status",
+ "schema": "public",
+ "values": [
+ "idle",
+ "running",
+ "waiting",
+ "completed",
+ "interrupted",
+ "failed"
+ ]
+ },
+ "public.agent_turn_status": {
+ "name": "agent_turn_status",
+ "schema": "public",
+ "values": [
+ "queued",
+ "running",
+ "completed",
+ "interrupted",
+ "failed"
+ ]
+ },
+ "public.brain_entry_kind": {
+ "name": "brain_entry_kind",
+ "schema": "public",
+ "values": [
+ "decision",
+ "attempt",
+ "dead_end",
+ "finding",
+ "convention",
+ "handoff"
+ ]
+ },
+ "public.brain_overlap_kind": {
+ "name": "brain_overlap_kind",
+ "schema": "public",
+ "values": [
+ "duplicate_intent",
+ "file_overlap",
+ "claim_contest"
+ ]
+ },
+ "public.brain_overlap_status": {
+ "name": "brain_overlap_status",
+ "schema": "public",
+ "values": [
+ "open",
+ "acknowledged",
+ "resolved"
+ ]
+ },
+ "public.channel_message_author_kind": {
+ "name": "channel_message_author_kind",
+ "schema": "public",
+ "values": [
+ "member",
+ "agent",
+ "system"
+ ]
+ },
+ "public.claim_status": {
+ "name": "claim_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "released",
+ "expired",
+ "contested"
+ ]
+ },
+ "public.claude_connection_session_status": {
+ "name": "claude_connection_session_status",
+ "schema": "public",
+ "values": [
+ "starting",
+ "awaiting_code",
+ "exchanging",
+ "connected",
+ "failed"
+ ]
+ },
+ "public.cli_client_type": {
+ "name": "cli_client_type",
+ "schema": "public",
+ "values": [
+ "cli",
+ "mobile"
+ ]
+ },
+ "public.cli_device_authorization_status": {
+ "name": "cli_device_authorization_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "approved",
+ "denied"
+ ]
+ },
+ "public.credential_connected_via": {
+ "name": "credential_connected_via",
+ "schema": "public",
+ "values": [
+ "browser",
+ "cli",
+ "api_key"
+ ]
+ },
+ "public.credential_provider": {
+ "name": "credential_provider",
+ "schema": "public",
+ "values": [
+ "anthropic",
+ "openai",
+ "bedrock",
+ "azure_foundry",
+ "cursor",
+ "custom"
+ ]
+ },
+ "public.credential_scope_type": {
+ "name": "credential_scope_type",
+ "schema": "public",
+ "values": [
+ "USER",
+ "WORKSPACE",
+ "ORGANIZATION"
+ ]
+ },
+ "public.credential_type": {
+ "name": "credential_type",
+ "schema": "public",
+ "values": [
+ "API_KEY",
+ "OAUTH_TOKEN",
+ "AWS_BEDROCK_ROLE",
+ "AZURE_ENDPOINT",
+ "HOSTED_CODEX_SUBSCRIPTION"
+ ]
+ },
+ "public.feature_key": {
+ "name": "feature_key",
+ "schema": "public",
+ "values": [
+ "hosted_codex_subscription"
+ ]
+ },
+ "public.feature_override_audit_action": {
+ "name": "feature_override_audit_action",
+ "schema": "public",
+ "values": [
+ "created",
+ "updated",
+ "deleted"
+ ]
+ },
+ "public.gen2_workspace_role": {
+ "name": "gen2_workspace_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "editor",
+ "viewer"
+ ]
+ },
+ "public.gen2_workspace_status": {
+ "name": "gen2_workspace_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "provisioning",
+ "ready",
+ "failed",
+ "stopped",
+ "deleting"
+ ]
+ },
+ "public.member_role": {
+ "name": "member_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "member"
+ ]
+ },
+ "public.coordination_message_status": {
+ "name": "coordination_message_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "delivered",
+ "resolved"
+ ]
+ },
+ "public.mobile_platform": {
+ "name": "mobile_platform",
+ "schema": "public",
+ "values": [
+ "ios",
+ "android"
+ ]
+ },
+ "public.organization_role": {
+ "name": "organization_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "admin",
+ "billing_admin",
+ "member"
+ ]
+ },
+ "public.organization_subscription_status": {
+ "name": "organization_subscription_status",
+ "schema": "public",
+ "values": [
+ "trialing",
+ "active",
+ "past_due",
+ "canceled"
+ ]
+ },
+ "public.provider_credential_status": {
+ "name": "provider_credential_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "reauthorization_required",
+ "revoked",
+ "failed"
+ ]
+ },
+ "public.publication_status": {
+ "name": "publication_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "published",
+ "failed"
+ ]
+ },
+ "public.repository_restore_status": {
+ "name": "repository_restore_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "matched",
+ "restored",
+ "conflicted",
+ "unavailable",
+ "transcript_only"
+ ]
+ },
+ "public.runtime_host_lifecycle": {
+ "name": "runtime_host_lifecycle",
+ "schema": "public",
+ "values": [
+ "provisioning",
+ "ready",
+ "draining",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.sandbox_runtime_status": {
+ "name": "sandbox_runtime_status",
+ "schema": "public",
+ "values": [
+ "provisioning",
+ "ready",
+ "hibernated",
+ "stopping",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.session_continuation_mode": {
+ "name": "session_continuation_mode",
+ "schema": "public",
+ "values": [
+ "managed",
+ "native_resume"
+ ]
+ },
+ "public.subscription_plan": {
+ "name": "subscription_plan",
+ "schema": "public",
+ "values": [
+ "free",
+ "pro",
+ "team",
+ "enterprise"
+ ]
+ },
+ "public.workspace_access_role": {
+ "name": "workspace_access_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "co_steer",
+ "reviewer",
+ "viewer"
+ ]
+ },
+ "public.workspace_runtime_assignment_state": {
+ "name": "workspace_runtime_assignment_state",
+ "schema": "public",
+ "values": [
+ "assigned",
+ "starting",
+ "ready",
+ "draining",
+ "lost"
+ ]
+ },
+ "public.workspace_status": {
+ "name": "workspace_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "provisioning",
+ "ready",
+ "hibernated",
+ "stopping",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.worktree_kind": {
+ "name": "worktree_kind",
+ "schema": "public",
+ "values": [
+ "integration",
+ "agent"
+ ]
+ },
+ "public.worktree_status": {
+ "name": "worktree_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "frozen",
+ "merged",
+ "discarded"
+ ]
+ }
+ },
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
diff --git a/packages/db/drizzle/meta/0057_snapshot.json b/packages/db/drizzle/meta/0057_snapshot.json
new file mode 100644
index 000000000..b3366da54
--- /dev/null
+++ b/packages/db/drizzle/meta/0057_snapshot.json
@@ -0,0 +1,9789 @@
+{
+ "id": "4930dc43-f415-4adf-a344-84200be83e7b",
+ "prevId": "ebf33200-4429-4e6d-b884-26eabd3e663c",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.access_requests": {
+ "name": "access_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_login": {
+ "name": "github_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "persona": {
+ "name": "persona",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building": {
+ "name": "building",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "referrer": {
+ "name": "referrer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ip_hash": {
+ "name": "ip_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "access_request_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "invited_at": {
+ "name": "invited_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invite_token_hash": {
+ "name": "invite_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invite_token_expires_at": {
+ "name": "invite_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "access_requests_email_idx": {
+ "name": "access_requests_email_idx",
+ "columns": [
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_status_created_idx": {
+ "name": "access_requests_status_created_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_ip_created_idx": {
+ "name": "access_requests_ip_created_idx",
+ "columns": [
+ {
+ "expression": "ip_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_invite_token_hash_idx": {
+ "name": "access_requests_invite_token_hash_idx",
+ "columns": [
+ {
+ "expression": "invite_token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_briefs": {
+ "name": "agent_briefs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "approach_summary": {
+ "name": "approach_summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "plan_steps": {
+ "name": "plan_steps",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "current_step": {
+ "name": "current_step",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "files_likely_to_touch": {
+ "name": "files_likely_to_touch",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "keywords": {
+ "name": "keywords",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_brief_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'planning'"
+ },
+ "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_briefs_session_idx": {
+ "name": "agent_briefs_session_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_briefs_workspace_status_idx": {
+ "name": "agent_briefs_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_briefs_workspace_id_workspaces_id_fk": {
+ "name": "agent_briefs_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_briefs",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_briefs_session_id_agent_sessions_id_fk": {
+ "name": "agent_briefs_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_briefs",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_events": {
+ "name": "agent_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "turn_id": {
+ "name": "turn_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_events_idempotency_idx": {
+ "name": "agent_events_idempotency_idx",
+ "columns": [
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_events_session_created_idx": {
+ "name": "agent_events_session_created_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_events_workspace_id_workspaces_id_fk": {
+ "name": "agent_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_events_session_id_agent_sessions_id_fk": {
+ "name": "agent_events_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_events_turn_id_agent_turns_id_fk": {
+ "name": "agent_events_turn_id_agent_turns_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "agent_turns",
+ "columnsFrom": [
+ "turn_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_session_import_artifacts": {
+ "name": "agent_session_import_artifacts",
+ "schema": "",
+ "columns": {
+ "import_id": {
+ "name": "import_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "media_type": {
+ "name": "media_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plaintext_sha256": {
+ "name": "plaintext_sha256",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plaintext_bytes": {
+ "name": "plaintext_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_payload": {
+ "name": "encrypted_payload",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_session_import_artifacts_created_idx": {
+ "name": "agent_session_import_artifacts_created_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_session_import_artifacts_import_id_agent_session_imports_id_fk": {
+ "name": "agent_session_import_artifacts_import_id_agent_session_imports_id_fk",
+ "tableFrom": "agent_session_import_artifacts",
+ "tableTo": "agent_session_imports",
+ "columnsFrom": [
+ "import_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_session_imports": {
+ "name": "agent_session_imports",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "imported_by": {
+ "name": "imported_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_import_id": {
+ "name": "parent_import_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_session_id": {
+ "name": "agent_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_provider": {
+ "name": "source_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_session_id": {
+ "name": "external_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capsule_schema_version": {
+ "name": "capsule_schema_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capsule_sha256": {
+ "name": "capsule_sha256",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_session_import_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'storing'"
+ },
+ "repository_status": {
+ "name": "repository_status",
+ "type": "repository_restore_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "continuation_mode": {
+ "name": "continuation_mode",
+ "type": "session_continuation_mode",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_session_imports_idempotency_idx": {
+ "name": "agent_session_imports_idempotency_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_workspace_status_idx": {
+ "name": "agent_session_imports_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_importer_idx": {
+ "name": "agent_session_imports_importer_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_source_idx": {
+ "name": "agent_session_imports_source_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_parent_idx": {
+ "name": "agent_session_imports_parent_idx",
+ "columns": [
+ {
+ "expression": "parent_import_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_active_writer_idx": {
+ "name": "agent_session_imports_active_writer_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_session_imports\".\"continuation_mode\" = 'native_resume' and \"agent_session_imports\".\"status\" in ('launching', 'active') and \"agent_session_imports\".\"deleted_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_session_imports_organization_id_organizations_id_fk": {
+ "name": "agent_session_imports_organization_id_organizations_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_workspace_id_workspaces_id_fk": {
+ "name": "agent_session_imports_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_imported_by_users_id_fk": {
+ "name": "agent_session_imports_imported_by_users_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "users",
+ "columnsFrom": [
+ "imported_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_parent_import_id_agent_session_imports_id_fk": {
+ "name": "agent_session_imports_parent_import_id_agent_session_imports_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "agent_session_imports",
+ "columnsFrom": [
+ "parent_import_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_worktree_id_worktrees_id_fk": {
+ "name": "agent_session_imports_worktree_id_worktrees_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_agent_session_id_agent_sessions_id_fk": {
+ "name": "agent_session_imports_agent_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "agent_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_sessions": {
+ "name": "agent_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_number": {
+ "name": "issue_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'Agent'"
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'gpt-5'"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'openai'"
+ },
+ "kind": {
+ "name": "kind",
+ "type": "agent_session_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'managed'"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_session_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'idle'"
+ },
+ "workflow_run_id": {
+ "name": "workflow_run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "interrupted_at": {
+ "name": "interrupted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_sessions_workspace_issue_idx": {
+ "name": "agent_sessions_workspace_issue_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "issue_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_sessions_workspace_status_idx": {
+ "name": "agent_sessions_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_sessions_workspace_id_workspaces_id_fk": {
+ "name": "agent_sessions_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_sessions_worktree_id_worktrees_id_fk": {
+ "name": "agent_sessions_worktree_id_worktrees_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_sessions_created_by_users_id_fk": {
+ "name": "agent_sessions_created_by_users_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_turns": {
+ "name": "agent_turns",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attachments": {
+ "name": "attachments",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_turn_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "workflow_run_id": {
+ "name": "workflow_run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_id": {
+ "name": "response_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output": {
+ "name": "output",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finished_at": {
+ "name": "finished_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_turns_session_created_idx": {
+ "name": "agent_turns_session_created_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_turns_session_id_agent_sessions_id_fk": {
+ "name": "agent_turns_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_turns",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_turns_author_id_users_id_fk": {
+ "name": "agent_turns_author_id_users_id_fk",
+ "tableFrom": "agent_turns",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.brain_entries": {
+ "name": "brain_entries",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "brain_entry_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "paths": {
+ "name": "paths",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "keywords": {
+ "name": "keywords",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "supersedes_id": {
+ "name": "supersedes_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "brain_entries_workspace_created_idx": {
+ "name": "brain_entries_workspace_created_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "brain_entries_workspace_kind_idx": {
+ "name": "brain_entries_workspace_kind_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "brain_entries_workspace_id_workspaces_id_fk": {
+ "name": "brain_entries_workspace_id_workspaces_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_entries_session_id_agent_sessions_id_fk": {
+ "name": "brain_entries_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "brain_entries_author_id_users_id_fk": {
+ "name": "brain_entries_author_id_users_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.brain_overlaps": {
+ "name": "brain_overlaps",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "left_session_id": {
+ "name": "left_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "right_session_id": {
+ "name": "right_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "brain_overlap_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "score": {
+ "name": "score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "evidence": {
+ "name": "evidence",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "rationale": {
+ "name": "rationale",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "status": {
+ "name": "status",
+ "type": "brain_overlap_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "detected_at": {
+ "name": "detected_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": {
+ "brain_overlaps_pair_kind_idx": {
+ "name": "brain_overlaps_pair_kind_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "left_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "right_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "brain_overlaps_workspace_status_idx": {
+ "name": "brain_overlaps_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "brain_overlaps_workspace_id_workspaces_id_fk": {
+ "name": "brain_overlaps_workspace_id_workspaces_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_overlaps_left_session_id_agent_sessions_id_fk": {
+ "name": "brain_overlaps_left_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "left_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_overlaps_right_session_id_agent_sessions_id_fk": {
+ "name": "brain_overlaps_right_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "right_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.claude_connection_sessions": {
+ "name": "claude_connection_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'USER'"
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "claude_connection_session_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'starting'"
+ },
+ "runner_id": {
+ "name": "runner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "authorize_url": {
+ "name": "authorize_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_reason": {
+ "name": "failure_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "claude_connection_sessions_user_idx": {
+ "name": "claude_connection_sessions_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "claude_connection_sessions_expiry_idx": {
+ "name": "claude_connection_sessions_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "claude_connection_sessions_user_id_users_id_fk": {
+ "name": "claude_connection_sessions_user_id_users_id_fk",
+ "tableFrom": "claude_connection_sessions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cli_access_tokens": {
+ "name": "cli_access_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'CoDev CLI'"
+ },
+ "client_type": {
+ "name": "client_type",
+ "type": "cli_client_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'cli'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_used_at": {
+ "name": "last_used_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "cli_access_tokens_token_hash_idx": {
+ "name": "cli_access_tokens_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_access_tokens_user_idx": {
+ "name": "cli_access_tokens_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_access_tokens_expiry_idx": {
+ "name": "cli_access_tokens_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cli_access_tokens_user_id_users_id_fk": {
+ "name": "cli_access_tokens_user_id_users_id_fk",
+ "tableFrom": "cli_access_tokens",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cli_device_authorizations": {
+ "name": "cli_device_authorizations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "device_code_hash": {
+ "name": "device_code_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_code": {
+ "name": "user_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "cli_device_authorization_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "client_type": {
+ "name": "client_type",
+ "type": "cli_client_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'cli'"
+ },
+ "approved_by": {
+ "name": "approved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "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": {
+ "cli_device_authorizations_device_code_idx": {
+ "name": "cli_device_authorizations_device_code_idx",
+ "columns": [
+ {
+ "expression": "device_code_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_device_authorizations_user_code_idx": {
+ "name": "cli_device_authorizations_user_code_idx",
+ "columns": [
+ {
+ "expression": "user_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_device_authorizations_expiry_idx": {
+ "name": "cli_device_authorizations_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cli_device_authorizations_approved_by_users_id_fk": {
+ "name": "cli_device_authorizations_approved_by_users_id_fk",
+ "tableFrom": "cli_device_authorizations",
+ "tableTo": "users",
+ "columnsFrom": [
+ "approved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.collaboration_conflict_resolutions": {
+ "name": "collaboration_conflict_resolutions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resolved_by": {
+ "name": "resolved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "strategy": {
+ "name": "strategy",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "snapshot_revision": {
+ "name": "snapshot_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result_revision": {
+ "name": "result_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "collaboration_conflict_resolutions_document_idx": {
+ "name": "collaboration_conflict_resolutions_document_idx",
+ "columns": [
+ {
+ "expression": "worktree_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "collaboration_conflict_resolutions_worktree_id_worktrees_id_fk": {
+ "name": "collaboration_conflict_resolutions_worktree_id_worktrees_id_fk",
+ "tableFrom": "collaboration_conflict_resolutions",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "collaboration_conflict_resolutions_resolved_by_users_id_fk": {
+ "name": "collaboration_conflict_resolutions_resolved_by_users_id_fk",
+ "tableFrom": "collaboration_conflict_resolutions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "resolved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversation_artifacts": {
+ "name": "conversation_artifacts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_url": {
+ "name": "source_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "downloadable": {
+ "name": "downloadable",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversation_artifacts_conversation_idx": {
+ "name": "conversation_artifacts_conversation_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "conversation_artifacts_message_idx": {
+ "name": "conversation_artifacts_message_idx",
+ "columns": [
+ {
+ "expression": "message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversation_artifacts_conversation_id_conversations_id_fk": {
+ "name": "conversation_artifacts_conversation_id_conversations_id_fk",
+ "tableFrom": "conversation_artifacts",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "conversation_artifacts_message_id_conversation_messages_id_fk": {
+ "name": "conversation_artifacts_message_id_conversation_messages_id_fk",
+ "tableFrom": "conversation_artifacts",
+ "tableTo": "conversation_messages",
+ "columnsFrom": [
+ "message_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversation_messages": {
+ "name": "conversation_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence": {
+ "name": "sequence",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_user_id": {
+ "name": "author_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_name": {
+ "name": "author_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_content_type": {
+ "name": "source_content_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_created_at": {
+ "name": "source_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversation_messages_sequence_idx": {
+ "name": "conversation_messages_sequence_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sequence",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversation_messages_conversation_id_conversations_id_fk": {
+ "name": "conversation_messages_conversation_id_conversations_id_fk",
+ "tableFrom": "conversation_messages",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "conversation_messages_author_user_id_users_id_fk": {
+ "name": "conversation_messages_author_user_id_users_id_fk",
+ "tableFrom": "conversation_messages",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversations": {
+ "name": "conversations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'imported'"
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_provider": {
+ "name": "source_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_external_id": {
+ "name": "source_external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_url": {
+ "name": "source_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_model": {
+ "name": "source_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_updated_at": {
+ "name": "source_updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "warnings": {
+ "name": "warnings",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversations_owner_updated_idx": {
+ "name": "conversations_owner_updated_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "conversations_owner_source_idx": {
+ "name": "conversations_owner_source_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_external_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversations_owner_id_users_id_fk": {
+ "name": "conversations_owner_id_users_id_fk",
+ "tableFrom": "conversations",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.coordination_messages": {
+ "name": "coordination_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "from_session_id": {
+ "name": "from_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "to_session_id": {
+ "name": "to_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "correlation_id": {
+ "name": "correlation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "response_to_id": {
+ "name": "response_to_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "coordination_message_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "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": {
+ "coordination_messages_target_status_idx": {
+ "name": "coordination_messages_target_status_idx",
+ "columns": [
+ {
+ "expression": "to_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "coordination_messages_workspace_id_workspaces_id_fk": {
+ "name": "coordination_messages_workspace_id_workspaces_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coordination_messages_from_session_id_agent_sessions_id_fk": {
+ "name": "coordination_messages_from_session_id_agent_sessions_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "from_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coordination_messages_to_session_id_agent_sessions_id_fk": {
+ "name": "coordination_messages_to_session_id_agent_sessions_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "to_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.design_partner_feedback": {
+ "name": "design_partner_feedback",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "category": {
+ "name": "category",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rating": {
+ "name": "rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "page": {
+ "name": "page",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "release": {
+ "name": "release",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'new'"
+ },
+ "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": {
+ "design_partner_feedback_user_created_idx": {
+ "name": "design_partner_feedback_user_created_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "design_partner_feedback_status_created_idx": {
+ "name": "design_partner_feedback_status_created_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "design_partner_feedback_user_id_users_id_fk": {
+ "name": "design_partner_feedback_user_id_users_id_fk",
+ "tableFrom": "design_partner_feedback",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "design_partner_feedback_workspace_id_workspaces_id_fk": {
+ "name": "design_partner_feedback_workspace_id_workspaces_id_fk",
+ "tableFrom": "design_partner_feedback",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.feature_override_audit_events": {
+ "name": "feature_override_audit_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_user_id": {
+ "name": "target_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_user_id": {
+ "name": "actor_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "feature_override_audit_action",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "previous_enabled": {
+ "name": "previous_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "previous_expires_at": {
+ "name": "previous_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "feature_override_audit_org_created_idx": {
+ "name": "feature_override_audit_org_created_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "feature_override_audit_user_created_idx": {
+ "name": "feature_override_audit_user_created_idx",
+ "columns": [
+ {
+ "expression": "target_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "feature_override_audit_events_organization_id_organizations_id_fk": {
+ "name": "feature_override_audit_events_organization_id_organizations_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "feature_override_audit_events_target_user_id_users_id_fk": {
+ "name": "feature_override_audit_events_target_user_id_users_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "target_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "feature_override_audit_events_actor_user_id_users_id_fk": {
+ "name": "feature_override_audit_events_actor_user_id_users_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_agent_turns": {
+ "name": "gen2_agent_turns",
+ "schema": "",
+ "columns": {
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "output": {
+ "name": "output",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "pending_base64": {
+ "name": "pending_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "exited": {
+ "name": "exited",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "reply_message_id": {
+ "name": "reply_message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_agent_turns_chat_idx": {
+ "name": "gen2_agent_turns_chat_idx",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_agent_turns_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_agent_turns_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_chat_id_gen2_chats_id_fk": {
+ "name": "gen2_agent_turns_chat_id_gen2_chats_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_chats",
+ "columnsFrom": [
+ "chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_user_id_users_id_fk": {
+ "name": "gen2_agent_turns_user_id_users_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_reply_message_id_gen2_chat_messages_id_fk": {
+ "name": "gen2_agent_turns_reply_message_id_gen2_chat_messages_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_chat_messages",
+ "columnsFrom": [
+ "reply_message_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_chat_messages": {
+ "name": "gen2_chat_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "items": {
+ "name": "items",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_chat_messages_chat_idx": {
+ "name": "gen2_chat_messages_chat_idx",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_chat_messages_chat_id_gen2_chats_id_fk": {
+ "name": "gen2_chat_messages_chat_id_gen2_chats_id_fk",
+ "tableFrom": "gen2_chat_messages",
+ "tableTo": "gen2_chats",
+ "columnsFrom": [
+ "chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_chats": {
+ "name": "gen2_chats",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_chats_workspace_updated_idx": {
+ "name": "gen2_chats_workspace_updated_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_chats_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_chats_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_chats",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_chats_created_by_user_id_users_id_fk": {
+ "name": "gen2_chats_created_by_user_id_users_id_fk",
+ "tableFrom": "gen2_chats",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_superset_run_events": {
+ "name": "gen2_superset_run_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "run_id": {
+ "name": "run_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result": {
+ "name": "result",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_superset_run_events_run_created_idx": {
+ "name": "gen2_superset_run_events_run_created_idx",
+ "columns": [
+ {
+ "expression": "run_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_superset_run_events_run_id_gen2_superset_runs_id_fk": {
+ "name": "gen2_superset_run_events_run_id_gen2_superset_runs_id_fk",
+ "tableFrom": "gen2_superset_run_events",
+ "tableTo": "gen2_superset_runs",
+ "columnsFrom": [
+ "run_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_run_events_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_superset_run_events_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_superset_run_events",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_run_events_actor_id_users_id_fk": {
+ "name": "gen2_superset_run_events_actor_id_users_id_fk",
+ "tableFrom": "gen2_superset_run_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_superset_runs": {
+ "name": "gen2_superset_runs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "host_workspace_id": {
+ "name": "host_workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "host_terminal_id": {
+ "name": "host_terminal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "host_agent_session_id": {
+ "name": "host_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "credential_provider",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_revision": {
+ "name": "credential_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "gen2_superset_run_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'creating'"
+ },
+ "lease_claimed": {
+ "name": "lease_claimed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "exit_reason": {
+ "name": "exit_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "recovery_count": {
+ "name": "recovery_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_superset_runs_workspace_idempotency_idx": {
+ "name": "gen2_superset_runs_workspace_idempotency_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "gen2_superset_runs_workspace_status_idx": {
+ "name": "gen2_superset_runs_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "gen2_superset_runs_chat_idx": {
+ "name": "gen2_superset_runs_chat_idx",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_superset_runs_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_superset_runs_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_runs_chat_id_gen2_chats_id_fk": {
+ "name": "gen2_superset_runs_chat_id_gen2_chats_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "gen2_chats",
+ "columnsFrom": [
+ "chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_runs_created_by_users_id_fk": {
+ "name": "gen2_superset_runs_created_by_users_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_runs_connection_id_provider_credentials_id_fk": {
+ "name": "gen2_superset_runs_connection_id_provider_credentials_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "provider_credentials",
+ "columnsFrom": [
+ "connection_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_workspace_members": {
+ "name": "gen2_workspace_members",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "gen2_workspace_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'editor'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_workspace_members_user_idx": {
+ "name": "gen2_workspace_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_workspace_members_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_workspace_members_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_workspace_members",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_workspace_members_user_id_users_id_fk": {
+ "name": "gen2_workspace_members_user_id_users_id_fk",
+ "tableFrom": "gen2_workspace_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "gen2_workspace_members_workspace_id_user_id_pk": {
+ "name": "gen2_workspace_members_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_workspaces": {
+ "name": "gen2_workspaces",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "gen2_workspace_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "sandbox_id": {
+ "name": "sandbox_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_token_hash": {
+ "name": "active_invite_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_created_by_user_id": {
+ "name": "active_invite_created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_role": {
+ "name": "active_invite_role",
+ "type": "gen2_workspace_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_created_at": {
+ "name": "active_invite_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_expires_at": {
+ "name": "active_invite_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_installation_id": {
+ "name": "github_installation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository": {
+ "name": "repository",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_private": {
+ "name": "repository_private",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "default_branch": {
+ "name": "default_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_workspaces_owner_idx": {
+ "name": "gen2_workspaces_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "gen2_workspaces_active_invite_token_hash_idx": {
+ "name": "gen2_workspaces_active_invite_token_hash_idx",
+ "columns": [
+ {
+ "expression": "active_invite_token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_workspaces_owner_id_users_id_fk": {
+ "name": "gen2_workspaces_owner_id_users_id_fk",
+ "tableFrom": "gen2_workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "gen2_workspaces_active_invite_created_by_user_id_users_id_fk": {
+ "name": "gen2_workspaces_active_invite_created_by_user_id_users_id_fk",
+ "tableFrom": "gen2_workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "active_invite_created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_yjs_documents": {
+ "name": "gen2_yjs_documents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'main'"
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "update_base64": {
+ "name": "update_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state_vector_base64": {
+ "name": "state_vector_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_contents": {
+ "name": "filesystem_contents",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_conflict": {
+ "name": "has_conflict",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "conflict_filesystem_revision": {
+ "name": "conflict_filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_detected_at": {
+ "name": "conflict_detected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_yjs_documents_workspace_worktree_path_idx": {
+ "name": "gen2_yjs_documents_workspace_worktree_path_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "worktree_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_yjs_documents_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_yjs_documents_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_yjs_documents",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_connections": {
+ "name": "github_connections",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "encrypted_access_token": {
+ "name": "encrypted_access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_refresh_token": {
+ "name": "encrypted_refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'bearer'"
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "github_connections_access_expiry_idx": {
+ "name": "github_connections_access_expiry_idx",
+ "columns": [
+ {
+ "expression": "access_token_expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "github_connections_user_id_users_id_fk": {
+ "name": "github_connections_user_id_users_id_fk",
+ "tableFrom": "github_connections",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_issue_assignments": {
+ "name": "github_issue_assignments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_number": {
+ "name": "issue_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_issue_id": {
+ "name": "github_issue_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "github_issue_assignments_repository_issue_idx": {
+ "name": "github_issue_assignments_repository_issue_idx",
+ "columns": [
+ {
+ "expression": "github_repository_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "issue_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "github_issue_assignments_session_idx": {
+ "name": "github_issue_assignments_session_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "github_issue_assignments_workspace_idx": {
+ "name": "github_issue_assignments_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "github_issue_assignments_workspace_id_workspaces_id_fk": {
+ "name": "github_issue_assignments_workspace_id_workspaces_id_fk",
+ "tableFrom": "github_issue_assignments",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "github_issue_assignments_session_id_agent_sessions_id_fk": {
+ "name": "github_issue_assignments_session_id_agent_sessions_id_fk",
+ "tableFrom": "github_issue_assignments",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.mobile_push_tokens": {
+ "name": "mobile_push_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expo_push_token": {
+ "name": "expo_push_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "mobile_platform",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "device_id": {
+ "name": "device_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_seen_at": {
+ "name": "last_seen_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": {
+ "mobile_push_tokens_token_idx": {
+ "name": "mobile_push_tokens_token_idx",
+ "columns": [
+ {
+ "expression": "expo_push_token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "mobile_push_tokens_user_idx": {
+ "name": "mobile_push_tokens_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mobile_push_tokens_user_id_users_id_fk": {
+ "name": "mobile_push_tokens_user_id_users_id_fk",
+ "tableFrom": "mobile_push_tokens",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_feature_overrides": {
+ "name": "organization_feature_overrides",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "organization_feature_overrides_organization_id_organizations_id_fk": {
+ "name": "organization_feature_overrides_organization_id_organizations_id_fk",
+ "tableFrom": "organization_feature_overrides",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_feature_overrides_created_by_users_id_fk": {
+ "name": "organization_feature_overrides_created_by_users_id_fk",
+ "tableFrom": "organization_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "organization_feature_overrides_organization_id_feature_pk": {
+ "name": "organization_feature_overrides_organization_id_feature_pk",
+ "columns": [
+ "organization_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_members": {
+ "name": "organization_members",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "organization_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organization_members_user_idx": {
+ "name": "organization_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organization_members_organization_id_organizations_id_fk": {
+ "name": "organization_members_organization_id_organizations_id_fk",
+ "tableFrom": "organization_members",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_members_user_id_users_id_fk": {
+ "name": "organization_members_user_id_users_id_fk",
+ "tableFrom": "organization_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "organization_members_organization_id_user_id_pk": {
+ "name": "organization_members_organization_id_user_id_pk",
+ "columns": [
+ "organization_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_subscriptions": {
+ "name": "organization_subscriptions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "organization_subscription_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_customer_id": {
+ "name": "provider_customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_subscription_id": {
+ "name": "provider_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_period_end": {
+ "name": "current_period_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "canceled_at": {
+ "name": "canceled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organization_subscriptions_org_idx": {
+ "name": "organization_subscriptions_org_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "organization_subscriptions_provider_idx": {
+ "name": "organization_subscriptions_provider_idx",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organization_subscriptions_organization_id_organizations_id_fk": {
+ "name": "organization_subscriptions_organization_id_organizations_id_fk",
+ "tableFrom": "organization_subscriptions",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_subscriptions_plan_id_plans_id_fk": {
+ "name": "organization_subscriptions_plan_id_plans_id_fk",
+ "tableFrom": "organization_subscriptions",
+ "tableTo": "plans",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organizations": {
+ "name": "organizations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organizations_slug_idx": {
+ "name": "organizations_slug_idx",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.page_views": {
+ "name": "page_views",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "referrer": {
+ "name": "referrer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ip_hash": {
+ "name": "ip_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "page_views_created_idx": {
+ "name": "page_views_created_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "page_views_user_created_idx": {
+ "name": "page_views_user_created_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "page_views_path_created_idx": {
+ "name": "page_views_path_created_idx",
+ "columns": [
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "page_views_user_id_users_id_fk": {
+ "name": "page_views_user_id_users_id_fk",
+ "tableFrom": "page_views",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.path_claims": {
+ "name": "path_claims",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path_glob": {
+ "name": "path_glob",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "intent": {
+ "name": "intent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "claim_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "path_claims_session_status_idx": {
+ "name": "path_claims_session_status_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "path_claims_expiry_idx": {
+ "name": "path_claims_expiry_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "path_claims_session_id_agent_sessions_id_fk": {
+ "name": "path_claims_session_id_agent_sessions_id_fk",
+ "tableFrom": "path_claims",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan_entitlements": {
+ "name": "plan_entitlements",
+ "schema": "",
+ "columns": {
+ "plan_id": {
+ "name": "plan_id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "plan_entitlements_plan_id_plans_id_fk": {
+ "name": "plan_entitlements_plan_id_plans_id_fk",
+ "tableFrom": "plan_entitlements",
+ "tableTo": "plans",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "plan_entitlements_plan_id_feature_pk": {
+ "name": "plan_entitlements_plan_id_feature_pk",
+ "columns": [
+ "plan_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plans": {
+ "name": "plans",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.provider_credential_events": {
+ "name": "provider_credential_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "credential_provider",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result": {
+ "name": "result",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "provider_credential_events_credential_created_idx": {
+ "name": "provider_credential_events_credential_created_idx",
+ "columns": [
+ {
+ "expression": "credential_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credential_events_actor_created_idx": {
+ "name": "provider_credential_events_actor_created_idx",
+ "columns": [
+ {
+ "expression": "actor_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "provider_credential_events_actor_id_users_id_fk": {
+ "name": "provider_credential_events_actor_id_users_id_fk",
+ "tableFrom": "provider_credential_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "provider_credential_events_workspace_id_workspaces_id_fk": {
+ "name": "provider_credential_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "provider_credential_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.provider_credentials": {
+ "name": "provider_credentials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "credential_provider",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_type": {
+ "name": "credential_type",
+ "type": "credential_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "priority_order": {
+ "name": "priority_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "encrypted_api_key": {
+ "name": "encrypted_api_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_access_token": {
+ "name": "encrypted_access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_refresh_token": {
+ "name": "encrypted_refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "endpoint_url": {
+ "name": "endpoint_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "aws_role_arn": {
+ "name": "aws_role_arn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_connected": {
+ "name": "is_connected",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_four": {
+ "name": "last_four",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "provider_credential_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "provider_subject_hash": {
+ "name": "provider_subject_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_material": {
+ "name": "encrypted_material",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_refreshed_at": {
+ "name": "last_refreshed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sharing_enabled": {
+ "name": "sharing_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "unavailable_until": {
+ "name": "unavailable_until",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "connected_via": {
+ "name": "connected_via",
+ "type": "credential_connected_via",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled_for_rooms": {
+ "name": "enabled_for_rooms",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "enabled_for_workspace": {
+ "name": "enabled_for_workspace",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "provider_credentials_scope_provider_type_idx": {
+ "name": "provider_credentials_scope_provider_type_idx",
+ "columns": [
+ {
+ "expression": "scope_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scope_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "credential_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credentials_scope_provider_priority_idx": {
+ "name": "provider_credentials_scope_provider_priority_idx",
+ "columns": [
+ {
+ "expression": "scope_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scope_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "priority_order",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credentials_status_idx": {
+ "name": "provider_credentials_status_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "provider_credentials_created_by_users_id_fk": {
+ "name": "provider_credentials_created_by_users_id_fk",
+ "tableFrom": "provider_credentials",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.published_branches": {
+ "name": "published_branches",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "published_by": {
+ "name": "published_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "branch_name": {
+ "name": "branch_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "publication_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "source_head_sha": {
+ "name": "source_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "commit_sha": {
+ "name": "commit_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_id": {
+ "name": "repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "remote_ref": {
+ "name": "remote_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "html_url": {
+ "name": "html_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pull_request_number": {
+ "name": "pull_request_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pull_request_url": {
+ "name": "pull_request_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "request_id": {
+ "name": "request_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "published_at": {
+ "name": "published_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "published_branches_workspace_name_idx": {
+ "name": "published_branches_workspace_name_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "branch_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "published_branches_workspace_request_idx": {
+ "name": "published_branches_workspace_request_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "request_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "published_branches_workspace_status_idx": {
+ "name": "published_branches_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "published_branches_workspace_id_workspaces_id_fk": {
+ "name": "published_branches_workspace_id_workspaces_id_fk",
+ "tableFrom": "published_branches",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "published_branches_published_by_users_id_fk": {
+ "name": "published_branches_published_by_users_id_fk",
+ "tableFrom": "published_branches",
+ "tableTo": "users",
+ "columnsFrom": [
+ "published_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.runtime_hosts": {
+ "name": "runtime_hosts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "runtime_address": {
+ "name": "runtime_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifecycle_state": {
+ "name": "lifecycle_state",
+ "type": "runtime_host_lifecycle",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'provisioning'"
+ },
+ "max_workspace_slots": {
+ "name": "max_workspace_slots",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 4
+ },
+ "free_workspace_slots": {
+ "name": "free_workspace_slots",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 4
+ },
+ "image_version": {
+ "name": "image_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_heartbeat_at": {
+ "name": "last_heartbeat_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "draining_at": {
+ "name": "draining_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "runtime_hosts_provider_id_idx": {
+ "name": "runtime_hosts_provider_id_idx",
+ "columns": [
+ {
+ "expression": "provider_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "runtime_hosts_runtime_address_idx": {
+ "name": "runtime_hosts_runtime_address_idx",
+ "columns": [
+ {
+ "expression": "runtime_address",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "runtime_hosts_capacity_idx": {
+ "name": "runtime_hosts_capacity_idx",
+ "columns": [
+ {
+ "expression": "lifecycle_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "free_workspace_slots",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sandbox_runtime_intervals": {
+ "name": "sandbox_runtime_intervals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ended_at": {
+ "name": "ended_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "sandbox_runtime_intervals_user_open_idx": {
+ "name": "sandbox_runtime_intervals_user_open_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "ended_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "sandbox_runtime_intervals_workspace_open_idx": {
+ "name": "sandbox_runtime_intervals_workspace_open_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "ended_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "sandbox_runtime_intervals_user_id_users_id_fk": {
+ "name": "sandbox_runtime_intervals_user_id_users_id_fk",
+ "tableFrom": "sandbox_runtime_intervals",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sandbox_runtime_intervals_workspace_id_workspaces_id_fk": {
+ "name": "sandbox_runtime_intervals_workspace_id_workspaces_id_fk",
+ "tableFrom": "sandbox_runtime_intervals",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chat_invites": {
+ "name": "shared_chat_invites",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "shared_chat_id": {
+ "name": "shared_chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_token": {
+ "name": "encrypted_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_by": {
+ "name": "accepted_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chat_invites_token_hash_idx": {
+ "name": "shared_chat_invites_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "shared_chat_invites_room_idx": {
+ "name": "shared_chat_invites_room_idx",
+ "columns": [
+ {
+ "expression": "shared_chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chat_invites_shared_chat_id_shared_chats_id_fk": {
+ "name": "shared_chat_invites_shared_chat_id_shared_chats_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "shared_chats",
+ "columnsFrom": [
+ "shared_chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_invites_created_by_users_id_fk": {
+ "name": "shared_chat_invites_created_by_users_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_invites_accepted_by_users_id_fk": {
+ "name": "shared_chat_invites_accepted_by_users_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "accepted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chat_members": {
+ "name": "shared_chat_members",
+ "schema": "",
+ "columns": {
+ "shared_chat_id": {
+ "name": "shared_chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chat_members_user_idx": {
+ "name": "shared_chat_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chat_members_shared_chat_id_shared_chats_id_fk": {
+ "name": "shared_chat_members_shared_chat_id_shared_chats_id_fk",
+ "tableFrom": "shared_chat_members",
+ "tableTo": "shared_chats",
+ "columnsFrom": [
+ "shared_chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_members_user_id_users_id_fk": {
+ "name": "shared_chat_members_user_id_users_id_fk",
+ "tableFrom": "shared_chat_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "shared_chat_members_shared_chat_id_user_id_pk": {
+ "name": "shared_chat_members_shared_chat_id_user_id_pk",
+ "columns": [
+ "shared_chat_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chats": {
+ "name": "shared_chats",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chats_conversation_idx": {
+ "name": "shared_chats_conversation_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "shared_chats_owner_updated_idx": {
+ "name": "shared_chats_owner_updated_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chats_conversation_id_conversations_id_fk": {
+ "name": "shared_chats_conversation_id_conversations_id_fk",
+ "tableFrom": "shared_chats",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chats_owner_id_users_id_fk": {
+ "name": "shared_chats_owner_id_users_id_fk",
+ "tableFrom": "shared_chats",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_compute_usage": {
+ "name": "user_compute_usage",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "minutes_used": {
+ "name": "minutes_used",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_compute_usage_user_id_users_id_fk": {
+ "name": "user_compute_usage_user_id_users_id_fk",
+ "tableFrom": "user_compute_usage",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_environment_variables": {
+ "name": "user_environment_variables",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_value": {
+ "name": "encrypted_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_four": {
+ "name": "last_four",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_environment_variables_user_name_idx": {
+ "name": "user_environment_variables_user_name_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_environment_variables_user_updated_idx": {
+ "name": "user_environment_variables_user_updated_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_environment_variables_user_id_users_id_fk": {
+ "name": "user_environment_variables_user_id_users_id_fk",
+ "tableFrom": "user_environment_variables",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_feature_overrides": {
+ "name": "user_feature_overrides",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_feature_overrides_user_idx": {
+ "name": "user_feature_overrides_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_feature_overrides_organization_id_organizations_id_fk": {
+ "name": "user_feature_overrides_organization_id_organizations_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_feature_overrides_user_id_users_id_fk": {
+ "name": "user_feature_overrides_user_id_users_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_feature_overrides_created_by_users_id_fk": {
+ "name": "user_feature_overrides_created_by_users_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "user_feature_overrides_organization_id_user_id_feature_pk": {
+ "name": "user_feature_overrides_organization_id_user_id_feature_pk",
+ "columns": [
+ "organization_id",
+ "user_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.users": {
+ "name": "users",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "github_user_id": {
+ "name": "github_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "google_user_id": {
+ "name": "google_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "clerk_user_id": {
+ "name": "clerk_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "login": {
+ "name": "login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password_hash": {
+ "name": "password_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avatar_url": {
+ "name": "avatar_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_admin": {
+ "name": "is_admin",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "users_github_user_id_idx": {
+ "name": "users_github_user_id_idx",
+ "columns": [
+ {
+ "expression": "github_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_google_user_id_idx": {
+ "name": "users_google_user_id_idx",
+ "columns": [
+ {
+ "expression": "google_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_clerk_user_id_idx": {
+ "name": "users_clerk_user_id_idx",
+ "columns": [
+ {
+ "expression": "clerk_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_login_idx": {
+ "name": "users_login_idx",
+ "columns": [
+ {
+ "expression": "login",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channel_messages": {
+ "name": "workspace_channel_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_kind": {
+ "name": "author_kind",
+ "type": "channel_message_author_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_label": {
+ "name": "author_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_session_id": {
+ "name": "agent_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mentions": {
+ "name": "mentions",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "mentions_agent": {
+ "name": "mentions_agent",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channel_messages_channel_idx": {
+ "name": "workspace_channel_messages_channel_idx",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_channel_messages_workspace_idx": {
+ "name": "workspace_channel_messages_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channel_messages_channel_id_workspace_channels_id_fk": {
+ "name": "workspace_channel_messages_channel_id_workspace_channels_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "workspace_channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_workspace_id_workspaces_id_fk": {
+ "name": "workspace_channel_messages_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_author_id_users_id_fk": {
+ "name": "workspace_channel_messages_author_id_users_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_agent_session_id_agent_sessions_id_fk": {
+ "name": "workspace_channel_messages_agent_session_id_agent_sessions_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "agent_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channel_reads": {
+ "name": "workspace_channel_reads",
+ "schema": "",
+ "columns": {
+ "channel_id": {
+ "name": "channel_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_read_at": {
+ "name": "last_read_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channel_reads_user_idx": {
+ "name": "workspace_channel_reads_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channel_reads_channel_id_workspace_channels_id_fk": {
+ "name": "workspace_channel_reads_channel_id_workspace_channels_id_fk",
+ "tableFrom": "workspace_channel_reads",
+ "tableTo": "workspace_channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_reads_user_id_users_id_fk": {
+ "name": "workspace_channel_reads_user_id_users_id_fk",
+ "tableFrom": "workspace_channel_reads",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_channel_reads_channel_id_user_id_pk": {
+ "name": "workspace_channel_reads_channel_id_user_id_pk",
+ "columns": [
+ "channel_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channels": {
+ "name": "workspace_channels",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "topic": {
+ "name": "topic",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_access": {
+ "name": "agent_access",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channels_workspace_slug_idx": {
+ "name": "workspace_channels_workspace_slug_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_channels_workspace_idx": {
+ "name": "workspace_channels_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "archived_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channels_workspace_id_workspaces_id_fk": {
+ "name": "workspace_channels_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_channels",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channels_created_by_users_id_fk": {
+ "name": "workspace_channels_created_by_users_id_fk",
+ "tableFrom": "workspace_channels",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_leases": {
+ "name": "workspace_chat_leases",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "holder_id": {
+ "name": "holder_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lease_token": {
+ "name": "lease_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_leases_expiry_idx": {
+ "name": "workspace_chat_leases_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_leases_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_leases_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_leases",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_leases_holder_id_users_id_fk": {
+ "name": "workspace_chat_leases_holder_id_users_id_fk",
+ "tableFrom": "workspace_chat_leases",
+ "tableTo": "users",
+ "columnsFrom": [
+ "holder_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_chat_leases_workspace_id_chat_id_pk": {
+ "name": "workspace_chat_leases_workspace_id_chat_id_pk",
+ "columns": [
+ "workspace_id",
+ "chat_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_participants": {
+ "name": "workspace_chat_participants",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_participants_expiry_idx": {
+ "name": "workspace_chat_participants_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_participants_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_participants_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_participants",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_participants_user_id_users_id_fk": {
+ "name": "workspace_chat_participants_user_id_users_id_fk",
+ "tableFrom": "workspace_chat_participants",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_chat_participants_workspace_id_chat_id_user_id_client_id_pk": {
+ "name": "workspace_chat_participants_workspace_id_chat_id_user_id_client_id_pk",
+ "columns": [
+ "workspace_id",
+ "chat_id",
+ "user_id",
+ "client_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_prompt_receipts": {
+ "name": "workspace_chat_prompt_receipts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_message_id": {
+ "name": "client_message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attachments": {
+ "name": "attachments",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "effort": {
+ "name": "effort",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_prompt_receipts_client_message_idx": {
+ "name": "workspace_chat_prompt_receipts_client_message_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "client_message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_chat_prompt_receipts_chat_created_idx": {
+ "name": "workspace_chat_prompt_receipts_chat_created_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_prompt_receipts_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_prompt_receipts_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_prompt_receipts",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_prompt_receipts_author_id_users_id_fk": {
+ "name": "workspace_chat_prompt_receipts_author_id_users_id_fk",
+ "tableFrom": "workspace_chat_prompt_receipts",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_events": {
+ "name": "workspace_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence": {
+ "name": "sequence",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_events_sequence_idx": {
+ "name": "workspace_events_sequence_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sequence",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_events_workspace_id_workspaces_id_fk": {
+ "name": "workspace_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_events_actor_id_users_id_fk": {
+ "name": "workspace_events_actor_id_users_id_fk",
+ "tableFrom": "workspace_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_invites": {
+ "name": "workspace_invites",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "invitee_email": {
+ "name": "invitee_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invitee_login": {
+ "name": "invitee_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_role": {
+ "name": "access_role",
+ "type": "workspace_access_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'viewer'"
+ },
+ "allow_link": {
+ "name": "allow_link",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_by": {
+ "name": "accepted_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_invites_token_hash_idx": {
+ "name": "workspace_invites_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_invites_workspace_idx": {
+ "name": "workspace_invites_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_invites_workspace_id_workspaces_id_fk": {
+ "name": "workspace_invites_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_invites_created_by_users_id_fk": {
+ "name": "workspace_invites_created_by_users_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_invites_accepted_by_users_id_fk": {
+ "name": "workspace_invites_accepted_by_users_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "accepted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_member_statuses": {
+ "name": "workspace_member_statuses",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emoji": {
+ "name": "emoji",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "headline": {
+ "name": "headline",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_member_statuses_workspace_idx": {
+ "name": "workspace_member_statuses_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_member_statuses_workspace_id_workspaces_id_fk": {
+ "name": "workspace_member_statuses_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_member_statuses",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_member_statuses_user_id_users_id_fk": {
+ "name": "workspace_member_statuses_user_id_users_id_fk",
+ "tableFrom": "workspace_member_statuses",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_member_statuses_workspace_id_user_id_pk": {
+ "name": "workspace_member_statuses_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_members": {
+ "name": "workspace_members",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "member_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "access_role": {
+ "name": "access_role",
+ "type": "workspace_access_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'viewer'"
+ },
+ "can_terminal": {
+ "name": "can_terminal",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "can_merge": {
+ "name": "can_merge",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_members_user_idx": {
+ "name": "workspace_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_members_workspace_id_workspaces_id_fk": {
+ "name": "workspace_members_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_members",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_members_user_id_users_id_fk": {
+ "name": "workspace_members_user_id_users_id_fk",
+ "tableFrom": "workspace_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_members_workspace_id_user_id_pk": {
+ "name": "workspace_members_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_runtime_assignments": {
+ "name": "workspace_runtime_assignments",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "host_id": {
+ "name": "host_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "generation": {
+ "name": "generation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "fencing_token": {
+ "name": "fencing_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "disk_id": {
+ "name": "disk_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "disk_lun": {
+ "name": "disk_lun",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "runtime_state": {
+ "name": "runtime_state",
+ "type": "workspace_runtime_assignment_state",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'assigned'"
+ },
+ "last_used_at": {
+ "name": "last_used_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": {
+ "workspace_runtime_assignments_host_state_idx": {
+ "name": "workspace_runtime_assignments_host_state_idx",
+ "columns": [
+ {
+ "expression": "host_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "runtime_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_runtime_assignments_state_updated_idx": {
+ "name": "workspace_runtime_assignments_state_updated_idx",
+ "columns": [
+ {
+ "expression": "runtime_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_runtime_assignments_workspace_id_workspaces_id_fk": {
+ "name": "workspace_runtime_assignments_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_runtime_assignments",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_runtime_assignments_host_id_runtime_hosts_id_fk": {
+ "name": "workspace_runtime_assignments_host_id_runtime_hosts_id_fk",
+ "tableFrom": "workspace_runtime_assignments",
+ "tableTo": "runtime_hosts",
+ "columnsFrom": [
+ "host_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_runtimes": {
+ "name": "workspace_runtimes",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "sandbox_id": {
+ "name": "sandbox_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "backend": {
+ "name": "backend",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'firecracker'"
+ },
+ "status": {
+ "name": "status",
+ "type": "sandbox_runtime_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'provisioning'"
+ },
+ "provisioned_head_sha": {
+ "name": "provisioned_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "snapshot_ref": {
+ "name": "snapshot_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_heartbeat_at": {
+ "name": "last_heartbeat_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hibernated_at": {
+ "name": "hibernated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provisioned_at": {
+ "name": "provisioned_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stopped_at": {
+ "name": "stopped_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_runtimes_status_updated_idx": {
+ "name": "workspace_runtimes_status_updated_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_runtimes_workspace_id_workspaces_id_fk": {
+ "name": "workspace_runtimes_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_runtimes",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "workspace_runtimes_sandbox_id_unique": {
+ "name": "workspace_runtimes_sandbox_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "sandbox_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_snapshots": {
+ "name": "workspace_snapshots",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "snapshot": {
+ "name": "snapshot",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_bytes": {
+ "name": "total_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_snapshots_updated_idx": {
+ "name": "workspace_snapshots_updated_idx",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_snapshots_workspace_id_workspaces_id_fk": {
+ "name": "workspace_snapshots_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_snapshots",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_state_documents": {
+ "name": "workspace_state_documents",
+ "schema": "",
+ "columns": {
+ "document_name": {
+ "name": "document_name",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state": {
+ "name": "state",
+ "type": "bytea",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_state_documents_workspace_idx": {
+ "name": "workspace_state_documents_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_state_documents_workspace_id_workspaces_id_fk": {
+ "name": "workspace_state_documents_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_state_documents",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspaces": {
+ "name": "workspaces",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_installation_id": {
+ "name": "github_installation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository": {
+ "name": "repository",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repository_visibility": {
+ "name": "repository_visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "default_branch": {
+ "name": "default_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "workspace_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "last_activity_at": {
+ "name": "last_activity_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "hibernate_at": {
+ "name": "hibernate_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspaces_owner_idx": {
+ "name": "workspaces_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_organization_idx": {
+ "name": "workspaces_organization_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_repository_idx": {
+ "name": "workspaces_repository_idx",
+ "columns": [
+ {
+ "expression": "github_repository_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_status_expiry_idx": {
+ "name": "workspaces_status_expiry_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_deleted_idx": {
+ "name": "workspaces_deleted_idx",
+ "columns": [
+ {
+ "expression": "deleted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspaces_owner_id_users_id_fk": {
+ "name": "workspaces_owner_id_users_id_fk",
+ "tableFrom": "workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "workspaces_organization_id_organizations_id_fk": {
+ "name": "workspaces_organization_id_organizations_id_fk",
+ "tableFrom": "workspaces",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.worktrees": {
+ "name": "worktrees",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "worktree_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "worktree_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "review_head_sha": {
+ "name": "review_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_base_sha": {
+ "name": "review_base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_diff_digest": {
+ "name": "review_diff_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_by": {
+ "name": "reviewed_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_at": {
+ "name": "reviewed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "merged_at": {
+ "name": "merged_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "discarded_at": {
+ "name": "discarded_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "worktrees_workspace_name_idx": {
+ "name": "worktrees_workspace_name_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "worktrees_workspace_status_idx": {
+ "name": "worktrees_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "worktrees_workspace_id_workspaces_id_fk": {
+ "name": "worktrees_workspace_id_workspaces_id_fk",
+ "tableFrom": "worktrees",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "worktrees_reviewed_by_users_id_fk": {
+ "name": "worktrees_reviewed_by_users_id_fk",
+ "tableFrom": "worktrees",
+ "tableTo": "users",
+ "columnsFrom": [
+ "reviewed_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.yjs_snapshots": {
+ "name": "yjs_snapshots",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "update_base64": {
+ "name": "update_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state_vector_base64": {
+ "name": "state_vector_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_contents": {
+ "name": "filesystem_contents",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_conflict": {
+ "name": "has_conflict",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "conflict_filesystem_revision": {
+ "name": "conflict_filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_detected_at": {
+ "name": "conflict_detected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolved_at": {
+ "name": "conflict_resolved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolved_by": {
+ "name": "conflict_resolved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolution": {
+ "name": "conflict_resolution",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "yjs_snapshots_worktree_path_idx": {
+ "name": "yjs_snapshots_worktree_path_idx",
+ "columns": [
+ {
+ "expression": "worktree_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "yjs_snapshots_worktree_id_worktrees_id_fk": {
+ "name": "yjs_snapshots_worktree_id_worktrees_id_fk",
+ "tableFrom": "yjs_snapshots",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "yjs_snapshots_conflict_resolved_by_users_id_fk": {
+ "name": "yjs_snapshots_conflict_resolved_by_users_id_fk",
+ "tableFrom": "yjs_snapshots",
+ "tableTo": "users",
+ "columnsFrom": [
+ "conflict_resolved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {
+ "public.access_request_status": {
+ "name": "access_request_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "invited",
+ "declined"
+ ]
+ },
+ "public.agent_brief_status": {
+ "name": "agent_brief_status",
+ "schema": "public",
+ "values": [
+ "planning",
+ "active",
+ "blocked",
+ "paused",
+ "done"
+ ]
+ },
+ "public.agent_session_import_status": {
+ "name": "agent_session_import_status",
+ "schema": "public",
+ "values": [
+ "storing",
+ "stored",
+ "restoring",
+ "ready",
+ "launching",
+ "active",
+ "failed",
+ "deleted"
+ ]
+ },
+ "public.agent_session_kind": {
+ "name": "agent_session_kind",
+ "schema": "public",
+ "values": [
+ "managed",
+ "cli"
+ ]
+ },
+ "public.agent_session_status": {
+ "name": "agent_session_status",
+ "schema": "public",
+ "values": [
+ "idle",
+ "running",
+ "waiting",
+ "completed",
+ "interrupted",
+ "failed"
+ ]
+ },
+ "public.agent_turn_status": {
+ "name": "agent_turn_status",
+ "schema": "public",
+ "values": [
+ "queued",
+ "running",
+ "completed",
+ "interrupted",
+ "failed"
+ ]
+ },
+ "public.brain_entry_kind": {
+ "name": "brain_entry_kind",
+ "schema": "public",
+ "values": [
+ "decision",
+ "attempt",
+ "dead_end",
+ "finding",
+ "convention",
+ "handoff"
+ ]
+ },
+ "public.brain_overlap_kind": {
+ "name": "brain_overlap_kind",
+ "schema": "public",
+ "values": [
+ "duplicate_intent",
+ "file_overlap",
+ "claim_contest"
+ ]
+ },
+ "public.brain_overlap_status": {
+ "name": "brain_overlap_status",
+ "schema": "public",
+ "values": [
+ "open",
+ "acknowledged",
+ "resolved"
+ ]
+ },
+ "public.channel_message_author_kind": {
+ "name": "channel_message_author_kind",
+ "schema": "public",
+ "values": [
+ "member",
+ "agent",
+ "system"
+ ]
+ },
+ "public.claim_status": {
+ "name": "claim_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "released",
+ "expired",
+ "contested"
+ ]
+ },
+ "public.claude_connection_session_status": {
+ "name": "claude_connection_session_status",
+ "schema": "public",
+ "values": [
+ "starting",
+ "awaiting_code",
+ "exchanging",
+ "connected",
+ "failed"
+ ]
+ },
+ "public.cli_client_type": {
+ "name": "cli_client_type",
+ "schema": "public",
+ "values": [
+ "cli",
+ "mobile"
+ ]
+ },
+ "public.cli_device_authorization_status": {
+ "name": "cli_device_authorization_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "approved",
+ "denied"
+ ]
+ },
+ "public.credential_connected_via": {
+ "name": "credential_connected_via",
+ "schema": "public",
+ "values": [
+ "browser",
+ "cli",
+ "api_key"
+ ]
+ },
+ "public.credential_provider": {
+ "name": "credential_provider",
+ "schema": "public",
+ "values": [
+ "anthropic",
+ "openai",
+ "bedrock",
+ "azure_foundry",
+ "cursor",
+ "custom"
+ ]
+ },
+ "public.credential_scope_type": {
+ "name": "credential_scope_type",
+ "schema": "public",
+ "values": [
+ "USER",
+ "WORKSPACE",
+ "ORGANIZATION"
+ ]
+ },
+ "public.credential_type": {
+ "name": "credential_type",
+ "schema": "public",
+ "values": [
+ "API_KEY",
+ "OAUTH_TOKEN",
+ "AWS_BEDROCK_ROLE",
+ "AZURE_ENDPOINT",
+ "HOSTED_CODEX_SUBSCRIPTION"
+ ]
+ },
+ "public.feature_key": {
+ "name": "feature_key",
+ "schema": "public",
+ "values": [
+ "hosted_codex_subscription"
+ ]
+ },
+ "public.feature_override_audit_action": {
+ "name": "feature_override_audit_action",
+ "schema": "public",
+ "values": [
+ "created",
+ "updated",
+ "deleted"
+ ]
+ },
+ "public.gen2_superset_run_status": {
+ "name": "gen2_superset_run_status",
+ "schema": "public",
+ "values": [
+ "creating",
+ "running",
+ "stopping",
+ "finished",
+ "failed",
+ "recovery_required"
+ ]
+ },
+ "public.gen2_workspace_role": {
+ "name": "gen2_workspace_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "editor",
+ "viewer"
+ ]
+ },
+ "public.gen2_workspace_status": {
+ "name": "gen2_workspace_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "provisioning",
+ "ready",
+ "failed",
+ "stopped",
+ "deleting"
+ ]
+ },
+ "public.member_role": {
+ "name": "member_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "member"
+ ]
+ },
+ "public.coordination_message_status": {
+ "name": "coordination_message_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "delivered",
+ "resolved"
+ ]
+ },
+ "public.mobile_platform": {
+ "name": "mobile_platform",
+ "schema": "public",
+ "values": [
+ "ios",
+ "android"
+ ]
+ },
+ "public.organization_role": {
+ "name": "organization_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "admin",
+ "billing_admin",
+ "member"
+ ]
+ },
+ "public.organization_subscription_status": {
+ "name": "organization_subscription_status",
+ "schema": "public",
+ "values": [
+ "trialing",
+ "active",
+ "past_due",
+ "canceled"
+ ]
+ },
+ "public.provider_credential_status": {
+ "name": "provider_credential_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "reauthorization_required",
+ "revoked",
+ "failed"
+ ]
+ },
+ "public.publication_status": {
+ "name": "publication_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "published",
+ "failed"
+ ]
+ },
+ "public.repository_restore_status": {
+ "name": "repository_restore_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "matched",
+ "restored",
+ "conflicted",
+ "unavailable",
+ "transcript_only"
+ ]
+ },
+ "public.runtime_host_lifecycle": {
+ "name": "runtime_host_lifecycle",
+ "schema": "public",
+ "values": [
+ "provisioning",
+ "ready",
+ "draining",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.sandbox_runtime_status": {
+ "name": "sandbox_runtime_status",
+ "schema": "public",
+ "values": [
+ "provisioning",
+ "ready",
+ "hibernated",
+ "stopping",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.session_continuation_mode": {
+ "name": "session_continuation_mode",
+ "schema": "public",
+ "values": [
+ "managed",
+ "native_resume"
+ ]
+ },
+ "public.subscription_plan": {
+ "name": "subscription_plan",
+ "schema": "public",
+ "values": [
+ "free",
+ "pro",
+ "team",
+ "enterprise"
+ ]
+ },
+ "public.workspace_access_role": {
+ "name": "workspace_access_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "co_steer",
+ "reviewer",
+ "viewer"
+ ]
+ },
+ "public.workspace_runtime_assignment_state": {
+ "name": "workspace_runtime_assignment_state",
+ "schema": "public",
+ "values": [
+ "assigned",
+ "starting",
+ "ready",
+ "draining",
+ "lost"
+ ]
+ },
+ "public.workspace_status": {
+ "name": "workspace_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "provisioning",
+ "ready",
+ "hibernated",
+ "stopping",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.worktree_kind": {
+ "name": "worktree_kind",
+ "schema": "public",
+ "values": [
+ "integration",
+ "agent"
+ ]
+ },
+ "public.worktree_status": {
+ "name": "worktree_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "frozen",
+ "merged",
+ "discarded"
+ ]
+ }
+ },
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
diff --git a/packages/db/drizzle/meta/0058_snapshot.json b/packages/db/drizzle/meta/0058_snapshot.json
new file mode 100644
index 000000000..83fc86af3
--- /dev/null
+++ b/packages/db/drizzle/meta/0058_snapshot.json
@@ -0,0 +1,9796 @@
+{
+ "id": "291036f3-e9f0-4da1-bea7-6a53290306e6",
+ "prevId": "4930dc43-f415-4adf-a344-84200be83e7b",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.access_requests": {
+ "name": "access_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_login": {
+ "name": "github_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "persona": {
+ "name": "persona",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building": {
+ "name": "building",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "referrer": {
+ "name": "referrer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ip_hash": {
+ "name": "ip_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "access_request_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "invited_at": {
+ "name": "invited_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invite_token_hash": {
+ "name": "invite_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invite_token_expires_at": {
+ "name": "invite_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "access_requests_email_idx": {
+ "name": "access_requests_email_idx",
+ "columns": [
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_status_created_idx": {
+ "name": "access_requests_status_created_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_ip_created_idx": {
+ "name": "access_requests_ip_created_idx",
+ "columns": [
+ {
+ "expression": "ip_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_invite_token_hash_idx": {
+ "name": "access_requests_invite_token_hash_idx",
+ "columns": [
+ {
+ "expression": "invite_token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_briefs": {
+ "name": "agent_briefs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "approach_summary": {
+ "name": "approach_summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "plan_steps": {
+ "name": "plan_steps",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "current_step": {
+ "name": "current_step",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "files_likely_to_touch": {
+ "name": "files_likely_to_touch",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "keywords": {
+ "name": "keywords",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_brief_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'planning'"
+ },
+ "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_briefs_session_idx": {
+ "name": "agent_briefs_session_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_briefs_workspace_status_idx": {
+ "name": "agent_briefs_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_briefs_workspace_id_workspaces_id_fk": {
+ "name": "agent_briefs_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_briefs",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_briefs_session_id_agent_sessions_id_fk": {
+ "name": "agent_briefs_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_briefs",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_events": {
+ "name": "agent_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "turn_id": {
+ "name": "turn_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_events_idempotency_idx": {
+ "name": "agent_events_idempotency_idx",
+ "columns": [
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_events_session_created_idx": {
+ "name": "agent_events_session_created_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_events_workspace_id_workspaces_id_fk": {
+ "name": "agent_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_events_session_id_agent_sessions_id_fk": {
+ "name": "agent_events_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_events_turn_id_agent_turns_id_fk": {
+ "name": "agent_events_turn_id_agent_turns_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "agent_turns",
+ "columnsFrom": [
+ "turn_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_session_import_artifacts": {
+ "name": "agent_session_import_artifacts",
+ "schema": "",
+ "columns": {
+ "import_id": {
+ "name": "import_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "media_type": {
+ "name": "media_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plaintext_sha256": {
+ "name": "plaintext_sha256",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plaintext_bytes": {
+ "name": "plaintext_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_payload": {
+ "name": "encrypted_payload",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_session_import_artifacts_created_idx": {
+ "name": "agent_session_import_artifacts_created_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_session_import_artifacts_import_id_agent_session_imports_id_fk": {
+ "name": "agent_session_import_artifacts_import_id_agent_session_imports_id_fk",
+ "tableFrom": "agent_session_import_artifacts",
+ "tableTo": "agent_session_imports",
+ "columnsFrom": [
+ "import_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_session_imports": {
+ "name": "agent_session_imports",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "imported_by": {
+ "name": "imported_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_import_id": {
+ "name": "parent_import_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_session_id": {
+ "name": "agent_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_provider": {
+ "name": "source_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_session_id": {
+ "name": "external_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capsule_schema_version": {
+ "name": "capsule_schema_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capsule_sha256": {
+ "name": "capsule_sha256",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_session_import_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'storing'"
+ },
+ "repository_status": {
+ "name": "repository_status",
+ "type": "repository_restore_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "continuation_mode": {
+ "name": "continuation_mode",
+ "type": "session_continuation_mode",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_session_imports_idempotency_idx": {
+ "name": "agent_session_imports_idempotency_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_workspace_status_idx": {
+ "name": "agent_session_imports_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_importer_idx": {
+ "name": "agent_session_imports_importer_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_source_idx": {
+ "name": "agent_session_imports_source_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_parent_idx": {
+ "name": "agent_session_imports_parent_idx",
+ "columns": [
+ {
+ "expression": "parent_import_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_active_writer_idx": {
+ "name": "agent_session_imports_active_writer_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_session_imports\".\"continuation_mode\" = 'native_resume' and \"agent_session_imports\".\"status\" in ('launching', 'active') and \"agent_session_imports\".\"deleted_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_session_imports_organization_id_organizations_id_fk": {
+ "name": "agent_session_imports_organization_id_organizations_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_workspace_id_workspaces_id_fk": {
+ "name": "agent_session_imports_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_imported_by_users_id_fk": {
+ "name": "agent_session_imports_imported_by_users_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "users",
+ "columnsFrom": [
+ "imported_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_parent_import_id_agent_session_imports_id_fk": {
+ "name": "agent_session_imports_parent_import_id_agent_session_imports_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "agent_session_imports",
+ "columnsFrom": [
+ "parent_import_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_worktree_id_worktrees_id_fk": {
+ "name": "agent_session_imports_worktree_id_worktrees_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_agent_session_id_agent_sessions_id_fk": {
+ "name": "agent_session_imports_agent_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "agent_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_sessions": {
+ "name": "agent_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_number": {
+ "name": "issue_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'Agent'"
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'gpt-5'"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'openai'"
+ },
+ "kind": {
+ "name": "kind",
+ "type": "agent_session_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'managed'"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_session_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'idle'"
+ },
+ "workflow_run_id": {
+ "name": "workflow_run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "interrupted_at": {
+ "name": "interrupted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_sessions_workspace_issue_idx": {
+ "name": "agent_sessions_workspace_issue_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "issue_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_sessions_workspace_status_idx": {
+ "name": "agent_sessions_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_sessions_workspace_id_workspaces_id_fk": {
+ "name": "agent_sessions_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_sessions_worktree_id_worktrees_id_fk": {
+ "name": "agent_sessions_worktree_id_worktrees_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_sessions_created_by_users_id_fk": {
+ "name": "agent_sessions_created_by_users_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_turns": {
+ "name": "agent_turns",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attachments": {
+ "name": "attachments",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_turn_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "workflow_run_id": {
+ "name": "workflow_run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_id": {
+ "name": "response_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output": {
+ "name": "output",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finished_at": {
+ "name": "finished_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_turns_session_created_idx": {
+ "name": "agent_turns_session_created_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_turns_session_id_agent_sessions_id_fk": {
+ "name": "agent_turns_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_turns",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_turns_author_id_users_id_fk": {
+ "name": "agent_turns_author_id_users_id_fk",
+ "tableFrom": "agent_turns",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.brain_entries": {
+ "name": "brain_entries",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "brain_entry_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "paths": {
+ "name": "paths",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "keywords": {
+ "name": "keywords",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "supersedes_id": {
+ "name": "supersedes_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "brain_entries_workspace_created_idx": {
+ "name": "brain_entries_workspace_created_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "brain_entries_workspace_kind_idx": {
+ "name": "brain_entries_workspace_kind_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "brain_entries_workspace_id_workspaces_id_fk": {
+ "name": "brain_entries_workspace_id_workspaces_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_entries_session_id_agent_sessions_id_fk": {
+ "name": "brain_entries_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "brain_entries_author_id_users_id_fk": {
+ "name": "brain_entries_author_id_users_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.brain_overlaps": {
+ "name": "brain_overlaps",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "left_session_id": {
+ "name": "left_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "right_session_id": {
+ "name": "right_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "brain_overlap_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "score": {
+ "name": "score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "evidence": {
+ "name": "evidence",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "rationale": {
+ "name": "rationale",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "status": {
+ "name": "status",
+ "type": "brain_overlap_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "detected_at": {
+ "name": "detected_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": {
+ "brain_overlaps_pair_kind_idx": {
+ "name": "brain_overlaps_pair_kind_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "left_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "right_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "brain_overlaps_workspace_status_idx": {
+ "name": "brain_overlaps_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "brain_overlaps_workspace_id_workspaces_id_fk": {
+ "name": "brain_overlaps_workspace_id_workspaces_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_overlaps_left_session_id_agent_sessions_id_fk": {
+ "name": "brain_overlaps_left_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "left_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_overlaps_right_session_id_agent_sessions_id_fk": {
+ "name": "brain_overlaps_right_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "right_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.claude_connection_sessions": {
+ "name": "claude_connection_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'USER'"
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "claude_connection_session_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'starting'"
+ },
+ "runner_id": {
+ "name": "runner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "authorize_url": {
+ "name": "authorize_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_reason": {
+ "name": "failure_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "claude_connection_sessions_user_idx": {
+ "name": "claude_connection_sessions_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "claude_connection_sessions_expiry_idx": {
+ "name": "claude_connection_sessions_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "claude_connection_sessions_user_id_users_id_fk": {
+ "name": "claude_connection_sessions_user_id_users_id_fk",
+ "tableFrom": "claude_connection_sessions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cli_access_tokens": {
+ "name": "cli_access_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'CoDev CLI'"
+ },
+ "client_type": {
+ "name": "client_type",
+ "type": "cli_client_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'cli'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_used_at": {
+ "name": "last_used_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "cli_access_tokens_token_hash_idx": {
+ "name": "cli_access_tokens_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_access_tokens_user_idx": {
+ "name": "cli_access_tokens_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_access_tokens_expiry_idx": {
+ "name": "cli_access_tokens_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cli_access_tokens_user_id_users_id_fk": {
+ "name": "cli_access_tokens_user_id_users_id_fk",
+ "tableFrom": "cli_access_tokens",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cli_device_authorizations": {
+ "name": "cli_device_authorizations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "device_code_hash": {
+ "name": "device_code_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_code": {
+ "name": "user_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "cli_device_authorization_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "client_type": {
+ "name": "client_type",
+ "type": "cli_client_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'cli'"
+ },
+ "approved_by": {
+ "name": "approved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "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": {
+ "cli_device_authorizations_device_code_idx": {
+ "name": "cli_device_authorizations_device_code_idx",
+ "columns": [
+ {
+ "expression": "device_code_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_device_authorizations_user_code_idx": {
+ "name": "cli_device_authorizations_user_code_idx",
+ "columns": [
+ {
+ "expression": "user_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_device_authorizations_expiry_idx": {
+ "name": "cli_device_authorizations_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cli_device_authorizations_approved_by_users_id_fk": {
+ "name": "cli_device_authorizations_approved_by_users_id_fk",
+ "tableFrom": "cli_device_authorizations",
+ "tableTo": "users",
+ "columnsFrom": [
+ "approved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.collaboration_conflict_resolutions": {
+ "name": "collaboration_conflict_resolutions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resolved_by": {
+ "name": "resolved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "strategy": {
+ "name": "strategy",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "snapshot_revision": {
+ "name": "snapshot_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result_revision": {
+ "name": "result_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "collaboration_conflict_resolutions_document_idx": {
+ "name": "collaboration_conflict_resolutions_document_idx",
+ "columns": [
+ {
+ "expression": "worktree_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "collaboration_conflict_resolutions_worktree_id_worktrees_id_fk": {
+ "name": "collaboration_conflict_resolutions_worktree_id_worktrees_id_fk",
+ "tableFrom": "collaboration_conflict_resolutions",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "collaboration_conflict_resolutions_resolved_by_users_id_fk": {
+ "name": "collaboration_conflict_resolutions_resolved_by_users_id_fk",
+ "tableFrom": "collaboration_conflict_resolutions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "resolved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversation_artifacts": {
+ "name": "conversation_artifacts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_url": {
+ "name": "source_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "downloadable": {
+ "name": "downloadable",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversation_artifacts_conversation_idx": {
+ "name": "conversation_artifacts_conversation_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "conversation_artifacts_message_idx": {
+ "name": "conversation_artifacts_message_idx",
+ "columns": [
+ {
+ "expression": "message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversation_artifacts_conversation_id_conversations_id_fk": {
+ "name": "conversation_artifacts_conversation_id_conversations_id_fk",
+ "tableFrom": "conversation_artifacts",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "conversation_artifacts_message_id_conversation_messages_id_fk": {
+ "name": "conversation_artifacts_message_id_conversation_messages_id_fk",
+ "tableFrom": "conversation_artifacts",
+ "tableTo": "conversation_messages",
+ "columnsFrom": [
+ "message_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversation_messages": {
+ "name": "conversation_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence": {
+ "name": "sequence",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_user_id": {
+ "name": "author_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_name": {
+ "name": "author_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_content_type": {
+ "name": "source_content_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_created_at": {
+ "name": "source_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversation_messages_sequence_idx": {
+ "name": "conversation_messages_sequence_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sequence",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversation_messages_conversation_id_conversations_id_fk": {
+ "name": "conversation_messages_conversation_id_conversations_id_fk",
+ "tableFrom": "conversation_messages",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "conversation_messages_author_user_id_users_id_fk": {
+ "name": "conversation_messages_author_user_id_users_id_fk",
+ "tableFrom": "conversation_messages",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversations": {
+ "name": "conversations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'imported'"
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_provider": {
+ "name": "source_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_external_id": {
+ "name": "source_external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_url": {
+ "name": "source_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_model": {
+ "name": "source_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_updated_at": {
+ "name": "source_updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "warnings": {
+ "name": "warnings",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversations_owner_updated_idx": {
+ "name": "conversations_owner_updated_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "conversations_owner_source_idx": {
+ "name": "conversations_owner_source_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_external_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversations_owner_id_users_id_fk": {
+ "name": "conversations_owner_id_users_id_fk",
+ "tableFrom": "conversations",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.coordination_messages": {
+ "name": "coordination_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "from_session_id": {
+ "name": "from_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "to_session_id": {
+ "name": "to_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "correlation_id": {
+ "name": "correlation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "response_to_id": {
+ "name": "response_to_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "coordination_message_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "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": {
+ "coordination_messages_target_status_idx": {
+ "name": "coordination_messages_target_status_idx",
+ "columns": [
+ {
+ "expression": "to_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "coordination_messages_workspace_id_workspaces_id_fk": {
+ "name": "coordination_messages_workspace_id_workspaces_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coordination_messages_from_session_id_agent_sessions_id_fk": {
+ "name": "coordination_messages_from_session_id_agent_sessions_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "from_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coordination_messages_to_session_id_agent_sessions_id_fk": {
+ "name": "coordination_messages_to_session_id_agent_sessions_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "to_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.design_partner_feedback": {
+ "name": "design_partner_feedback",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "category": {
+ "name": "category",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rating": {
+ "name": "rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "page": {
+ "name": "page",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "release": {
+ "name": "release",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'new'"
+ },
+ "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": {
+ "design_partner_feedback_user_created_idx": {
+ "name": "design_partner_feedback_user_created_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "design_partner_feedback_status_created_idx": {
+ "name": "design_partner_feedback_status_created_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "design_partner_feedback_user_id_users_id_fk": {
+ "name": "design_partner_feedback_user_id_users_id_fk",
+ "tableFrom": "design_partner_feedback",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "design_partner_feedback_workspace_id_workspaces_id_fk": {
+ "name": "design_partner_feedback_workspace_id_workspaces_id_fk",
+ "tableFrom": "design_partner_feedback",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.feature_override_audit_events": {
+ "name": "feature_override_audit_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_user_id": {
+ "name": "target_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_user_id": {
+ "name": "actor_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "feature_override_audit_action",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "previous_enabled": {
+ "name": "previous_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "previous_expires_at": {
+ "name": "previous_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "feature_override_audit_org_created_idx": {
+ "name": "feature_override_audit_org_created_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "feature_override_audit_user_created_idx": {
+ "name": "feature_override_audit_user_created_idx",
+ "columns": [
+ {
+ "expression": "target_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "feature_override_audit_events_organization_id_organizations_id_fk": {
+ "name": "feature_override_audit_events_organization_id_organizations_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "feature_override_audit_events_target_user_id_users_id_fk": {
+ "name": "feature_override_audit_events_target_user_id_users_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "target_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "feature_override_audit_events_actor_user_id_users_id_fk": {
+ "name": "feature_override_audit_events_actor_user_id_users_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_agent_turns": {
+ "name": "gen2_agent_turns",
+ "schema": "",
+ "columns": {
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "output": {
+ "name": "output",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "pending_base64": {
+ "name": "pending_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "exited": {
+ "name": "exited",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "reply_message_id": {
+ "name": "reply_message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_agent_turns_chat_idx": {
+ "name": "gen2_agent_turns_chat_idx",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_agent_turns_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_agent_turns_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_chat_id_gen2_chats_id_fk": {
+ "name": "gen2_agent_turns_chat_id_gen2_chats_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_chats",
+ "columnsFrom": [
+ "chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_user_id_users_id_fk": {
+ "name": "gen2_agent_turns_user_id_users_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_reply_message_id_gen2_chat_messages_id_fk": {
+ "name": "gen2_agent_turns_reply_message_id_gen2_chat_messages_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_chat_messages",
+ "columnsFrom": [
+ "reply_message_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_chat_messages": {
+ "name": "gen2_chat_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "items": {
+ "name": "items",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_chat_messages_chat_idx": {
+ "name": "gen2_chat_messages_chat_idx",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_chat_messages_chat_id_gen2_chats_id_fk": {
+ "name": "gen2_chat_messages_chat_id_gen2_chats_id_fk",
+ "tableFrom": "gen2_chat_messages",
+ "tableTo": "gen2_chats",
+ "columnsFrom": [
+ "chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_chats": {
+ "name": "gen2_chats",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_chats_workspace_updated_idx": {
+ "name": "gen2_chats_workspace_updated_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_chats_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_chats_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_chats",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_chats_created_by_user_id_users_id_fk": {
+ "name": "gen2_chats_created_by_user_id_users_id_fk",
+ "tableFrom": "gen2_chats",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_superset_run_events": {
+ "name": "gen2_superset_run_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "run_id": {
+ "name": "run_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result": {
+ "name": "result",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_superset_run_events_run_created_idx": {
+ "name": "gen2_superset_run_events_run_created_idx",
+ "columns": [
+ {
+ "expression": "run_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_superset_run_events_run_id_gen2_superset_runs_id_fk": {
+ "name": "gen2_superset_run_events_run_id_gen2_superset_runs_id_fk",
+ "tableFrom": "gen2_superset_run_events",
+ "tableTo": "gen2_superset_runs",
+ "columnsFrom": [
+ "run_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_run_events_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_superset_run_events_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_superset_run_events",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_run_events_actor_id_users_id_fk": {
+ "name": "gen2_superset_run_events_actor_id_users_id_fk",
+ "tableFrom": "gen2_superset_run_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_superset_runs": {
+ "name": "gen2_superset_runs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "host_workspace_id": {
+ "name": "host_workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "host_terminal_id": {
+ "name": "host_terminal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "host_agent_session_id": {
+ "name": "host_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "credential_provider",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_revision": {
+ "name": "credential_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "gen2_superset_run_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'creating'"
+ },
+ "lease_claimed": {
+ "name": "lease_claimed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "exit_reason": {
+ "name": "exit_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "recovery_count": {
+ "name": "recovery_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_superset_runs_workspace_idempotency_idx": {
+ "name": "gen2_superset_runs_workspace_idempotency_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "gen2_superset_runs_workspace_status_idx": {
+ "name": "gen2_superset_runs_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "gen2_superset_runs_chat_idx": {
+ "name": "gen2_superset_runs_chat_idx",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_superset_runs_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_superset_runs_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_runs_chat_id_gen2_chats_id_fk": {
+ "name": "gen2_superset_runs_chat_id_gen2_chats_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "gen2_chats",
+ "columnsFrom": [
+ "chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_runs_created_by_users_id_fk": {
+ "name": "gen2_superset_runs_created_by_users_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_runs_connection_id_provider_credentials_id_fk": {
+ "name": "gen2_superset_runs_connection_id_provider_credentials_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "provider_credentials",
+ "columnsFrom": [
+ "connection_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_workspace_members": {
+ "name": "gen2_workspace_members",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "gen2_workspace_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'editor'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_workspace_members_user_idx": {
+ "name": "gen2_workspace_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_workspace_members_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_workspace_members_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_workspace_members",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_workspace_members_user_id_users_id_fk": {
+ "name": "gen2_workspace_members_user_id_users_id_fk",
+ "tableFrom": "gen2_workspace_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "gen2_workspace_members_workspace_id_user_id_pk": {
+ "name": "gen2_workspace_members_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_workspaces": {
+ "name": "gen2_workspaces",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "gen2_workspace_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "sandbox_id": {
+ "name": "sandbox_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_token_hash": {
+ "name": "active_invite_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_created_by_user_id": {
+ "name": "active_invite_created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_role": {
+ "name": "active_invite_role",
+ "type": "gen2_workspace_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_created_at": {
+ "name": "active_invite_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_expires_at": {
+ "name": "active_invite_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_installation_id": {
+ "name": "github_installation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository": {
+ "name": "repository",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_private": {
+ "name": "repository_private",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "default_branch": {
+ "name": "default_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_workspaces_owner_idx": {
+ "name": "gen2_workspaces_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "gen2_workspaces_active_invite_token_hash_idx": {
+ "name": "gen2_workspaces_active_invite_token_hash_idx",
+ "columns": [
+ {
+ "expression": "active_invite_token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_workspaces_owner_id_users_id_fk": {
+ "name": "gen2_workspaces_owner_id_users_id_fk",
+ "tableFrom": "gen2_workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "gen2_workspaces_active_invite_created_by_user_id_users_id_fk": {
+ "name": "gen2_workspaces_active_invite_created_by_user_id_users_id_fk",
+ "tableFrom": "gen2_workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "active_invite_created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_yjs_documents": {
+ "name": "gen2_yjs_documents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'main'"
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "update_base64": {
+ "name": "update_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state_vector_base64": {
+ "name": "state_vector_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_contents": {
+ "name": "filesystem_contents",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_conflict": {
+ "name": "has_conflict",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "conflict_filesystem_revision": {
+ "name": "conflict_filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_detected_at": {
+ "name": "conflict_detected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_yjs_documents_workspace_worktree_path_idx": {
+ "name": "gen2_yjs_documents_workspace_worktree_path_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "worktree_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_yjs_documents_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_yjs_documents_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_yjs_documents",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_connections": {
+ "name": "github_connections",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "encrypted_access_token": {
+ "name": "encrypted_access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_refresh_token": {
+ "name": "encrypted_refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'bearer'"
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "github_connections_access_expiry_idx": {
+ "name": "github_connections_access_expiry_idx",
+ "columns": [
+ {
+ "expression": "access_token_expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "github_connections_user_id_users_id_fk": {
+ "name": "github_connections_user_id_users_id_fk",
+ "tableFrom": "github_connections",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_issue_assignments": {
+ "name": "github_issue_assignments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_number": {
+ "name": "issue_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_issue_id": {
+ "name": "github_issue_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "github_issue_assignments_repository_issue_idx": {
+ "name": "github_issue_assignments_repository_issue_idx",
+ "columns": [
+ {
+ "expression": "github_repository_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "issue_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "github_issue_assignments_session_idx": {
+ "name": "github_issue_assignments_session_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "github_issue_assignments_workspace_idx": {
+ "name": "github_issue_assignments_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "github_issue_assignments_workspace_id_workspaces_id_fk": {
+ "name": "github_issue_assignments_workspace_id_workspaces_id_fk",
+ "tableFrom": "github_issue_assignments",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "github_issue_assignments_session_id_agent_sessions_id_fk": {
+ "name": "github_issue_assignments_session_id_agent_sessions_id_fk",
+ "tableFrom": "github_issue_assignments",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.mobile_push_tokens": {
+ "name": "mobile_push_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expo_push_token": {
+ "name": "expo_push_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "mobile_platform",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "device_id": {
+ "name": "device_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_seen_at": {
+ "name": "last_seen_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": {
+ "mobile_push_tokens_token_idx": {
+ "name": "mobile_push_tokens_token_idx",
+ "columns": [
+ {
+ "expression": "expo_push_token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "mobile_push_tokens_user_idx": {
+ "name": "mobile_push_tokens_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mobile_push_tokens_user_id_users_id_fk": {
+ "name": "mobile_push_tokens_user_id_users_id_fk",
+ "tableFrom": "mobile_push_tokens",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_feature_overrides": {
+ "name": "organization_feature_overrides",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "organization_feature_overrides_organization_id_organizations_id_fk": {
+ "name": "organization_feature_overrides_organization_id_organizations_id_fk",
+ "tableFrom": "organization_feature_overrides",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_feature_overrides_created_by_users_id_fk": {
+ "name": "organization_feature_overrides_created_by_users_id_fk",
+ "tableFrom": "organization_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "organization_feature_overrides_organization_id_feature_pk": {
+ "name": "organization_feature_overrides_organization_id_feature_pk",
+ "columns": [
+ "organization_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_members": {
+ "name": "organization_members",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "organization_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organization_members_user_idx": {
+ "name": "organization_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organization_members_organization_id_organizations_id_fk": {
+ "name": "organization_members_organization_id_organizations_id_fk",
+ "tableFrom": "organization_members",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_members_user_id_users_id_fk": {
+ "name": "organization_members_user_id_users_id_fk",
+ "tableFrom": "organization_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "organization_members_organization_id_user_id_pk": {
+ "name": "organization_members_organization_id_user_id_pk",
+ "columns": [
+ "organization_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_subscriptions": {
+ "name": "organization_subscriptions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "organization_subscription_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_customer_id": {
+ "name": "provider_customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_subscription_id": {
+ "name": "provider_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_period_end": {
+ "name": "current_period_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "canceled_at": {
+ "name": "canceled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organization_subscriptions_org_idx": {
+ "name": "organization_subscriptions_org_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "organization_subscriptions_provider_idx": {
+ "name": "organization_subscriptions_provider_idx",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organization_subscriptions_organization_id_organizations_id_fk": {
+ "name": "organization_subscriptions_organization_id_organizations_id_fk",
+ "tableFrom": "organization_subscriptions",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_subscriptions_plan_id_plans_id_fk": {
+ "name": "organization_subscriptions_plan_id_plans_id_fk",
+ "tableFrom": "organization_subscriptions",
+ "tableTo": "plans",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organizations": {
+ "name": "organizations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organizations_slug_idx": {
+ "name": "organizations_slug_idx",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.page_views": {
+ "name": "page_views",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "referrer": {
+ "name": "referrer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ip_hash": {
+ "name": "ip_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "page_views_created_idx": {
+ "name": "page_views_created_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "page_views_user_created_idx": {
+ "name": "page_views_user_created_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "page_views_path_created_idx": {
+ "name": "page_views_path_created_idx",
+ "columns": [
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "page_views_user_id_users_id_fk": {
+ "name": "page_views_user_id_users_id_fk",
+ "tableFrom": "page_views",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.path_claims": {
+ "name": "path_claims",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path_glob": {
+ "name": "path_glob",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "intent": {
+ "name": "intent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "claim_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "path_claims_session_status_idx": {
+ "name": "path_claims_session_status_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "path_claims_expiry_idx": {
+ "name": "path_claims_expiry_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "path_claims_session_id_agent_sessions_id_fk": {
+ "name": "path_claims_session_id_agent_sessions_id_fk",
+ "tableFrom": "path_claims",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan_entitlements": {
+ "name": "plan_entitlements",
+ "schema": "",
+ "columns": {
+ "plan_id": {
+ "name": "plan_id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "plan_entitlements_plan_id_plans_id_fk": {
+ "name": "plan_entitlements_plan_id_plans_id_fk",
+ "tableFrom": "plan_entitlements",
+ "tableTo": "plans",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "plan_entitlements_plan_id_feature_pk": {
+ "name": "plan_entitlements_plan_id_feature_pk",
+ "columns": [
+ "plan_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plans": {
+ "name": "plans",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.provider_credential_events": {
+ "name": "provider_credential_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "credential_provider",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result": {
+ "name": "result",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "provider_credential_events_credential_created_idx": {
+ "name": "provider_credential_events_credential_created_idx",
+ "columns": [
+ {
+ "expression": "credential_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credential_events_actor_created_idx": {
+ "name": "provider_credential_events_actor_created_idx",
+ "columns": [
+ {
+ "expression": "actor_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "provider_credential_events_actor_id_users_id_fk": {
+ "name": "provider_credential_events_actor_id_users_id_fk",
+ "tableFrom": "provider_credential_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "provider_credential_events_workspace_id_workspaces_id_fk": {
+ "name": "provider_credential_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "provider_credential_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.provider_credentials": {
+ "name": "provider_credentials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "credential_provider",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_type": {
+ "name": "credential_type",
+ "type": "credential_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "priority_order": {
+ "name": "priority_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "encrypted_api_key": {
+ "name": "encrypted_api_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_access_token": {
+ "name": "encrypted_access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_refresh_token": {
+ "name": "encrypted_refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "endpoint_url": {
+ "name": "endpoint_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "aws_role_arn": {
+ "name": "aws_role_arn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_connected": {
+ "name": "is_connected",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_four": {
+ "name": "last_four",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "provider_credential_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "provider_subject_hash": {
+ "name": "provider_subject_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_material": {
+ "name": "encrypted_material",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_refreshed_at": {
+ "name": "last_refreshed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sharing_enabled": {
+ "name": "sharing_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "unavailable_until": {
+ "name": "unavailable_until",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "connected_via": {
+ "name": "connected_via",
+ "type": "credential_connected_via",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "allow_in_shared_workspaces": {
+ "name": "allow_in_shared_workspaces",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "enabled_for_rooms": {
+ "name": "enabled_for_rooms",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "enabled_for_workspace": {
+ "name": "enabled_for_workspace",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "provider_credentials_scope_provider_type_idx": {
+ "name": "provider_credentials_scope_provider_type_idx",
+ "columns": [
+ {
+ "expression": "scope_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scope_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "credential_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credentials_scope_provider_priority_idx": {
+ "name": "provider_credentials_scope_provider_priority_idx",
+ "columns": [
+ {
+ "expression": "scope_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scope_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "priority_order",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credentials_status_idx": {
+ "name": "provider_credentials_status_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "provider_credentials_created_by_users_id_fk": {
+ "name": "provider_credentials_created_by_users_id_fk",
+ "tableFrom": "provider_credentials",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.published_branches": {
+ "name": "published_branches",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "published_by": {
+ "name": "published_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "branch_name": {
+ "name": "branch_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "publication_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "source_head_sha": {
+ "name": "source_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "commit_sha": {
+ "name": "commit_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_id": {
+ "name": "repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "remote_ref": {
+ "name": "remote_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "html_url": {
+ "name": "html_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pull_request_number": {
+ "name": "pull_request_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pull_request_url": {
+ "name": "pull_request_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "request_id": {
+ "name": "request_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "published_at": {
+ "name": "published_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "published_branches_workspace_name_idx": {
+ "name": "published_branches_workspace_name_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "branch_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "published_branches_workspace_request_idx": {
+ "name": "published_branches_workspace_request_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "request_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "published_branches_workspace_status_idx": {
+ "name": "published_branches_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "published_branches_workspace_id_workspaces_id_fk": {
+ "name": "published_branches_workspace_id_workspaces_id_fk",
+ "tableFrom": "published_branches",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "published_branches_published_by_users_id_fk": {
+ "name": "published_branches_published_by_users_id_fk",
+ "tableFrom": "published_branches",
+ "tableTo": "users",
+ "columnsFrom": [
+ "published_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.runtime_hosts": {
+ "name": "runtime_hosts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "runtime_address": {
+ "name": "runtime_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifecycle_state": {
+ "name": "lifecycle_state",
+ "type": "runtime_host_lifecycle",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'provisioning'"
+ },
+ "max_workspace_slots": {
+ "name": "max_workspace_slots",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 4
+ },
+ "free_workspace_slots": {
+ "name": "free_workspace_slots",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 4
+ },
+ "image_version": {
+ "name": "image_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_heartbeat_at": {
+ "name": "last_heartbeat_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "draining_at": {
+ "name": "draining_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "runtime_hosts_provider_id_idx": {
+ "name": "runtime_hosts_provider_id_idx",
+ "columns": [
+ {
+ "expression": "provider_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "runtime_hosts_runtime_address_idx": {
+ "name": "runtime_hosts_runtime_address_idx",
+ "columns": [
+ {
+ "expression": "runtime_address",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "runtime_hosts_capacity_idx": {
+ "name": "runtime_hosts_capacity_idx",
+ "columns": [
+ {
+ "expression": "lifecycle_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "free_workspace_slots",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sandbox_runtime_intervals": {
+ "name": "sandbox_runtime_intervals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ended_at": {
+ "name": "ended_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "sandbox_runtime_intervals_user_open_idx": {
+ "name": "sandbox_runtime_intervals_user_open_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "ended_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "sandbox_runtime_intervals_workspace_open_idx": {
+ "name": "sandbox_runtime_intervals_workspace_open_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "ended_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "sandbox_runtime_intervals_user_id_users_id_fk": {
+ "name": "sandbox_runtime_intervals_user_id_users_id_fk",
+ "tableFrom": "sandbox_runtime_intervals",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sandbox_runtime_intervals_workspace_id_workspaces_id_fk": {
+ "name": "sandbox_runtime_intervals_workspace_id_workspaces_id_fk",
+ "tableFrom": "sandbox_runtime_intervals",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chat_invites": {
+ "name": "shared_chat_invites",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "shared_chat_id": {
+ "name": "shared_chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_token": {
+ "name": "encrypted_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_by": {
+ "name": "accepted_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chat_invites_token_hash_idx": {
+ "name": "shared_chat_invites_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "shared_chat_invites_room_idx": {
+ "name": "shared_chat_invites_room_idx",
+ "columns": [
+ {
+ "expression": "shared_chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chat_invites_shared_chat_id_shared_chats_id_fk": {
+ "name": "shared_chat_invites_shared_chat_id_shared_chats_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "shared_chats",
+ "columnsFrom": [
+ "shared_chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_invites_created_by_users_id_fk": {
+ "name": "shared_chat_invites_created_by_users_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_invites_accepted_by_users_id_fk": {
+ "name": "shared_chat_invites_accepted_by_users_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "accepted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chat_members": {
+ "name": "shared_chat_members",
+ "schema": "",
+ "columns": {
+ "shared_chat_id": {
+ "name": "shared_chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chat_members_user_idx": {
+ "name": "shared_chat_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chat_members_shared_chat_id_shared_chats_id_fk": {
+ "name": "shared_chat_members_shared_chat_id_shared_chats_id_fk",
+ "tableFrom": "shared_chat_members",
+ "tableTo": "shared_chats",
+ "columnsFrom": [
+ "shared_chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_members_user_id_users_id_fk": {
+ "name": "shared_chat_members_user_id_users_id_fk",
+ "tableFrom": "shared_chat_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "shared_chat_members_shared_chat_id_user_id_pk": {
+ "name": "shared_chat_members_shared_chat_id_user_id_pk",
+ "columns": [
+ "shared_chat_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chats": {
+ "name": "shared_chats",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chats_conversation_idx": {
+ "name": "shared_chats_conversation_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "shared_chats_owner_updated_idx": {
+ "name": "shared_chats_owner_updated_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chats_conversation_id_conversations_id_fk": {
+ "name": "shared_chats_conversation_id_conversations_id_fk",
+ "tableFrom": "shared_chats",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chats_owner_id_users_id_fk": {
+ "name": "shared_chats_owner_id_users_id_fk",
+ "tableFrom": "shared_chats",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_compute_usage": {
+ "name": "user_compute_usage",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "minutes_used": {
+ "name": "minutes_used",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_compute_usage_user_id_users_id_fk": {
+ "name": "user_compute_usage_user_id_users_id_fk",
+ "tableFrom": "user_compute_usage",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_environment_variables": {
+ "name": "user_environment_variables",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_value": {
+ "name": "encrypted_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_four": {
+ "name": "last_four",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_environment_variables_user_name_idx": {
+ "name": "user_environment_variables_user_name_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_environment_variables_user_updated_idx": {
+ "name": "user_environment_variables_user_updated_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_environment_variables_user_id_users_id_fk": {
+ "name": "user_environment_variables_user_id_users_id_fk",
+ "tableFrom": "user_environment_variables",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_feature_overrides": {
+ "name": "user_feature_overrides",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_feature_overrides_user_idx": {
+ "name": "user_feature_overrides_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_feature_overrides_organization_id_organizations_id_fk": {
+ "name": "user_feature_overrides_organization_id_organizations_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_feature_overrides_user_id_users_id_fk": {
+ "name": "user_feature_overrides_user_id_users_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_feature_overrides_created_by_users_id_fk": {
+ "name": "user_feature_overrides_created_by_users_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "user_feature_overrides_organization_id_user_id_feature_pk": {
+ "name": "user_feature_overrides_organization_id_user_id_feature_pk",
+ "columns": [
+ "organization_id",
+ "user_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.users": {
+ "name": "users",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "github_user_id": {
+ "name": "github_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "google_user_id": {
+ "name": "google_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "clerk_user_id": {
+ "name": "clerk_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "login": {
+ "name": "login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password_hash": {
+ "name": "password_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avatar_url": {
+ "name": "avatar_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_admin": {
+ "name": "is_admin",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "users_github_user_id_idx": {
+ "name": "users_github_user_id_idx",
+ "columns": [
+ {
+ "expression": "github_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_google_user_id_idx": {
+ "name": "users_google_user_id_idx",
+ "columns": [
+ {
+ "expression": "google_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_clerk_user_id_idx": {
+ "name": "users_clerk_user_id_idx",
+ "columns": [
+ {
+ "expression": "clerk_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_login_idx": {
+ "name": "users_login_idx",
+ "columns": [
+ {
+ "expression": "login",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channel_messages": {
+ "name": "workspace_channel_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_kind": {
+ "name": "author_kind",
+ "type": "channel_message_author_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_label": {
+ "name": "author_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_session_id": {
+ "name": "agent_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mentions": {
+ "name": "mentions",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "mentions_agent": {
+ "name": "mentions_agent",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channel_messages_channel_idx": {
+ "name": "workspace_channel_messages_channel_idx",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_channel_messages_workspace_idx": {
+ "name": "workspace_channel_messages_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channel_messages_channel_id_workspace_channels_id_fk": {
+ "name": "workspace_channel_messages_channel_id_workspace_channels_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "workspace_channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_workspace_id_workspaces_id_fk": {
+ "name": "workspace_channel_messages_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_author_id_users_id_fk": {
+ "name": "workspace_channel_messages_author_id_users_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_agent_session_id_agent_sessions_id_fk": {
+ "name": "workspace_channel_messages_agent_session_id_agent_sessions_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "agent_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channel_reads": {
+ "name": "workspace_channel_reads",
+ "schema": "",
+ "columns": {
+ "channel_id": {
+ "name": "channel_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_read_at": {
+ "name": "last_read_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channel_reads_user_idx": {
+ "name": "workspace_channel_reads_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channel_reads_channel_id_workspace_channels_id_fk": {
+ "name": "workspace_channel_reads_channel_id_workspace_channels_id_fk",
+ "tableFrom": "workspace_channel_reads",
+ "tableTo": "workspace_channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_reads_user_id_users_id_fk": {
+ "name": "workspace_channel_reads_user_id_users_id_fk",
+ "tableFrom": "workspace_channel_reads",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_channel_reads_channel_id_user_id_pk": {
+ "name": "workspace_channel_reads_channel_id_user_id_pk",
+ "columns": [
+ "channel_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channels": {
+ "name": "workspace_channels",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "topic": {
+ "name": "topic",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_access": {
+ "name": "agent_access",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channels_workspace_slug_idx": {
+ "name": "workspace_channels_workspace_slug_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_channels_workspace_idx": {
+ "name": "workspace_channels_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "archived_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channels_workspace_id_workspaces_id_fk": {
+ "name": "workspace_channels_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_channels",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channels_created_by_users_id_fk": {
+ "name": "workspace_channels_created_by_users_id_fk",
+ "tableFrom": "workspace_channels",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_leases": {
+ "name": "workspace_chat_leases",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "holder_id": {
+ "name": "holder_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lease_token": {
+ "name": "lease_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_leases_expiry_idx": {
+ "name": "workspace_chat_leases_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_leases_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_leases_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_leases",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_leases_holder_id_users_id_fk": {
+ "name": "workspace_chat_leases_holder_id_users_id_fk",
+ "tableFrom": "workspace_chat_leases",
+ "tableTo": "users",
+ "columnsFrom": [
+ "holder_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_chat_leases_workspace_id_chat_id_pk": {
+ "name": "workspace_chat_leases_workspace_id_chat_id_pk",
+ "columns": [
+ "workspace_id",
+ "chat_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_participants": {
+ "name": "workspace_chat_participants",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_participants_expiry_idx": {
+ "name": "workspace_chat_participants_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_participants_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_participants_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_participants",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_participants_user_id_users_id_fk": {
+ "name": "workspace_chat_participants_user_id_users_id_fk",
+ "tableFrom": "workspace_chat_participants",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_chat_participants_workspace_id_chat_id_user_id_client_id_pk": {
+ "name": "workspace_chat_participants_workspace_id_chat_id_user_id_client_id_pk",
+ "columns": [
+ "workspace_id",
+ "chat_id",
+ "user_id",
+ "client_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_prompt_receipts": {
+ "name": "workspace_chat_prompt_receipts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_message_id": {
+ "name": "client_message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attachments": {
+ "name": "attachments",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "effort": {
+ "name": "effort",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_prompt_receipts_client_message_idx": {
+ "name": "workspace_chat_prompt_receipts_client_message_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "client_message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_chat_prompt_receipts_chat_created_idx": {
+ "name": "workspace_chat_prompt_receipts_chat_created_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_prompt_receipts_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_prompt_receipts_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_prompt_receipts",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_prompt_receipts_author_id_users_id_fk": {
+ "name": "workspace_chat_prompt_receipts_author_id_users_id_fk",
+ "tableFrom": "workspace_chat_prompt_receipts",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_events": {
+ "name": "workspace_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence": {
+ "name": "sequence",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_events_sequence_idx": {
+ "name": "workspace_events_sequence_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sequence",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_events_workspace_id_workspaces_id_fk": {
+ "name": "workspace_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_events_actor_id_users_id_fk": {
+ "name": "workspace_events_actor_id_users_id_fk",
+ "tableFrom": "workspace_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_invites": {
+ "name": "workspace_invites",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "invitee_email": {
+ "name": "invitee_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invitee_login": {
+ "name": "invitee_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_role": {
+ "name": "access_role",
+ "type": "workspace_access_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'viewer'"
+ },
+ "allow_link": {
+ "name": "allow_link",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_by": {
+ "name": "accepted_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_invites_token_hash_idx": {
+ "name": "workspace_invites_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_invites_workspace_idx": {
+ "name": "workspace_invites_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_invites_workspace_id_workspaces_id_fk": {
+ "name": "workspace_invites_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_invites_created_by_users_id_fk": {
+ "name": "workspace_invites_created_by_users_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_invites_accepted_by_users_id_fk": {
+ "name": "workspace_invites_accepted_by_users_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "accepted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_member_statuses": {
+ "name": "workspace_member_statuses",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emoji": {
+ "name": "emoji",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "headline": {
+ "name": "headline",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_member_statuses_workspace_idx": {
+ "name": "workspace_member_statuses_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_member_statuses_workspace_id_workspaces_id_fk": {
+ "name": "workspace_member_statuses_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_member_statuses",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_member_statuses_user_id_users_id_fk": {
+ "name": "workspace_member_statuses_user_id_users_id_fk",
+ "tableFrom": "workspace_member_statuses",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_member_statuses_workspace_id_user_id_pk": {
+ "name": "workspace_member_statuses_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_members": {
+ "name": "workspace_members",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "member_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "access_role": {
+ "name": "access_role",
+ "type": "workspace_access_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'viewer'"
+ },
+ "can_terminal": {
+ "name": "can_terminal",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "can_merge": {
+ "name": "can_merge",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_members_user_idx": {
+ "name": "workspace_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_members_workspace_id_workspaces_id_fk": {
+ "name": "workspace_members_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_members",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_members_user_id_users_id_fk": {
+ "name": "workspace_members_user_id_users_id_fk",
+ "tableFrom": "workspace_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_members_workspace_id_user_id_pk": {
+ "name": "workspace_members_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_runtime_assignments": {
+ "name": "workspace_runtime_assignments",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "host_id": {
+ "name": "host_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "generation": {
+ "name": "generation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "fencing_token": {
+ "name": "fencing_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "disk_id": {
+ "name": "disk_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "disk_lun": {
+ "name": "disk_lun",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "runtime_state": {
+ "name": "runtime_state",
+ "type": "workspace_runtime_assignment_state",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'assigned'"
+ },
+ "last_used_at": {
+ "name": "last_used_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": {
+ "workspace_runtime_assignments_host_state_idx": {
+ "name": "workspace_runtime_assignments_host_state_idx",
+ "columns": [
+ {
+ "expression": "host_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "runtime_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_runtime_assignments_state_updated_idx": {
+ "name": "workspace_runtime_assignments_state_updated_idx",
+ "columns": [
+ {
+ "expression": "runtime_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_runtime_assignments_workspace_id_workspaces_id_fk": {
+ "name": "workspace_runtime_assignments_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_runtime_assignments",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_runtime_assignments_host_id_runtime_hosts_id_fk": {
+ "name": "workspace_runtime_assignments_host_id_runtime_hosts_id_fk",
+ "tableFrom": "workspace_runtime_assignments",
+ "tableTo": "runtime_hosts",
+ "columnsFrom": [
+ "host_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_runtimes": {
+ "name": "workspace_runtimes",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "sandbox_id": {
+ "name": "sandbox_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "backend": {
+ "name": "backend",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'firecracker'"
+ },
+ "status": {
+ "name": "status",
+ "type": "sandbox_runtime_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'provisioning'"
+ },
+ "provisioned_head_sha": {
+ "name": "provisioned_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "snapshot_ref": {
+ "name": "snapshot_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_heartbeat_at": {
+ "name": "last_heartbeat_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hibernated_at": {
+ "name": "hibernated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provisioned_at": {
+ "name": "provisioned_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stopped_at": {
+ "name": "stopped_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_runtimes_status_updated_idx": {
+ "name": "workspace_runtimes_status_updated_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_runtimes_workspace_id_workspaces_id_fk": {
+ "name": "workspace_runtimes_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_runtimes",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "workspace_runtimes_sandbox_id_unique": {
+ "name": "workspace_runtimes_sandbox_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "sandbox_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_snapshots": {
+ "name": "workspace_snapshots",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "snapshot": {
+ "name": "snapshot",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_bytes": {
+ "name": "total_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_snapshots_updated_idx": {
+ "name": "workspace_snapshots_updated_idx",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_snapshots_workspace_id_workspaces_id_fk": {
+ "name": "workspace_snapshots_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_snapshots",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_state_documents": {
+ "name": "workspace_state_documents",
+ "schema": "",
+ "columns": {
+ "document_name": {
+ "name": "document_name",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state": {
+ "name": "state",
+ "type": "bytea",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_state_documents_workspace_idx": {
+ "name": "workspace_state_documents_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_state_documents_workspace_id_workspaces_id_fk": {
+ "name": "workspace_state_documents_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_state_documents",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspaces": {
+ "name": "workspaces",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_installation_id": {
+ "name": "github_installation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository": {
+ "name": "repository",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repository_visibility": {
+ "name": "repository_visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "default_branch": {
+ "name": "default_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "workspace_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "last_activity_at": {
+ "name": "last_activity_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "hibernate_at": {
+ "name": "hibernate_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspaces_owner_idx": {
+ "name": "workspaces_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_organization_idx": {
+ "name": "workspaces_organization_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_repository_idx": {
+ "name": "workspaces_repository_idx",
+ "columns": [
+ {
+ "expression": "github_repository_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_status_expiry_idx": {
+ "name": "workspaces_status_expiry_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_deleted_idx": {
+ "name": "workspaces_deleted_idx",
+ "columns": [
+ {
+ "expression": "deleted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspaces_owner_id_users_id_fk": {
+ "name": "workspaces_owner_id_users_id_fk",
+ "tableFrom": "workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "workspaces_organization_id_organizations_id_fk": {
+ "name": "workspaces_organization_id_organizations_id_fk",
+ "tableFrom": "workspaces",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.worktrees": {
+ "name": "worktrees",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "worktree_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "worktree_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "review_head_sha": {
+ "name": "review_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_base_sha": {
+ "name": "review_base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_diff_digest": {
+ "name": "review_diff_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_by": {
+ "name": "reviewed_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_at": {
+ "name": "reviewed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "merged_at": {
+ "name": "merged_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "discarded_at": {
+ "name": "discarded_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "worktrees_workspace_name_idx": {
+ "name": "worktrees_workspace_name_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "worktrees_workspace_status_idx": {
+ "name": "worktrees_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "worktrees_workspace_id_workspaces_id_fk": {
+ "name": "worktrees_workspace_id_workspaces_id_fk",
+ "tableFrom": "worktrees",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "worktrees_reviewed_by_users_id_fk": {
+ "name": "worktrees_reviewed_by_users_id_fk",
+ "tableFrom": "worktrees",
+ "tableTo": "users",
+ "columnsFrom": [
+ "reviewed_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.yjs_snapshots": {
+ "name": "yjs_snapshots",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "update_base64": {
+ "name": "update_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state_vector_base64": {
+ "name": "state_vector_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_contents": {
+ "name": "filesystem_contents",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_conflict": {
+ "name": "has_conflict",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "conflict_filesystem_revision": {
+ "name": "conflict_filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_detected_at": {
+ "name": "conflict_detected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolved_at": {
+ "name": "conflict_resolved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolved_by": {
+ "name": "conflict_resolved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolution": {
+ "name": "conflict_resolution",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "yjs_snapshots_worktree_path_idx": {
+ "name": "yjs_snapshots_worktree_path_idx",
+ "columns": [
+ {
+ "expression": "worktree_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "yjs_snapshots_worktree_id_worktrees_id_fk": {
+ "name": "yjs_snapshots_worktree_id_worktrees_id_fk",
+ "tableFrom": "yjs_snapshots",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "yjs_snapshots_conflict_resolved_by_users_id_fk": {
+ "name": "yjs_snapshots_conflict_resolved_by_users_id_fk",
+ "tableFrom": "yjs_snapshots",
+ "tableTo": "users",
+ "columnsFrom": [
+ "conflict_resolved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {
+ "public.access_request_status": {
+ "name": "access_request_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "invited",
+ "declined"
+ ]
+ },
+ "public.agent_brief_status": {
+ "name": "agent_brief_status",
+ "schema": "public",
+ "values": [
+ "planning",
+ "active",
+ "blocked",
+ "paused",
+ "done"
+ ]
+ },
+ "public.agent_session_import_status": {
+ "name": "agent_session_import_status",
+ "schema": "public",
+ "values": [
+ "storing",
+ "stored",
+ "restoring",
+ "ready",
+ "launching",
+ "active",
+ "failed",
+ "deleted"
+ ]
+ },
+ "public.agent_session_kind": {
+ "name": "agent_session_kind",
+ "schema": "public",
+ "values": [
+ "managed",
+ "cli"
+ ]
+ },
+ "public.agent_session_status": {
+ "name": "agent_session_status",
+ "schema": "public",
+ "values": [
+ "idle",
+ "running",
+ "waiting",
+ "completed",
+ "interrupted",
+ "failed"
+ ]
+ },
+ "public.agent_turn_status": {
+ "name": "agent_turn_status",
+ "schema": "public",
+ "values": [
+ "queued",
+ "running",
+ "completed",
+ "interrupted",
+ "failed"
+ ]
+ },
+ "public.brain_entry_kind": {
+ "name": "brain_entry_kind",
+ "schema": "public",
+ "values": [
+ "decision",
+ "attempt",
+ "dead_end",
+ "finding",
+ "convention",
+ "handoff"
+ ]
+ },
+ "public.brain_overlap_kind": {
+ "name": "brain_overlap_kind",
+ "schema": "public",
+ "values": [
+ "duplicate_intent",
+ "file_overlap",
+ "claim_contest"
+ ]
+ },
+ "public.brain_overlap_status": {
+ "name": "brain_overlap_status",
+ "schema": "public",
+ "values": [
+ "open",
+ "acknowledged",
+ "resolved"
+ ]
+ },
+ "public.channel_message_author_kind": {
+ "name": "channel_message_author_kind",
+ "schema": "public",
+ "values": [
+ "member",
+ "agent",
+ "system"
+ ]
+ },
+ "public.claim_status": {
+ "name": "claim_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "released",
+ "expired",
+ "contested"
+ ]
+ },
+ "public.claude_connection_session_status": {
+ "name": "claude_connection_session_status",
+ "schema": "public",
+ "values": [
+ "starting",
+ "awaiting_code",
+ "exchanging",
+ "connected",
+ "failed"
+ ]
+ },
+ "public.cli_client_type": {
+ "name": "cli_client_type",
+ "schema": "public",
+ "values": [
+ "cli",
+ "mobile"
+ ]
+ },
+ "public.cli_device_authorization_status": {
+ "name": "cli_device_authorization_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "approved",
+ "denied"
+ ]
+ },
+ "public.credential_connected_via": {
+ "name": "credential_connected_via",
+ "schema": "public",
+ "values": [
+ "browser",
+ "cli",
+ "api_key"
+ ]
+ },
+ "public.credential_provider": {
+ "name": "credential_provider",
+ "schema": "public",
+ "values": [
+ "anthropic",
+ "openai",
+ "bedrock",
+ "azure_foundry",
+ "cursor",
+ "custom"
+ ]
+ },
+ "public.credential_scope_type": {
+ "name": "credential_scope_type",
+ "schema": "public",
+ "values": [
+ "USER",
+ "WORKSPACE",
+ "ORGANIZATION"
+ ]
+ },
+ "public.credential_type": {
+ "name": "credential_type",
+ "schema": "public",
+ "values": [
+ "API_KEY",
+ "OAUTH_TOKEN",
+ "AWS_BEDROCK_ROLE",
+ "AZURE_ENDPOINT",
+ "HOSTED_CODEX_SUBSCRIPTION"
+ ]
+ },
+ "public.feature_key": {
+ "name": "feature_key",
+ "schema": "public",
+ "values": [
+ "hosted_codex_subscription"
+ ]
+ },
+ "public.feature_override_audit_action": {
+ "name": "feature_override_audit_action",
+ "schema": "public",
+ "values": [
+ "created",
+ "updated",
+ "deleted"
+ ]
+ },
+ "public.gen2_superset_run_status": {
+ "name": "gen2_superset_run_status",
+ "schema": "public",
+ "values": [
+ "creating",
+ "running",
+ "stopping",
+ "finished",
+ "failed",
+ "recovery_required"
+ ]
+ },
+ "public.gen2_workspace_role": {
+ "name": "gen2_workspace_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "editor",
+ "viewer"
+ ]
+ },
+ "public.gen2_workspace_status": {
+ "name": "gen2_workspace_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "provisioning",
+ "ready",
+ "failed",
+ "stopped",
+ "deleting"
+ ]
+ },
+ "public.member_role": {
+ "name": "member_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "member"
+ ]
+ },
+ "public.coordination_message_status": {
+ "name": "coordination_message_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "delivered",
+ "resolved"
+ ]
+ },
+ "public.mobile_platform": {
+ "name": "mobile_platform",
+ "schema": "public",
+ "values": [
+ "ios",
+ "android"
+ ]
+ },
+ "public.organization_role": {
+ "name": "organization_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "admin",
+ "billing_admin",
+ "member"
+ ]
+ },
+ "public.organization_subscription_status": {
+ "name": "organization_subscription_status",
+ "schema": "public",
+ "values": [
+ "trialing",
+ "active",
+ "past_due",
+ "canceled"
+ ]
+ },
+ "public.provider_credential_status": {
+ "name": "provider_credential_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "reauthorization_required",
+ "revoked",
+ "failed"
+ ]
+ },
+ "public.publication_status": {
+ "name": "publication_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "published",
+ "failed"
+ ]
+ },
+ "public.repository_restore_status": {
+ "name": "repository_restore_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "matched",
+ "restored",
+ "conflicted",
+ "unavailable",
+ "transcript_only"
+ ]
+ },
+ "public.runtime_host_lifecycle": {
+ "name": "runtime_host_lifecycle",
+ "schema": "public",
+ "values": [
+ "provisioning",
+ "ready",
+ "draining",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.sandbox_runtime_status": {
+ "name": "sandbox_runtime_status",
+ "schema": "public",
+ "values": [
+ "provisioning",
+ "ready",
+ "hibernated",
+ "stopping",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.session_continuation_mode": {
+ "name": "session_continuation_mode",
+ "schema": "public",
+ "values": [
+ "managed",
+ "native_resume"
+ ]
+ },
+ "public.subscription_plan": {
+ "name": "subscription_plan",
+ "schema": "public",
+ "values": [
+ "free",
+ "pro",
+ "team",
+ "enterprise"
+ ]
+ },
+ "public.workspace_access_role": {
+ "name": "workspace_access_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "co_steer",
+ "reviewer",
+ "viewer"
+ ]
+ },
+ "public.workspace_runtime_assignment_state": {
+ "name": "workspace_runtime_assignment_state",
+ "schema": "public",
+ "values": [
+ "assigned",
+ "starting",
+ "ready",
+ "draining",
+ "lost"
+ ]
+ },
+ "public.workspace_status": {
+ "name": "workspace_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "provisioning",
+ "ready",
+ "hibernated",
+ "stopping",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.worktree_kind": {
+ "name": "worktree_kind",
+ "schema": "public",
+ "values": [
+ "integration",
+ "agent"
+ ]
+ },
+ "public.worktree_status": {
+ "name": "worktree_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "frozen",
+ "merged",
+ "discarded"
+ ]
+ }
+ },
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/0059_snapshot.json b/packages/db/drizzle/meta/0059_snapshot.json
new file mode 100644
index 000000000..99e738fb3
--- /dev/null
+++ b/packages/db/drizzle/meta/0059_snapshot.json
@@ -0,0 +1,9782 @@
+{
+ "id": "ac0f55f2-bd22-46dc-b6b5-aa0d3aea10ec",
+ "prevId": "291036f3-e9f0-4da1-bea7-6a53290306e6",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.access_requests": {
+ "name": "access_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_login": {
+ "name": "github_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "persona": {
+ "name": "persona",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building": {
+ "name": "building",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "referrer": {
+ "name": "referrer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ip_hash": {
+ "name": "ip_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "access_request_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "invited_at": {
+ "name": "invited_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invite_token_hash": {
+ "name": "invite_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invite_token_expires_at": {
+ "name": "invite_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "access_requests_email_idx": {
+ "name": "access_requests_email_idx",
+ "columns": [
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_status_created_idx": {
+ "name": "access_requests_status_created_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_ip_created_idx": {
+ "name": "access_requests_ip_created_idx",
+ "columns": [
+ {
+ "expression": "ip_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_invite_token_hash_idx": {
+ "name": "access_requests_invite_token_hash_idx",
+ "columns": [
+ {
+ "expression": "invite_token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_briefs": {
+ "name": "agent_briefs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "approach_summary": {
+ "name": "approach_summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "plan_steps": {
+ "name": "plan_steps",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "current_step": {
+ "name": "current_step",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "files_likely_to_touch": {
+ "name": "files_likely_to_touch",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "keywords": {
+ "name": "keywords",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_brief_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'planning'"
+ },
+ "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_briefs_session_idx": {
+ "name": "agent_briefs_session_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_briefs_workspace_status_idx": {
+ "name": "agent_briefs_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_briefs_workspace_id_workspaces_id_fk": {
+ "name": "agent_briefs_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_briefs",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_briefs_session_id_agent_sessions_id_fk": {
+ "name": "agent_briefs_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_briefs",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_events": {
+ "name": "agent_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "turn_id": {
+ "name": "turn_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_events_idempotency_idx": {
+ "name": "agent_events_idempotency_idx",
+ "columns": [
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_events_session_created_idx": {
+ "name": "agent_events_session_created_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_events_workspace_id_workspaces_id_fk": {
+ "name": "agent_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_events_session_id_agent_sessions_id_fk": {
+ "name": "agent_events_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_events_turn_id_agent_turns_id_fk": {
+ "name": "agent_events_turn_id_agent_turns_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "agent_turns",
+ "columnsFrom": [
+ "turn_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_session_import_artifacts": {
+ "name": "agent_session_import_artifacts",
+ "schema": "",
+ "columns": {
+ "import_id": {
+ "name": "import_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "media_type": {
+ "name": "media_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plaintext_sha256": {
+ "name": "plaintext_sha256",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plaintext_bytes": {
+ "name": "plaintext_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_payload": {
+ "name": "encrypted_payload",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_session_import_artifacts_created_idx": {
+ "name": "agent_session_import_artifacts_created_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_session_import_artifacts_import_id_agent_session_imports_id_fk": {
+ "name": "agent_session_import_artifacts_import_id_agent_session_imports_id_fk",
+ "tableFrom": "agent_session_import_artifacts",
+ "tableTo": "agent_session_imports",
+ "columnsFrom": [
+ "import_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_session_imports": {
+ "name": "agent_session_imports",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "imported_by": {
+ "name": "imported_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_import_id": {
+ "name": "parent_import_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_session_id": {
+ "name": "agent_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_provider": {
+ "name": "source_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_session_id": {
+ "name": "external_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capsule_schema_version": {
+ "name": "capsule_schema_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capsule_sha256": {
+ "name": "capsule_sha256",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_session_import_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'storing'"
+ },
+ "repository_status": {
+ "name": "repository_status",
+ "type": "repository_restore_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "continuation_mode": {
+ "name": "continuation_mode",
+ "type": "session_continuation_mode",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_session_imports_idempotency_idx": {
+ "name": "agent_session_imports_idempotency_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_workspace_status_idx": {
+ "name": "agent_session_imports_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_importer_idx": {
+ "name": "agent_session_imports_importer_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_source_idx": {
+ "name": "agent_session_imports_source_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_parent_idx": {
+ "name": "agent_session_imports_parent_idx",
+ "columns": [
+ {
+ "expression": "parent_import_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_active_writer_idx": {
+ "name": "agent_session_imports_active_writer_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_session_imports\".\"continuation_mode\" = 'native_resume' and \"agent_session_imports\".\"status\" in ('launching', 'active') and \"agent_session_imports\".\"deleted_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_session_imports_organization_id_organizations_id_fk": {
+ "name": "agent_session_imports_organization_id_organizations_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_workspace_id_workspaces_id_fk": {
+ "name": "agent_session_imports_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_imported_by_users_id_fk": {
+ "name": "agent_session_imports_imported_by_users_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "users",
+ "columnsFrom": [
+ "imported_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_parent_import_id_agent_session_imports_id_fk": {
+ "name": "agent_session_imports_parent_import_id_agent_session_imports_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "agent_session_imports",
+ "columnsFrom": [
+ "parent_import_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_worktree_id_worktrees_id_fk": {
+ "name": "agent_session_imports_worktree_id_worktrees_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_agent_session_id_agent_sessions_id_fk": {
+ "name": "agent_session_imports_agent_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "agent_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_sessions": {
+ "name": "agent_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_number": {
+ "name": "issue_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'Agent'"
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'gpt-5'"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'openai'"
+ },
+ "kind": {
+ "name": "kind",
+ "type": "agent_session_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'managed'"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_session_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'idle'"
+ },
+ "workflow_run_id": {
+ "name": "workflow_run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "interrupted_at": {
+ "name": "interrupted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_sessions_workspace_issue_idx": {
+ "name": "agent_sessions_workspace_issue_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "issue_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_sessions_workspace_status_idx": {
+ "name": "agent_sessions_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_sessions_workspace_id_workspaces_id_fk": {
+ "name": "agent_sessions_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_sessions_worktree_id_worktrees_id_fk": {
+ "name": "agent_sessions_worktree_id_worktrees_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_sessions_created_by_users_id_fk": {
+ "name": "agent_sessions_created_by_users_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_turns": {
+ "name": "agent_turns",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attachments": {
+ "name": "attachments",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_turn_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "workflow_run_id": {
+ "name": "workflow_run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_id": {
+ "name": "response_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output": {
+ "name": "output",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finished_at": {
+ "name": "finished_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_turns_session_created_idx": {
+ "name": "agent_turns_session_created_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_turns_session_id_agent_sessions_id_fk": {
+ "name": "agent_turns_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_turns",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_turns_author_id_users_id_fk": {
+ "name": "agent_turns_author_id_users_id_fk",
+ "tableFrom": "agent_turns",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.brain_entries": {
+ "name": "brain_entries",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "brain_entry_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "paths": {
+ "name": "paths",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "keywords": {
+ "name": "keywords",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "supersedes_id": {
+ "name": "supersedes_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "brain_entries_workspace_created_idx": {
+ "name": "brain_entries_workspace_created_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "brain_entries_workspace_kind_idx": {
+ "name": "brain_entries_workspace_kind_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "brain_entries_workspace_id_workspaces_id_fk": {
+ "name": "brain_entries_workspace_id_workspaces_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_entries_session_id_agent_sessions_id_fk": {
+ "name": "brain_entries_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "brain_entries_author_id_users_id_fk": {
+ "name": "brain_entries_author_id_users_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.brain_overlaps": {
+ "name": "brain_overlaps",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "left_session_id": {
+ "name": "left_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "right_session_id": {
+ "name": "right_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "brain_overlap_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "score": {
+ "name": "score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "evidence": {
+ "name": "evidence",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "rationale": {
+ "name": "rationale",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "status": {
+ "name": "status",
+ "type": "brain_overlap_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "detected_at": {
+ "name": "detected_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": {
+ "brain_overlaps_pair_kind_idx": {
+ "name": "brain_overlaps_pair_kind_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "left_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "right_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "brain_overlaps_workspace_status_idx": {
+ "name": "brain_overlaps_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "brain_overlaps_workspace_id_workspaces_id_fk": {
+ "name": "brain_overlaps_workspace_id_workspaces_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_overlaps_left_session_id_agent_sessions_id_fk": {
+ "name": "brain_overlaps_left_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "left_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_overlaps_right_session_id_agent_sessions_id_fk": {
+ "name": "brain_overlaps_right_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "right_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.claude_connection_sessions": {
+ "name": "claude_connection_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'USER'"
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "claude_connection_session_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'starting'"
+ },
+ "runner_id": {
+ "name": "runner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "authorize_url": {
+ "name": "authorize_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_reason": {
+ "name": "failure_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "claude_connection_sessions_user_idx": {
+ "name": "claude_connection_sessions_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "claude_connection_sessions_expiry_idx": {
+ "name": "claude_connection_sessions_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "claude_connection_sessions_user_id_users_id_fk": {
+ "name": "claude_connection_sessions_user_id_users_id_fk",
+ "tableFrom": "claude_connection_sessions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cli_access_tokens": {
+ "name": "cli_access_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'CoDev CLI'"
+ },
+ "client_type": {
+ "name": "client_type",
+ "type": "cli_client_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'cli'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_used_at": {
+ "name": "last_used_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "cli_access_tokens_token_hash_idx": {
+ "name": "cli_access_tokens_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_access_tokens_user_idx": {
+ "name": "cli_access_tokens_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_access_tokens_expiry_idx": {
+ "name": "cli_access_tokens_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cli_access_tokens_user_id_users_id_fk": {
+ "name": "cli_access_tokens_user_id_users_id_fk",
+ "tableFrom": "cli_access_tokens",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cli_device_authorizations": {
+ "name": "cli_device_authorizations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "device_code_hash": {
+ "name": "device_code_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_code": {
+ "name": "user_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "cli_device_authorization_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "client_type": {
+ "name": "client_type",
+ "type": "cli_client_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'cli'"
+ },
+ "approved_by": {
+ "name": "approved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "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": {
+ "cli_device_authorizations_device_code_idx": {
+ "name": "cli_device_authorizations_device_code_idx",
+ "columns": [
+ {
+ "expression": "device_code_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_device_authorizations_user_code_idx": {
+ "name": "cli_device_authorizations_user_code_idx",
+ "columns": [
+ {
+ "expression": "user_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_device_authorizations_expiry_idx": {
+ "name": "cli_device_authorizations_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cli_device_authorizations_approved_by_users_id_fk": {
+ "name": "cli_device_authorizations_approved_by_users_id_fk",
+ "tableFrom": "cli_device_authorizations",
+ "tableTo": "users",
+ "columnsFrom": [
+ "approved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.collaboration_conflict_resolutions": {
+ "name": "collaboration_conflict_resolutions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resolved_by": {
+ "name": "resolved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "strategy": {
+ "name": "strategy",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "snapshot_revision": {
+ "name": "snapshot_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result_revision": {
+ "name": "result_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "collaboration_conflict_resolutions_document_idx": {
+ "name": "collaboration_conflict_resolutions_document_idx",
+ "columns": [
+ {
+ "expression": "worktree_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "collaboration_conflict_resolutions_worktree_id_worktrees_id_fk": {
+ "name": "collaboration_conflict_resolutions_worktree_id_worktrees_id_fk",
+ "tableFrom": "collaboration_conflict_resolutions",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "collaboration_conflict_resolutions_resolved_by_users_id_fk": {
+ "name": "collaboration_conflict_resolutions_resolved_by_users_id_fk",
+ "tableFrom": "collaboration_conflict_resolutions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "resolved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversation_artifacts": {
+ "name": "conversation_artifacts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_url": {
+ "name": "source_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "downloadable": {
+ "name": "downloadable",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversation_artifacts_conversation_idx": {
+ "name": "conversation_artifacts_conversation_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "conversation_artifacts_message_idx": {
+ "name": "conversation_artifacts_message_idx",
+ "columns": [
+ {
+ "expression": "message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversation_artifacts_conversation_id_conversations_id_fk": {
+ "name": "conversation_artifacts_conversation_id_conversations_id_fk",
+ "tableFrom": "conversation_artifacts",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "conversation_artifacts_message_id_conversation_messages_id_fk": {
+ "name": "conversation_artifacts_message_id_conversation_messages_id_fk",
+ "tableFrom": "conversation_artifacts",
+ "tableTo": "conversation_messages",
+ "columnsFrom": [
+ "message_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversation_messages": {
+ "name": "conversation_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence": {
+ "name": "sequence",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_user_id": {
+ "name": "author_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_name": {
+ "name": "author_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_content_type": {
+ "name": "source_content_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_created_at": {
+ "name": "source_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversation_messages_sequence_idx": {
+ "name": "conversation_messages_sequence_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sequence",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversation_messages_conversation_id_conversations_id_fk": {
+ "name": "conversation_messages_conversation_id_conversations_id_fk",
+ "tableFrom": "conversation_messages",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "conversation_messages_author_user_id_users_id_fk": {
+ "name": "conversation_messages_author_user_id_users_id_fk",
+ "tableFrom": "conversation_messages",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversations": {
+ "name": "conversations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'imported'"
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_provider": {
+ "name": "source_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_external_id": {
+ "name": "source_external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_url": {
+ "name": "source_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_model": {
+ "name": "source_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_updated_at": {
+ "name": "source_updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "warnings": {
+ "name": "warnings",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversations_owner_updated_idx": {
+ "name": "conversations_owner_updated_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "conversations_owner_source_idx": {
+ "name": "conversations_owner_source_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_external_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversations_owner_id_users_id_fk": {
+ "name": "conversations_owner_id_users_id_fk",
+ "tableFrom": "conversations",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.coordination_messages": {
+ "name": "coordination_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "from_session_id": {
+ "name": "from_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "to_session_id": {
+ "name": "to_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "correlation_id": {
+ "name": "correlation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "response_to_id": {
+ "name": "response_to_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "coordination_message_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "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": {
+ "coordination_messages_target_status_idx": {
+ "name": "coordination_messages_target_status_idx",
+ "columns": [
+ {
+ "expression": "to_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "coordination_messages_workspace_id_workspaces_id_fk": {
+ "name": "coordination_messages_workspace_id_workspaces_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coordination_messages_from_session_id_agent_sessions_id_fk": {
+ "name": "coordination_messages_from_session_id_agent_sessions_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "from_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coordination_messages_to_session_id_agent_sessions_id_fk": {
+ "name": "coordination_messages_to_session_id_agent_sessions_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "to_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.design_partner_feedback": {
+ "name": "design_partner_feedback",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "category": {
+ "name": "category",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rating": {
+ "name": "rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "page": {
+ "name": "page",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "release": {
+ "name": "release",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'new'"
+ },
+ "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": {
+ "design_partner_feedback_user_created_idx": {
+ "name": "design_partner_feedback_user_created_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "design_partner_feedback_status_created_idx": {
+ "name": "design_partner_feedback_status_created_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "design_partner_feedback_user_id_users_id_fk": {
+ "name": "design_partner_feedback_user_id_users_id_fk",
+ "tableFrom": "design_partner_feedback",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "design_partner_feedback_workspace_id_workspaces_id_fk": {
+ "name": "design_partner_feedback_workspace_id_workspaces_id_fk",
+ "tableFrom": "design_partner_feedback",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.feature_override_audit_events": {
+ "name": "feature_override_audit_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_user_id": {
+ "name": "target_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_user_id": {
+ "name": "actor_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "feature_override_audit_action",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "previous_enabled": {
+ "name": "previous_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "previous_expires_at": {
+ "name": "previous_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "feature_override_audit_org_created_idx": {
+ "name": "feature_override_audit_org_created_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "feature_override_audit_user_created_idx": {
+ "name": "feature_override_audit_user_created_idx",
+ "columns": [
+ {
+ "expression": "target_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "feature_override_audit_events_organization_id_organizations_id_fk": {
+ "name": "feature_override_audit_events_organization_id_organizations_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "feature_override_audit_events_target_user_id_users_id_fk": {
+ "name": "feature_override_audit_events_target_user_id_users_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "target_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "feature_override_audit_events_actor_user_id_users_id_fk": {
+ "name": "feature_override_audit_events_actor_user_id_users_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_agent_turns": {
+ "name": "gen2_agent_turns",
+ "schema": "",
+ "columns": {
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "output": {
+ "name": "output",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "pending_base64": {
+ "name": "pending_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "exited": {
+ "name": "exited",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "reply_message_id": {
+ "name": "reply_message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_agent_turns_chat_idx": {
+ "name": "gen2_agent_turns_chat_idx",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_agent_turns_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_agent_turns_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_chat_id_gen2_chats_id_fk": {
+ "name": "gen2_agent_turns_chat_id_gen2_chats_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_chats",
+ "columnsFrom": [
+ "chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_user_id_users_id_fk": {
+ "name": "gen2_agent_turns_user_id_users_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_reply_message_id_gen2_chat_messages_id_fk": {
+ "name": "gen2_agent_turns_reply_message_id_gen2_chat_messages_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_chat_messages",
+ "columnsFrom": [
+ "reply_message_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_chat_messages": {
+ "name": "gen2_chat_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "items": {
+ "name": "items",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_chat_messages_chat_idx": {
+ "name": "gen2_chat_messages_chat_idx",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_chat_messages_chat_id_gen2_chats_id_fk": {
+ "name": "gen2_chat_messages_chat_id_gen2_chats_id_fk",
+ "tableFrom": "gen2_chat_messages",
+ "tableTo": "gen2_chats",
+ "columnsFrom": [
+ "chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_chats": {
+ "name": "gen2_chats",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_chats_workspace_updated_idx": {
+ "name": "gen2_chats_workspace_updated_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_chats_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_chats_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_chats",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_chats_created_by_user_id_users_id_fk": {
+ "name": "gen2_chats_created_by_user_id_users_id_fk",
+ "tableFrom": "gen2_chats",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_superset_run_events": {
+ "name": "gen2_superset_run_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "run_id": {
+ "name": "run_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result": {
+ "name": "result",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_superset_run_events_run_created_idx": {
+ "name": "gen2_superset_run_events_run_created_idx",
+ "columns": [
+ {
+ "expression": "run_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_superset_run_events_run_id_gen2_superset_runs_id_fk": {
+ "name": "gen2_superset_run_events_run_id_gen2_superset_runs_id_fk",
+ "tableFrom": "gen2_superset_run_events",
+ "tableTo": "gen2_superset_runs",
+ "columnsFrom": [
+ "run_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_run_events_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_superset_run_events_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_superset_run_events",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_run_events_actor_id_users_id_fk": {
+ "name": "gen2_superset_run_events_actor_id_users_id_fk",
+ "tableFrom": "gen2_superset_run_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_superset_runs": {
+ "name": "gen2_superset_runs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "host_workspace_id": {
+ "name": "host_workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "host_terminal_id": {
+ "name": "host_terminal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "host_agent_session_id": {
+ "name": "host_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "credential_provider",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_revision": {
+ "name": "credential_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "gen2_superset_run_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'creating'"
+ },
+ "lease_claimed": {
+ "name": "lease_claimed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "exit_reason": {
+ "name": "exit_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "recovery_count": {
+ "name": "recovery_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_superset_runs_workspace_idempotency_idx": {
+ "name": "gen2_superset_runs_workspace_idempotency_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "gen2_superset_runs_workspace_status_idx": {
+ "name": "gen2_superset_runs_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "gen2_superset_runs_chat_idx": {
+ "name": "gen2_superset_runs_chat_idx",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_superset_runs_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_superset_runs_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_runs_chat_id_gen2_chats_id_fk": {
+ "name": "gen2_superset_runs_chat_id_gen2_chats_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "gen2_chats",
+ "columnsFrom": [
+ "chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_runs_created_by_users_id_fk": {
+ "name": "gen2_superset_runs_created_by_users_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_runs_connection_id_provider_credentials_id_fk": {
+ "name": "gen2_superset_runs_connection_id_provider_credentials_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "provider_credentials",
+ "columnsFrom": [
+ "connection_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_workspace_members": {
+ "name": "gen2_workspace_members",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "gen2_workspace_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'editor'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_workspace_members_user_idx": {
+ "name": "gen2_workspace_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_workspace_members_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_workspace_members_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_workspace_members",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_workspace_members_user_id_users_id_fk": {
+ "name": "gen2_workspace_members_user_id_users_id_fk",
+ "tableFrom": "gen2_workspace_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "gen2_workspace_members_workspace_id_user_id_pk": {
+ "name": "gen2_workspace_members_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_workspaces": {
+ "name": "gen2_workspaces",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "gen2_workspace_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "sandbox_id": {
+ "name": "sandbox_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_token_hash": {
+ "name": "active_invite_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_created_by_user_id": {
+ "name": "active_invite_created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_role": {
+ "name": "active_invite_role",
+ "type": "gen2_workspace_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_created_at": {
+ "name": "active_invite_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_expires_at": {
+ "name": "active_invite_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_installation_id": {
+ "name": "github_installation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository": {
+ "name": "repository",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_private": {
+ "name": "repository_private",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "default_branch": {
+ "name": "default_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_workspaces_owner_idx": {
+ "name": "gen2_workspaces_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "gen2_workspaces_active_invite_token_hash_idx": {
+ "name": "gen2_workspaces_active_invite_token_hash_idx",
+ "columns": [
+ {
+ "expression": "active_invite_token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_workspaces_owner_id_users_id_fk": {
+ "name": "gen2_workspaces_owner_id_users_id_fk",
+ "tableFrom": "gen2_workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "gen2_workspaces_active_invite_created_by_user_id_users_id_fk": {
+ "name": "gen2_workspaces_active_invite_created_by_user_id_users_id_fk",
+ "tableFrom": "gen2_workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "active_invite_created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_yjs_documents": {
+ "name": "gen2_yjs_documents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'main'"
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "update_base64": {
+ "name": "update_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state_vector_base64": {
+ "name": "state_vector_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_contents": {
+ "name": "filesystem_contents",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_conflict": {
+ "name": "has_conflict",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "conflict_filesystem_revision": {
+ "name": "conflict_filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_detected_at": {
+ "name": "conflict_detected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_yjs_documents_workspace_worktree_path_idx": {
+ "name": "gen2_yjs_documents_workspace_worktree_path_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "worktree_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_yjs_documents_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_yjs_documents_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_yjs_documents",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_connections": {
+ "name": "github_connections",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "encrypted_access_token": {
+ "name": "encrypted_access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_refresh_token": {
+ "name": "encrypted_refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'bearer'"
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "github_connections_access_expiry_idx": {
+ "name": "github_connections_access_expiry_idx",
+ "columns": [
+ {
+ "expression": "access_token_expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "github_connections_user_id_users_id_fk": {
+ "name": "github_connections_user_id_users_id_fk",
+ "tableFrom": "github_connections",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_issue_assignments": {
+ "name": "github_issue_assignments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_number": {
+ "name": "issue_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_issue_id": {
+ "name": "github_issue_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "github_issue_assignments_repository_issue_idx": {
+ "name": "github_issue_assignments_repository_issue_idx",
+ "columns": [
+ {
+ "expression": "github_repository_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "issue_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "github_issue_assignments_session_idx": {
+ "name": "github_issue_assignments_session_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "github_issue_assignments_workspace_idx": {
+ "name": "github_issue_assignments_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "github_issue_assignments_workspace_id_workspaces_id_fk": {
+ "name": "github_issue_assignments_workspace_id_workspaces_id_fk",
+ "tableFrom": "github_issue_assignments",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "github_issue_assignments_session_id_agent_sessions_id_fk": {
+ "name": "github_issue_assignments_session_id_agent_sessions_id_fk",
+ "tableFrom": "github_issue_assignments",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.mobile_push_tokens": {
+ "name": "mobile_push_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expo_push_token": {
+ "name": "expo_push_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "mobile_platform",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "device_id": {
+ "name": "device_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_seen_at": {
+ "name": "last_seen_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": {
+ "mobile_push_tokens_token_idx": {
+ "name": "mobile_push_tokens_token_idx",
+ "columns": [
+ {
+ "expression": "expo_push_token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "mobile_push_tokens_user_idx": {
+ "name": "mobile_push_tokens_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mobile_push_tokens_user_id_users_id_fk": {
+ "name": "mobile_push_tokens_user_id_users_id_fk",
+ "tableFrom": "mobile_push_tokens",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_feature_overrides": {
+ "name": "organization_feature_overrides",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "organization_feature_overrides_organization_id_organizations_id_fk": {
+ "name": "organization_feature_overrides_organization_id_organizations_id_fk",
+ "tableFrom": "organization_feature_overrides",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_feature_overrides_created_by_users_id_fk": {
+ "name": "organization_feature_overrides_created_by_users_id_fk",
+ "tableFrom": "organization_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "organization_feature_overrides_organization_id_feature_pk": {
+ "name": "organization_feature_overrides_organization_id_feature_pk",
+ "columns": [
+ "organization_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_members": {
+ "name": "organization_members",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "organization_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organization_members_user_idx": {
+ "name": "organization_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organization_members_organization_id_organizations_id_fk": {
+ "name": "organization_members_organization_id_organizations_id_fk",
+ "tableFrom": "organization_members",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_members_user_id_users_id_fk": {
+ "name": "organization_members_user_id_users_id_fk",
+ "tableFrom": "organization_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "organization_members_organization_id_user_id_pk": {
+ "name": "organization_members_organization_id_user_id_pk",
+ "columns": [
+ "organization_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_subscriptions": {
+ "name": "organization_subscriptions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "organization_subscription_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_customer_id": {
+ "name": "provider_customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_subscription_id": {
+ "name": "provider_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_period_end": {
+ "name": "current_period_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "canceled_at": {
+ "name": "canceled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organization_subscriptions_org_idx": {
+ "name": "organization_subscriptions_org_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "organization_subscriptions_provider_idx": {
+ "name": "organization_subscriptions_provider_idx",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organization_subscriptions_organization_id_organizations_id_fk": {
+ "name": "organization_subscriptions_organization_id_organizations_id_fk",
+ "tableFrom": "organization_subscriptions",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_subscriptions_plan_id_plans_id_fk": {
+ "name": "organization_subscriptions_plan_id_plans_id_fk",
+ "tableFrom": "organization_subscriptions",
+ "tableTo": "plans",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organizations": {
+ "name": "organizations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organizations_slug_idx": {
+ "name": "organizations_slug_idx",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.page_views": {
+ "name": "page_views",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "referrer": {
+ "name": "referrer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ip_hash": {
+ "name": "ip_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "page_views_created_idx": {
+ "name": "page_views_created_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "page_views_user_created_idx": {
+ "name": "page_views_user_created_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "page_views_path_created_idx": {
+ "name": "page_views_path_created_idx",
+ "columns": [
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "page_views_user_id_users_id_fk": {
+ "name": "page_views_user_id_users_id_fk",
+ "tableFrom": "page_views",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.path_claims": {
+ "name": "path_claims",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path_glob": {
+ "name": "path_glob",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "intent": {
+ "name": "intent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "claim_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "path_claims_session_status_idx": {
+ "name": "path_claims_session_status_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "path_claims_expiry_idx": {
+ "name": "path_claims_expiry_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "path_claims_session_id_agent_sessions_id_fk": {
+ "name": "path_claims_session_id_agent_sessions_id_fk",
+ "tableFrom": "path_claims",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan_entitlements": {
+ "name": "plan_entitlements",
+ "schema": "",
+ "columns": {
+ "plan_id": {
+ "name": "plan_id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "plan_entitlements_plan_id_plans_id_fk": {
+ "name": "plan_entitlements_plan_id_plans_id_fk",
+ "tableFrom": "plan_entitlements",
+ "tableTo": "plans",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "plan_entitlements_plan_id_feature_pk": {
+ "name": "plan_entitlements_plan_id_feature_pk",
+ "columns": [
+ "plan_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plans": {
+ "name": "plans",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.provider_credential_events": {
+ "name": "provider_credential_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "credential_provider",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result": {
+ "name": "result",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "provider_credential_events_credential_created_idx": {
+ "name": "provider_credential_events_credential_created_idx",
+ "columns": [
+ {
+ "expression": "credential_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credential_events_actor_created_idx": {
+ "name": "provider_credential_events_actor_created_idx",
+ "columns": [
+ {
+ "expression": "actor_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "provider_credential_events_actor_id_users_id_fk": {
+ "name": "provider_credential_events_actor_id_users_id_fk",
+ "tableFrom": "provider_credential_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "provider_credential_events_workspace_id_workspaces_id_fk": {
+ "name": "provider_credential_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "provider_credential_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.provider_credentials": {
+ "name": "provider_credentials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "credential_provider",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_type": {
+ "name": "credential_type",
+ "type": "credential_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "priority_order": {
+ "name": "priority_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "encrypted_api_key": {
+ "name": "encrypted_api_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_access_token": {
+ "name": "encrypted_access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_refresh_token": {
+ "name": "encrypted_refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "endpoint_url": {
+ "name": "endpoint_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "aws_role_arn": {
+ "name": "aws_role_arn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_connected": {
+ "name": "is_connected",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_four": {
+ "name": "last_four",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "provider_credential_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "provider_subject_hash": {
+ "name": "provider_subject_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_material": {
+ "name": "encrypted_material",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_refreshed_at": {
+ "name": "last_refreshed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sharing_enabled": {
+ "name": "sharing_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "unavailable_until": {
+ "name": "unavailable_until",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "connected_via": {
+ "name": "connected_via",
+ "type": "credential_connected_via",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "allow_in_shared_workspaces": {
+ "name": "allow_in_shared_workspaces",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "provider_credentials_scope_provider_type_idx": {
+ "name": "provider_credentials_scope_provider_type_idx",
+ "columns": [
+ {
+ "expression": "scope_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scope_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "credential_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credentials_scope_provider_priority_idx": {
+ "name": "provider_credentials_scope_provider_priority_idx",
+ "columns": [
+ {
+ "expression": "scope_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scope_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "priority_order",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credentials_status_idx": {
+ "name": "provider_credentials_status_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "provider_credentials_created_by_users_id_fk": {
+ "name": "provider_credentials_created_by_users_id_fk",
+ "tableFrom": "provider_credentials",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.published_branches": {
+ "name": "published_branches",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "published_by": {
+ "name": "published_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "branch_name": {
+ "name": "branch_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "publication_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "source_head_sha": {
+ "name": "source_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "commit_sha": {
+ "name": "commit_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_id": {
+ "name": "repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "remote_ref": {
+ "name": "remote_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "html_url": {
+ "name": "html_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pull_request_number": {
+ "name": "pull_request_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pull_request_url": {
+ "name": "pull_request_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "request_id": {
+ "name": "request_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "published_at": {
+ "name": "published_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "published_branches_workspace_name_idx": {
+ "name": "published_branches_workspace_name_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "branch_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "published_branches_workspace_request_idx": {
+ "name": "published_branches_workspace_request_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "request_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "published_branches_workspace_status_idx": {
+ "name": "published_branches_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "published_branches_workspace_id_workspaces_id_fk": {
+ "name": "published_branches_workspace_id_workspaces_id_fk",
+ "tableFrom": "published_branches",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "published_branches_published_by_users_id_fk": {
+ "name": "published_branches_published_by_users_id_fk",
+ "tableFrom": "published_branches",
+ "tableTo": "users",
+ "columnsFrom": [
+ "published_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.runtime_hosts": {
+ "name": "runtime_hosts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "runtime_address": {
+ "name": "runtime_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifecycle_state": {
+ "name": "lifecycle_state",
+ "type": "runtime_host_lifecycle",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'provisioning'"
+ },
+ "max_workspace_slots": {
+ "name": "max_workspace_slots",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 4
+ },
+ "free_workspace_slots": {
+ "name": "free_workspace_slots",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 4
+ },
+ "image_version": {
+ "name": "image_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_heartbeat_at": {
+ "name": "last_heartbeat_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "draining_at": {
+ "name": "draining_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "runtime_hosts_provider_id_idx": {
+ "name": "runtime_hosts_provider_id_idx",
+ "columns": [
+ {
+ "expression": "provider_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "runtime_hosts_runtime_address_idx": {
+ "name": "runtime_hosts_runtime_address_idx",
+ "columns": [
+ {
+ "expression": "runtime_address",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "runtime_hosts_capacity_idx": {
+ "name": "runtime_hosts_capacity_idx",
+ "columns": [
+ {
+ "expression": "lifecycle_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "free_workspace_slots",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sandbox_runtime_intervals": {
+ "name": "sandbox_runtime_intervals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ended_at": {
+ "name": "ended_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "sandbox_runtime_intervals_user_open_idx": {
+ "name": "sandbox_runtime_intervals_user_open_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "ended_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "sandbox_runtime_intervals_workspace_open_idx": {
+ "name": "sandbox_runtime_intervals_workspace_open_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "ended_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "sandbox_runtime_intervals_user_id_users_id_fk": {
+ "name": "sandbox_runtime_intervals_user_id_users_id_fk",
+ "tableFrom": "sandbox_runtime_intervals",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sandbox_runtime_intervals_workspace_id_workspaces_id_fk": {
+ "name": "sandbox_runtime_intervals_workspace_id_workspaces_id_fk",
+ "tableFrom": "sandbox_runtime_intervals",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chat_invites": {
+ "name": "shared_chat_invites",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "shared_chat_id": {
+ "name": "shared_chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_token": {
+ "name": "encrypted_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_by": {
+ "name": "accepted_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chat_invites_token_hash_idx": {
+ "name": "shared_chat_invites_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "shared_chat_invites_room_idx": {
+ "name": "shared_chat_invites_room_idx",
+ "columns": [
+ {
+ "expression": "shared_chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chat_invites_shared_chat_id_shared_chats_id_fk": {
+ "name": "shared_chat_invites_shared_chat_id_shared_chats_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "shared_chats",
+ "columnsFrom": [
+ "shared_chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_invites_created_by_users_id_fk": {
+ "name": "shared_chat_invites_created_by_users_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_invites_accepted_by_users_id_fk": {
+ "name": "shared_chat_invites_accepted_by_users_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "accepted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chat_members": {
+ "name": "shared_chat_members",
+ "schema": "",
+ "columns": {
+ "shared_chat_id": {
+ "name": "shared_chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chat_members_user_idx": {
+ "name": "shared_chat_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chat_members_shared_chat_id_shared_chats_id_fk": {
+ "name": "shared_chat_members_shared_chat_id_shared_chats_id_fk",
+ "tableFrom": "shared_chat_members",
+ "tableTo": "shared_chats",
+ "columnsFrom": [
+ "shared_chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_members_user_id_users_id_fk": {
+ "name": "shared_chat_members_user_id_users_id_fk",
+ "tableFrom": "shared_chat_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "shared_chat_members_shared_chat_id_user_id_pk": {
+ "name": "shared_chat_members_shared_chat_id_user_id_pk",
+ "columns": [
+ "shared_chat_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chats": {
+ "name": "shared_chats",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chats_conversation_idx": {
+ "name": "shared_chats_conversation_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "shared_chats_owner_updated_idx": {
+ "name": "shared_chats_owner_updated_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chats_conversation_id_conversations_id_fk": {
+ "name": "shared_chats_conversation_id_conversations_id_fk",
+ "tableFrom": "shared_chats",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chats_owner_id_users_id_fk": {
+ "name": "shared_chats_owner_id_users_id_fk",
+ "tableFrom": "shared_chats",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_compute_usage": {
+ "name": "user_compute_usage",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "minutes_used": {
+ "name": "minutes_used",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_compute_usage_user_id_users_id_fk": {
+ "name": "user_compute_usage_user_id_users_id_fk",
+ "tableFrom": "user_compute_usage",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_environment_variables": {
+ "name": "user_environment_variables",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_value": {
+ "name": "encrypted_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_four": {
+ "name": "last_four",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_environment_variables_user_name_idx": {
+ "name": "user_environment_variables_user_name_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_environment_variables_user_updated_idx": {
+ "name": "user_environment_variables_user_updated_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_environment_variables_user_id_users_id_fk": {
+ "name": "user_environment_variables_user_id_users_id_fk",
+ "tableFrom": "user_environment_variables",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_feature_overrides": {
+ "name": "user_feature_overrides",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_feature_overrides_user_idx": {
+ "name": "user_feature_overrides_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_feature_overrides_organization_id_organizations_id_fk": {
+ "name": "user_feature_overrides_organization_id_organizations_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_feature_overrides_user_id_users_id_fk": {
+ "name": "user_feature_overrides_user_id_users_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_feature_overrides_created_by_users_id_fk": {
+ "name": "user_feature_overrides_created_by_users_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "user_feature_overrides_organization_id_user_id_feature_pk": {
+ "name": "user_feature_overrides_organization_id_user_id_feature_pk",
+ "columns": [
+ "organization_id",
+ "user_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.users": {
+ "name": "users",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "github_user_id": {
+ "name": "github_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "google_user_id": {
+ "name": "google_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "clerk_user_id": {
+ "name": "clerk_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "login": {
+ "name": "login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password_hash": {
+ "name": "password_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avatar_url": {
+ "name": "avatar_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_admin": {
+ "name": "is_admin",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "users_github_user_id_idx": {
+ "name": "users_github_user_id_idx",
+ "columns": [
+ {
+ "expression": "github_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_google_user_id_idx": {
+ "name": "users_google_user_id_idx",
+ "columns": [
+ {
+ "expression": "google_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_clerk_user_id_idx": {
+ "name": "users_clerk_user_id_idx",
+ "columns": [
+ {
+ "expression": "clerk_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_login_idx": {
+ "name": "users_login_idx",
+ "columns": [
+ {
+ "expression": "login",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channel_messages": {
+ "name": "workspace_channel_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_kind": {
+ "name": "author_kind",
+ "type": "channel_message_author_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_label": {
+ "name": "author_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_session_id": {
+ "name": "agent_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mentions": {
+ "name": "mentions",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "mentions_agent": {
+ "name": "mentions_agent",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channel_messages_channel_idx": {
+ "name": "workspace_channel_messages_channel_idx",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_channel_messages_workspace_idx": {
+ "name": "workspace_channel_messages_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channel_messages_channel_id_workspace_channels_id_fk": {
+ "name": "workspace_channel_messages_channel_id_workspace_channels_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "workspace_channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_workspace_id_workspaces_id_fk": {
+ "name": "workspace_channel_messages_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_author_id_users_id_fk": {
+ "name": "workspace_channel_messages_author_id_users_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_agent_session_id_agent_sessions_id_fk": {
+ "name": "workspace_channel_messages_agent_session_id_agent_sessions_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "agent_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channel_reads": {
+ "name": "workspace_channel_reads",
+ "schema": "",
+ "columns": {
+ "channel_id": {
+ "name": "channel_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_read_at": {
+ "name": "last_read_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channel_reads_user_idx": {
+ "name": "workspace_channel_reads_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channel_reads_channel_id_workspace_channels_id_fk": {
+ "name": "workspace_channel_reads_channel_id_workspace_channels_id_fk",
+ "tableFrom": "workspace_channel_reads",
+ "tableTo": "workspace_channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_reads_user_id_users_id_fk": {
+ "name": "workspace_channel_reads_user_id_users_id_fk",
+ "tableFrom": "workspace_channel_reads",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_channel_reads_channel_id_user_id_pk": {
+ "name": "workspace_channel_reads_channel_id_user_id_pk",
+ "columns": [
+ "channel_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channels": {
+ "name": "workspace_channels",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "topic": {
+ "name": "topic",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_access": {
+ "name": "agent_access",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channels_workspace_slug_idx": {
+ "name": "workspace_channels_workspace_slug_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_channels_workspace_idx": {
+ "name": "workspace_channels_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "archived_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channels_workspace_id_workspaces_id_fk": {
+ "name": "workspace_channels_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_channels",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channels_created_by_users_id_fk": {
+ "name": "workspace_channels_created_by_users_id_fk",
+ "tableFrom": "workspace_channels",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_leases": {
+ "name": "workspace_chat_leases",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "holder_id": {
+ "name": "holder_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lease_token": {
+ "name": "lease_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_leases_expiry_idx": {
+ "name": "workspace_chat_leases_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_leases_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_leases_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_leases",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_leases_holder_id_users_id_fk": {
+ "name": "workspace_chat_leases_holder_id_users_id_fk",
+ "tableFrom": "workspace_chat_leases",
+ "tableTo": "users",
+ "columnsFrom": [
+ "holder_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_chat_leases_workspace_id_chat_id_pk": {
+ "name": "workspace_chat_leases_workspace_id_chat_id_pk",
+ "columns": [
+ "workspace_id",
+ "chat_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_participants": {
+ "name": "workspace_chat_participants",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_participants_expiry_idx": {
+ "name": "workspace_chat_participants_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_participants_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_participants_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_participants",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_participants_user_id_users_id_fk": {
+ "name": "workspace_chat_participants_user_id_users_id_fk",
+ "tableFrom": "workspace_chat_participants",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_chat_participants_workspace_id_chat_id_user_id_client_id_pk": {
+ "name": "workspace_chat_participants_workspace_id_chat_id_user_id_client_id_pk",
+ "columns": [
+ "workspace_id",
+ "chat_id",
+ "user_id",
+ "client_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_prompt_receipts": {
+ "name": "workspace_chat_prompt_receipts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_message_id": {
+ "name": "client_message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attachments": {
+ "name": "attachments",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "effort": {
+ "name": "effort",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_prompt_receipts_client_message_idx": {
+ "name": "workspace_chat_prompt_receipts_client_message_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "client_message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_chat_prompt_receipts_chat_created_idx": {
+ "name": "workspace_chat_prompt_receipts_chat_created_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_prompt_receipts_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_prompt_receipts_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_prompt_receipts",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_prompt_receipts_author_id_users_id_fk": {
+ "name": "workspace_chat_prompt_receipts_author_id_users_id_fk",
+ "tableFrom": "workspace_chat_prompt_receipts",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_events": {
+ "name": "workspace_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence": {
+ "name": "sequence",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_events_sequence_idx": {
+ "name": "workspace_events_sequence_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sequence",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_events_workspace_id_workspaces_id_fk": {
+ "name": "workspace_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_events_actor_id_users_id_fk": {
+ "name": "workspace_events_actor_id_users_id_fk",
+ "tableFrom": "workspace_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_invites": {
+ "name": "workspace_invites",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "invitee_email": {
+ "name": "invitee_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invitee_login": {
+ "name": "invitee_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_role": {
+ "name": "access_role",
+ "type": "workspace_access_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'viewer'"
+ },
+ "allow_link": {
+ "name": "allow_link",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_by": {
+ "name": "accepted_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_invites_token_hash_idx": {
+ "name": "workspace_invites_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_invites_workspace_idx": {
+ "name": "workspace_invites_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_invites_workspace_id_workspaces_id_fk": {
+ "name": "workspace_invites_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_invites_created_by_users_id_fk": {
+ "name": "workspace_invites_created_by_users_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_invites_accepted_by_users_id_fk": {
+ "name": "workspace_invites_accepted_by_users_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "accepted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_member_statuses": {
+ "name": "workspace_member_statuses",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emoji": {
+ "name": "emoji",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "headline": {
+ "name": "headline",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_member_statuses_workspace_idx": {
+ "name": "workspace_member_statuses_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_member_statuses_workspace_id_workspaces_id_fk": {
+ "name": "workspace_member_statuses_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_member_statuses",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_member_statuses_user_id_users_id_fk": {
+ "name": "workspace_member_statuses_user_id_users_id_fk",
+ "tableFrom": "workspace_member_statuses",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_member_statuses_workspace_id_user_id_pk": {
+ "name": "workspace_member_statuses_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_members": {
+ "name": "workspace_members",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "member_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "access_role": {
+ "name": "access_role",
+ "type": "workspace_access_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'viewer'"
+ },
+ "can_terminal": {
+ "name": "can_terminal",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "can_merge": {
+ "name": "can_merge",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_members_user_idx": {
+ "name": "workspace_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_members_workspace_id_workspaces_id_fk": {
+ "name": "workspace_members_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_members",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_members_user_id_users_id_fk": {
+ "name": "workspace_members_user_id_users_id_fk",
+ "tableFrom": "workspace_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_members_workspace_id_user_id_pk": {
+ "name": "workspace_members_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_runtime_assignments": {
+ "name": "workspace_runtime_assignments",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "host_id": {
+ "name": "host_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "generation": {
+ "name": "generation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "fencing_token": {
+ "name": "fencing_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "disk_id": {
+ "name": "disk_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "disk_lun": {
+ "name": "disk_lun",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "runtime_state": {
+ "name": "runtime_state",
+ "type": "workspace_runtime_assignment_state",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'assigned'"
+ },
+ "last_used_at": {
+ "name": "last_used_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": {
+ "workspace_runtime_assignments_host_state_idx": {
+ "name": "workspace_runtime_assignments_host_state_idx",
+ "columns": [
+ {
+ "expression": "host_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "runtime_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_runtime_assignments_state_updated_idx": {
+ "name": "workspace_runtime_assignments_state_updated_idx",
+ "columns": [
+ {
+ "expression": "runtime_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_runtime_assignments_workspace_id_workspaces_id_fk": {
+ "name": "workspace_runtime_assignments_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_runtime_assignments",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_runtime_assignments_host_id_runtime_hosts_id_fk": {
+ "name": "workspace_runtime_assignments_host_id_runtime_hosts_id_fk",
+ "tableFrom": "workspace_runtime_assignments",
+ "tableTo": "runtime_hosts",
+ "columnsFrom": [
+ "host_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_runtimes": {
+ "name": "workspace_runtimes",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "sandbox_id": {
+ "name": "sandbox_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "backend": {
+ "name": "backend",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'firecracker'"
+ },
+ "status": {
+ "name": "status",
+ "type": "sandbox_runtime_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'provisioning'"
+ },
+ "provisioned_head_sha": {
+ "name": "provisioned_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "snapshot_ref": {
+ "name": "snapshot_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_heartbeat_at": {
+ "name": "last_heartbeat_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hibernated_at": {
+ "name": "hibernated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provisioned_at": {
+ "name": "provisioned_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stopped_at": {
+ "name": "stopped_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_runtimes_status_updated_idx": {
+ "name": "workspace_runtimes_status_updated_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_runtimes_workspace_id_workspaces_id_fk": {
+ "name": "workspace_runtimes_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_runtimes",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "workspace_runtimes_sandbox_id_unique": {
+ "name": "workspace_runtimes_sandbox_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "sandbox_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_snapshots": {
+ "name": "workspace_snapshots",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "snapshot": {
+ "name": "snapshot",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_bytes": {
+ "name": "total_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_snapshots_updated_idx": {
+ "name": "workspace_snapshots_updated_idx",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_snapshots_workspace_id_workspaces_id_fk": {
+ "name": "workspace_snapshots_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_snapshots",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_state_documents": {
+ "name": "workspace_state_documents",
+ "schema": "",
+ "columns": {
+ "document_name": {
+ "name": "document_name",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state": {
+ "name": "state",
+ "type": "bytea",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_state_documents_workspace_idx": {
+ "name": "workspace_state_documents_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_state_documents_workspace_id_workspaces_id_fk": {
+ "name": "workspace_state_documents_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_state_documents",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspaces": {
+ "name": "workspaces",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_installation_id": {
+ "name": "github_installation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository": {
+ "name": "repository",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repository_visibility": {
+ "name": "repository_visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "default_branch": {
+ "name": "default_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "workspace_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "last_activity_at": {
+ "name": "last_activity_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "hibernate_at": {
+ "name": "hibernate_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspaces_owner_idx": {
+ "name": "workspaces_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_organization_idx": {
+ "name": "workspaces_organization_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_repository_idx": {
+ "name": "workspaces_repository_idx",
+ "columns": [
+ {
+ "expression": "github_repository_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_status_expiry_idx": {
+ "name": "workspaces_status_expiry_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_deleted_idx": {
+ "name": "workspaces_deleted_idx",
+ "columns": [
+ {
+ "expression": "deleted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspaces_owner_id_users_id_fk": {
+ "name": "workspaces_owner_id_users_id_fk",
+ "tableFrom": "workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "workspaces_organization_id_organizations_id_fk": {
+ "name": "workspaces_organization_id_organizations_id_fk",
+ "tableFrom": "workspaces",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.worktrees": {
+ "name": "worktrees",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "worktree_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "worktree_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "review_head_sha": {
+ "name": "review_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_base_sha": {
+ "name": "review_base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_diff_digest": {
+ "name": "review_diff_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_by": {
+ "name": "reviewed_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_at": {
+ "name": "reviewed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "merged_at": {
+ "name": "merged_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "discarded_at": {
+ "name": "discarded_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "worktrees_workspace_name_idx": {
+ "name": "worktrees_workspace_name_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "worktrees_workspace_status_idx": {
+ "name": "worktrees_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "worktrees_workspace_id_workspaces_id_fk": {
+ "name": "worktrees_workspace_id_workspaces_id_fk",
+ "tableFrom": "worktrees",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "worktrees_reviewed_by_users_id_fk": {
+ "name": "worktrees_reviewed_by_users_id_fk",
+ "tableFrom": "worktrees",
+ "tableTo": "users",
+ "columnsFrom": [
+ "reviewed_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.yjs_snapshots": {
+ "name": "yjs_snapshots",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "update_base64": {
+ "name": "update_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state_vector_base64": {
+ "name": "state_vector_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_contents": {
+ "name": "filesystem_contents",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_conflict": {
+ "name": "has_conflict",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "conflict_filesystem_revision": {
+ "name": "conflict_filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_detected_at": {
+ "name": "conflict_detected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolved_at": {
+ "name": "conflict_resolved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolved_by": {
+ "name": "conflict_resolved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolution": {
+ "name": "conflict_resolution",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "yjs_snapshots_worktree_path_idx": {
+ "name": "yjs_snapshots_worktree_path_idx",
+ "columns": [
+ {
+ "expression": "worktree_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "yjs_snapshots_worktree_id_worktrees_id_fk": {
+ "name": "yjs_snapshots_worktree_id_worktrees_id_fk",
+ "tableFrom": "yjs_snapshots",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "yjs_snapshots_conflict_resolved_by_users_id_fk": {
+ "name": "yjs_snapshots_conflict_resolved_by_users_id_fk",
+ "tableFrom": "yjs_snapshots",
+ "tableTo": "users",
+ "columnsFrom": [
+ "conflict_resolved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {
+ "public.access_request_status": {
+ "name": "access_request_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "invited",
+ "declined"
+ ]
+ },
+ "public.agent_brief_status": {
+ "name": "agent_brief_status",
+ "schema": "public",
+ "values": [
+ "planning",
+ "active",
+ "blocked",
+ "paused",
+ "done"
+ ]
+ },
+ "public.agent_session_import_status": {
+ "name": "agent_session_import_status",
+ "schema": "public",
+ "values": [
+ "storing",
+ "stored",
+ "restoring",
+ "ready",
+ "launching",
+ "active",
+ "failed",
+ "deleted"
+ ]
+ },
+ "public.agent_session_kind": {
+ "name": "agent_session_kind",
+ "schema": "public",
+ "values": [
+ "managed",
+ "cli"
+ ]
+ },
+ "public.agent_session_status": {
+ "name": "agent_session_status",
+ "schema": "public",
+ "values": [
+ "idle",
+ "running",
+ "waiting",
+ "completed",
+ "interrupted",
+ "failed"
+ ]
+ },
+ "public.agent_turn_status": {
+ "name": "agent_turn_status",
+ "schema": "public",
+ "values": [
+ "queued",
+ "running",
+ "completed",
+ "interrupted",
+ "failed"
+ ]
+ },
+ "public.brain_entry_kind": {
+ "name": "brain_entry_kind",
+ "schema": "public",
+ "values": [
+ "decision",
+ "attempt",
+ "dead_end",
+ "finding",
+ "convention",
+ "handoff"
+ ]
+ },
+ "public.brain_overlap_kind": {
+ "name": "brain_overlap_kind",
+ "schema": "public",
+ "values": [
+ "duplicate_intent",
+ "file_overlap",
+ "claim_contest"
+ ]
+ },
+ "public.brain_overlap_status": {
+ "name": "brain_overlap_status",
+ "schema": "public",
+ "values": [
+ "open",
+ "acknowledged",
+ "resolved"
+ ]
+ },
+ "public.channel_message_author_kind": {
+ "name": "channel_message_author_kind",
+ "schema": "public",
+ "values": [
+ "member",
+ "agent",
+ "system"
+ ]
+ },
+ "public.claim_status": {
+ "name": "claim_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "released",
+ "expired",
+ "contested"
+ ]
+ },
+ "public.claude_connection_session_status": {
+ "name": "claude_connection_session_status",
+ "schema": "public",
+ "values": [
+ "starting",
+ "awaiting_code",
+ "exchanging",
+ "connected",
+ "failed"
+ ]
+ },
+ "public.cli_client_type": {
+ "name": "cli_client_type",
+ "schema": "public",
+ "values": [
+ "cli",
+ "mobile"
+ ]
+ },
+ "public.cli_device_authorization_status": {
+ "name": "cli_device_authorization_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "approved",
+ "denied"
+ ]
+ },
+ "public.credential_connected_via": {
+ "name": "credential_connected_via",
+ "schema": "public",
+ "values": [
+ "browser",
+ "cli",
+ "api_key"
+ ]
+ },
+ "public.credential_provider": {
+ "name": "credential_provider",
+ "schema": "public",
+ "values": [
+ "anthropic",
+ "openai",
+ "bedrock",
+ "azure_foundry",
+ "cursor",
+ "custom"
+ ]
+ },
+ "public.credential_scope_type": {
+ "name": "credential_scope_type",
+ "schema": "public",
+ "values": [
+ "USER",
+ "WORKSPACE",
+ "ORGANIZATION"
+ ]
+ },
+ "public.credential_type": {
+ "name": "credential_type",
+ "schema": "public",
+ "values": [
+ "API_KEY",
+ "OAUTH_TOKEN",
+ "AWS_BEDROCK_ROLE",
+ "AZURE_ENDPOINT",
+ "HOSTED_CODEX_SUBSCRIPTION"
+ ]
+ },
+ "public.feature_key": {
+ "name": "feature_key",
+ "schema": "public",
+ "values": [
+ "hosted_codex_subscription"
+ ]
+ },
+ "public.feature_override_audit_action": {
+ "name": "feature_override_audit_action",
+ "schema": "public",
+ "values": [
+ "created",
+ "updated",
+ "deleted"
+ ]
+ },
+ "public.gen2_superset_run_status": {
+ "name": "gen2_superset_run_status",
+ "schema": "public",
+ "values": [
+ "creating",
+ "running",
+ "stopping",
+ "finished",
+ "failed",
+ "recovery_required"
+ ]
+ },
+ "public.gen2_workspace_role": {
+ "name": "gen2_workspace_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "editor",
+ "viewer"
+ ]
+ },
+ "public.gen2_workspace_status": {
+ "name": "gen2_workspace_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "provisioning",
+ "ready",
+ "failed",
+ "stopped",
+ "deleting"
+ ]
+ },
+ "public.member_role": {
+ "name": "member_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "member"
+ ]
+ },
+ "public.coordination_message_status": {
+ "name": "coordination_message_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "delivered",
+ "resolved"
+ ]
+ },
+ "public.mobile_platform": {
+ "name": "mobile_platform",
+ "schema": "public",
+ "values": [
+ "ios",
+ "android"
+ ]
+ },
+ "public.organization_role": {
+ "name": "organization_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "admin",
+ "billing_admin",
+ "member"
+ ]
+ },
+ "public.organization_subscription_status": {
+ "name": "organization_subscription_status",
+ "schema": "public",
+ "values": [
+ "trialing",
+ "active",
+ "past_due",
+ "canceled"
+ ]
+ },
+ "public.provider_credential_status": {
+ "name": "provider_credential_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "reauthorization_required",
+ "revoked",
+ "failed"
+ ]
+ },
+ "public.publication_status": {
+ "name": "publication_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "published",
+ "failed"
+ ]
+ },
+ "public.repository_restore_status": {
+ "name": "repository_restore_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "matched",
+ "restored",
+ "conflicted",
+ "unavailable",
+ "transcript_only"
+ ]
+ },
+ "public.runtime_host_lifecycle": {
+ "name": "runtime_host_lifecycle",
+ "schema": "public",
+ "values": [
+ "provisioning",
+ "ready",
+ "draining",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.sandbox_runtime_status": {
+ "name": "sandbox_runtime_status",
+ "schema": "public",
+ "values": [
+ "provisioning",
+ "ready",
+ "hibernated",
+ "stopping",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.session_continuation_mode": {
+ "name": "session_continuation_mode",
+ "schema": "public",
+ "values": [
+ "managed",
+ "native_resume"
+ ]
+ },
+ "public.subscription_plan": {
+ "name": "subscription_plan",
+ "schema": "public",
+ "values": [
+ "free",
+ "pro",
+ "team",
+ "enterprise"
+ ]
+ },
+ "public.workspace_access_role": {
+ "name": "workspace_access_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "co_steer",
+ "reviewer",
+ "viewer"
+ ]
+ },
+ "public.workspace_runtime_assignment_state": {
+ "name": "workspace_runtime_assignment_state",
+ "schema": "public",
+ "values": [
+ "assigned",
+ "starting",
+ "ready",
+ "draining",
+ "lost"
+ ]
+ },
+ "public.workspace_status": {
+ "name": "workspace_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "provisioning",
+ "ready",
+ "hibernated",
+ "stopping",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.worktree_kind": {
+ "name": "worktree_kind",
+ "schema": "public",
+ "values": [
+ "integration",
+ "agent"
+ ]
+ },
+ "public.worktree_status": {
+ "name": "worktree_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "frozen",
+ "merged",
+ "discarded"
+ ]
+ }
+ },
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/0060_snapshot.json b/packages/db/drizzle/meta/0060_snapshot.json
new file mode 100644
index 000000000..66169008b
--- /dev/null
+++ b/packages/db/drizzle/meta/0060_snapshot.json
@@ -0,0 +1,9886 @@
+{
+ "id": "3003777d-f0e0-4c4f-a4c7-cb3a82a6254b",
+ "prevId": "ac0f55f2-bd22-46dc-b6b5-aa0d3aea10ec",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.access_requests": {
+ "name": "access_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_login": {
+ "name": "github_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "persona": {
+ "name": "persona",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building": {
+ "name": "building",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "referrer": {
+ "name": "referrer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ip_hash": {
+ "name": "ip_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "access_request_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "invited_at": {
+ "name": "invited_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invite_token_hash": {
+ "name": "invite_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invite_token_expires_at": {
+ "name": "invite_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "access_requests_email_idx": {
+ "name": "access_requests_email_idx",
+ "columns": [
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_status_created_idx": {
+ "name": "access_requests_status_created_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_ip_created_idx": {
+ "name": "access_requests_ip_created_idx",
+ "columns": [
+ {
+ "expression": "ip_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_invite_token_hash_idx": {
+ "name": "access_requests_invite_token_hash_idx",
+ "columns": [
+ {
+ "expression": "invite_token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_briefs": {
+ "name": "agent_briefs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "approach_summary": {
+ "name": "approach_summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "plan_steps": {
+ "name": "plan_steps",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "current_step": {
+ "name": "current_step",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "files_likely_to_touch": {
+ "name": "files_likely_to_touch",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "keywords": {
+ "name": "keywords",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_brief_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'planning'"
+ },
+ "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_briefs_session_idx": {
+ "name": "agent_briefs_session_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_briefs_workspace_status_idx": {
+ "name": "agent_briefs_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_briefs_workspace_id_workspaces_id_fk": {
+ "name": "agent_briefs_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_briefs",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_briefs_session_id_agent_sessions_id_fk": {
+ "name": "agent_briefs_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_briefs",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_events": {
+ "name": "agent_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "turn_id": {
+ "name": "turn_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_events_idempotency_idx": {
+ "name": "agent_events_idempotency_idx",
+ "columns": [
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_events_session_created_idx": {
+ "name": "agent_events_session_created_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_events_workspace_id_workspaces_id_fk": {
+ "name": "agent_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_events_session_id_agent_sessions_id_fk": {
+ "name": "agent_events_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_events_turn_id_agent_turns_id_fk": {
+ "name": "agent_events_turn_id_agent_turns_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "agent_turns",
+ "columnsFrom": [
+ "turn_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_session_import_artifacts": {
+ "name": "agent_session_import_artifacts",
+ "schema": "",
+ "columns": {
+ "import_id": {
+ "name": "import_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "media_type": {
+ "name": "media_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plaintext_sha256": {
+ "name": "plaintext_sha256",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plaintext_bytes": {
+ "name": "plaintext_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_payload": {
+ "name": "encrypted_payload",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_session_import_artifacts_created_idx": {
+ "name": "agent_session_import_artifacts_created_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_session_import_artifacts_import_id_agent_session_imports_id_fk": {
+ "name": "agent_session_import_artifacts_import_id_agent_session_imports_id_fk",
+ "tableFrom": "agent_session_import_artifacts",
+ "tableTo": "agent_session_imports",
+ "columnsFrom": [
+ "import_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_session_imports": {
+ "name": "agent_session_imports",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "imported_by": {
+ "name": "imported_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_import_id": {
+ "name": "parent_import_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_session_id": {
+ "name": "agent_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_provider": {
+ "name": "source_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_session_id": {
+ "name": "external_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capsule_schema_version": {
+ "name": "capsule_schema_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capsule_sha256": {
+ "name": "capsule_sha256",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_session_import_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'storing'"
+ },
+ "repository_status": {
+ "name": "repository_status",
+ "type": "repository_restore_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "continuation_mode": {
+ "name": "continuation_mode",
+ "type": "session_continuation_mode",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_session_imports_idempotency_idx": {
+ "name": "agent_session_imports_idempotency_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_workspace_status_idx": {
+ "name": "agent_session_imports_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_importer_idx": {
+ "name": "agent_session_imports_importer_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_source_idx": {
+ "name": "agent_session_imports_source_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_parent_idx": {
+ "name": "agent_session_imports_parent_idx",
+ "columns": [
+ {
+ "expression": "parent_import_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_active_writer_idx": {
+ "name": "agent_session_imports_active_writer_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_session_imports\".\"continuation_mode\" = 'native_resume' and \"agent_session_imports\".\"status\" in ('launching', 'active') and \"agent_session_imports\".\"deleted_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_session_imports_organization_id_organizations_id_fk": {
+ "name": "agent_session_imports_organization_id_organizations_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_workspace_id_workspaces_id_fk": {
+ "name": "agent_session_imports_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_imported_by_users_id_fk": {
+ "name": "agent_session_imports_imported_by_users_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "users",
+ "columnsFrom": [
+ "imported_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_parent_import_id_agent_session_imports_id_fk": {
+ "name": "agent_session_imports_parent_import_id_agent_session_imports_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "agent_session_imports",
+ "columnsFrom": [
+ "parent_import_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_worktree_id_worktrees_id_fk": {
+ "name": "agent_session_imports_worktree_id_worktrees_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_agent_session_id_agent_sessions_id_fk": {
+ "name": "agent_session_imports_agent_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "agent_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_sessions": {
+ "name": "agent_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_number": {
+ "name": "issue_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'Agent'"
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'gpt-5'"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'openai'"
+ },
+ "kind": {
+ "name": "kind",
+ "type": "agent_session_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'managed'"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_session_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'idle'"
+ },
+ "workflow_run_id": {
+ "name": "workflow_run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "interrupted_at": {
+ "name": "interrupted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_sessions_workspace_issue_idx": {
+ "name": "agent_sessions_workspace_issue_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "issue_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_sessions_workspace_status_idx": {
+ "name": "agent_sessions_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_sessions_workspace_id_workspaces_id_fk": {
+ "name": "agent_sessions_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_sessions_worktree_id_worktrees_id_fk": {
+ "name": "agent_sessions_worktree_id_worktrees_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_sessions_created_by_users_id_fk": {
+ "name": "agent_sessions_created_by_users_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_turns": {
+ "name": "agent_turns",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attachments": {
+ "name": "attachments",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_turn_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "workflow_run_id": {
+ "name": "workflow_run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_id": {
+ "name": "response_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output": {
+ "name": "output",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finished_at": {
+ "name": "finished_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_turns_session_created_idx": {
+ "name": "agent_turns_session_created_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_turns_session_id_agent_sessions_id_fk": {
+ "name": "agent_turns_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_turns",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_turns_author_id_users_id_fk": {
+ "name": "agent_turns_author_id_users_id_fk",
+ "tableFrom": "agent_turns",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.brain_entries": {
+ "name": "brain_entries",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "brain_entry_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "paths": {
+ "name": "paths",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "keywords": {
+ "name": "keywords",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "supersedes_id": {
+ "name": "supersedes_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "brain_entries_workspace_created_idx": {
+ "name": "brain_entries_workspace_created_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "brain_entries_workspace_kind_idx": {
+ "name": "brain_entries_workspace_kind_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "brain_entries_workspace_id_workspaces_id_fk": {
+ "name": "brain_entries_workspace_id_workspaces_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_entries_session_id_agent_sessions_id_fk": {
+ "name": "brain_entries_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "brain_entries_author_id_users_id_fk": {
+ "name": "brain_entries_author_id_users_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.brain_overlaps": {
+ "name": "brain_overlaps",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "left_session_id": {
+ "name": "left_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "right_session_id": {
+ "name": "right_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "brain_overlap_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "score": {
+ "name": "score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "evidence": {
+ "name": "evidence",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "rationale": {
+ "name": "rationale",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "status": {
+ "name": "status",
+ "type": "brain_overlap_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "detected_at": {
+ "name": "detected_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": {
+ "brain_overlaps_pair_kind_idx": {
+ "name": "brain_overlaps_pair_kind_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "left_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "right_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "brain_overlaps_workspace_status_idx": {
+ "name": "brain_overlaps_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "brain_overlaps_workspace_id_workspaces_id_fk": {
+ "name": "brain_overlaps_workspace_id_workspaces_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_overlaps_left_session_id_agent_sessions_id_fk": {
+ "name": "brain_overlaps_left_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "left_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_overlaps_right_session_id_agent_sessions_id_fk": {
+ "name": "brain_overlaps_right_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "right_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.claude_connection_sessions": {
+ "name": "claude_connection_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'USER'"
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "claude_connection_session_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'starting'"
+ },
+ "runner_id": {
+ "name": "runner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "authorize_url": {
+ "name": "authorize_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_reason": {
+ "name": "failure_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "claude_connection_sessions_user_idx": {
+ "name": "claude_connection_sessions_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "claude_connection_sessions_expiry_idx": {
+ "name": "claude_connection_sessions_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "claude_connection_sessions_user_id_users_id_fk": {
+ "name": "claude_connection_sessions_user_id_users_id_fk",
+ "tableFrom": "claude_connection_sessions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cli_access_tokens": {
+ "name": "cli_access_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'CoDev CLI'"
+ },
+ "client_type": {
+ "name": "client_type",
+ "type": "cli_client_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'cli'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_used_at": {
+ "name": "last_used_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "cli_access_tokens_token_hash_idx": {
+ "name": "cli_access_tokens_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_access_tokens_user_idx": {
+ "name": "cli_access_tokens_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_access_tokens_expiry_idx": {
+ "name": "cli_access_tokens_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cli_access_tokens_user_id_users_id_fk": {
+ "name": "cli_access_tokens_user_id_users_id_fk",
+ "tableFrom": "cli_access_tokens",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cli_device_authorizations": {
+ "name": "cli_device_authorizations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "device_code_hash": {
+ "name": "device_code_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_code": {
+ "name": "user_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "cli_device_authorization_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "client_type": {
+ "name": "client_type",
+ "type": "cli_client_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'cli'"
+ },
+ "approved_by": {
+ "name": "approved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "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": {
+ "cli_device_authorizations_device_code_idx": {
+ "name": "cli_device_authorizations_device_code_idx",
+ "columns": [
+ {
+ "expression": "device_code_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_device_authorizations_user_code_idx": {
+ "name": "cli_device_authorizations_user_code_idx",
+ "columns": [
+ {
+ "expression": "user_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_device_authorizations_expiry_idx": {
+ "name": "cli_device_authorizations_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cli_device_authorizations_approved_by_users_id_fk": {
+ "name": "cli_device_authorizations_approved_by_users_id_fk",
+ "tableFrom": "cli_device_authorizations",
+ "tableTo": "users",
+ "columnsFrom": [
+ "approved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.collaboration_conflict_resolutions": {
+ "name": "collaboration_conflict_resolutions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resolved_by": {
+ "name": "resolved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "strategy": {
+ "name": "strategy",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "snapshot_revision": {
+ "name": "snapshot_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result_revision": {
+ "name": "result_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "collaboration_conflict_resolutions_document_idx": {
+ "name": "collaboration_conflict_resolutions_document_idx",
+ "columns": [
+ {
+ "expression": "worktree_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "collaboration_conflict_resolutions_worktree_id_worktrees_id_fk": {
+ "name": "collaboration_conflict_resolutions_worktree_id_worktrees_id_fk",
+ "tableFrom": "collaboration_conflict_resolutions",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "collaboration_conflict_resolutions_resolved_by_users_id_fk": {
+ "name": "collaboration_conflict_resolutions_resolved_by_users_id_fk",
+ "tableFrom": "collaboration_conflict_resolutions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "resolved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversation_artifacts": {
+ "name": "conversation_artifacts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_url": {
+ "name": "source_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "downloadable": {
+ "name": "downloadable",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversation_artifacts_conversation_idx": {
+ "name": "conversation_artifacts_conversation_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "conversation_artifacts_message_idx": {
+ "name": "conversation_artifacts_message_idx",
+ "columns": [
+ {
+ "expression": "message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversation_artifacts_conversation_id_conversations_id_fk": {
+ "name": "conversation_artifacts_conversation_id_conversations_id_fk",
+ "tableFrom": "conversation_artifacts",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "conversation_artifacts_message_id_conversation_messages_id_fk": {
+ "name": "conversation_artifacts_message_id_conversation_messages_id_fk",
+ "tableFrom": "conversation_artifacts",
+ "tableTo": "conversation_messages",
+ "columnsFrom": [
+ "message_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversation_messages": {
+ "name": "conversation_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence": {
+ "name": "sequence",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_user_id": {
+ "name": "author_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_name": {
+ "name": "author_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_content_type": {
+ "name": "source_content_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_created_at": {
+ "name": "source_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversation_messages_sequence_idx": {
+ "name": "conversation_messages_sequence_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sequence",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversation_messages_conversation_id_conversations_id_fk": {
+ "name": "conversation_messages_conversation_id_conversations_id_fk",
+ "tableFrom": "conversation_messages",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "conversation_messages_author_user_id_users_id_fk": {
+ "name": "conversation_messages_author_user_id_users_id_fk",
+ "tableFrom": "conversation_messages",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversations": {
+ "name": "conversations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'imported'"
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_provider": {
+ "name": "source_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_external_id": {
+ "name": "source_external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_url": {
+ "name": "source_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_model": {
+ "name": "source_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_updated_at": {
+ "name": "source_updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "warnings": {
+ "name": "warnings",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversations_owner_updated_idx": {
+ "name": "conversations_owner_updated_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "conversations_owner_source_idx": {
+ "name": "conversations_owner_source_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_external_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversations_owner_id_users_id_fk": {
+ "name": "conversations_owner_id_users_id_fk",
+ "tableFrom": "conversations",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.coordination_messages": {
+ "name": "coordination_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "from_session_id": {
+ "name": "from_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "to_session_id": {
+ "name": "to_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "correlation_id": {
+ "name": "correlation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "response_to_id": {
+ "name": "response_to_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "coordination_message_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "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": {
+ "coordination_messages_target_status_idx": {
+ "name": "coordination_messages_target_status_idx",
+ "columns": [
+ {
+ "expression": "to_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "coordination_messages_workspace_id_workspaces_id_fk": {
+ "name": "coordination_messages_workspace_id_workspaces_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coordination_messages_from_session_id_agent_sessions_id_fk": {
+ "name": "coordination_messages_from_session_id_agent_sessions_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "from_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coordination_messages_to_session_id_agent_sessions_id_fk": {
+ "name": "coordination_messages_to_session_id_agent_sessions_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "to_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.design_partner_feedback": {
+ "name": "design_partner_feedback",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "category": {
+ "name": "category",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rating": {
+ "name": "rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "page": {
+ "name": "page",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "release": {
+ "name": "release",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'new'"
+ },
+ "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": {
+ "design_partner_feedback_user_created_idx": {
+ "name": "design_partner_feedback_user_created_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "design_partner_feedback_status_created_idx": {
+ "name": "design_partner_feedback_status_created_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "design_partner_feedback_user_id_users_id_fk": {
+ "name": "design_partner_feedback_user_id_users_id_fk",
+ "tableFrom": "design_partner_feedback",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "design_partner_feedback_workspace_id_workspaces_id_fk": {
+ "name": "design_partner_feedback_workspace_id_workspaces_id_fk",
+ "tableFrom": "design_partner_feedback",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.feature_override_audit_events": {
+ "name": "feature_override_audit_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_user_id": {
+ "name": "target_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_user_id": {
+ "name": "actor_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "feature_override_audit_action",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "previous_enabled": {
+ "name": "previous_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "previous_expires_at": {
+ "name": "previous_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "feature_override_audit_org_created_idx": {
+ "name": "feature_override_audit_org_created_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "feature_override_audit_user_created_idx": {
+ "name": "feature_override_audit_user_created_idx",
+ "columns": [
+ {
+ "expression": "target_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "feature_override_audit_events_organization_id_organizations_id_fk": {
+ "name": "feature_override_audit_events_organization_id_organizations_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "feature_override_audit_events_target_user_id_users_id_fk": {
+ "name": "feature_override_audit_events_target_user_id_users_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "target_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "feature_override_audit_events_actor_user_id_users_id_fk": {
+ "name": "feature_override_audit_events_actor_user_id_users_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_agent_turns": {
+ "name": "gen2_agent_turns",
+ "schema": "",
+ "columns": {
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "output": {
+ "name": "output",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "pending_base64": {
+ "name": "pending_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "exited": {
+ "name": "exited",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "reply_message_id": {
+ "name": "reply_message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_agent_turns_chat_idx": {
+ "name": "gen2_agent_turns_chat_idx",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_agent_turns_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_agent_turns_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_chat_id_gen2_chats_id_fk": {
+ "name": "gen2_agent_turns_chat_id_gen2_chats_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_chats",
+ "columnsFrom": [
+ "chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_user_id_users_id_fk": {
+ "name": "gen2_agent_turns_user_id_users_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_reply_message_id_gen2_chat_messages_id_fk": {
+ "name": "gen2_agent_turns_reply_message_id_gen2_chat_messages_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_chat_messages",
+ "columnsFrom": [
+ "reply_message_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_chat_messages": {
+ "name": "gen2_chat_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "items": {
+ "name": "items",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_chat_messages_chat_idx": {
+ "name": "gen2_chat_messages_chat_idx",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_chat_messages_chat_id_gen2_chats_id_fk": {
+ "name": "gen2_chat_messages_chat_id_gen2_chats_id_fk",
+ "tableFrom": "gen2_chat_messages",
+ "tableTo": "gen2_chats",
+ "columnsFrom": [
+ "chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_chats": {
+ "name": "gen2_chats",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_chats_workspace_updated_idx": {
+ "name": "gen2_chats_workspace_updated_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_chats_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_chats_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_chats",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_chats_created_by_user_id_users_id_fk": {
+ "name": "gen2_chats_created_by_user_id_users_id_fk",
+ "tableFrom": "gen2_chats",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_superset_run_events": {
+ "name": "gen2_superset_run_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "run_id": {
+ "name": "run_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result": {
+ "name": "result",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_superset_run_events_run_created_idx": {
+ "name": "gen2_superset_run_events_run_created_idx",
+ "columns": [
+ {
+ "expression": "run_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_superset_run_events_run_id_gen2_superset_runs_id_fk": {
+ "name": "gen2_superset_run_events_run_id_gen2_superset_runs_id_fk",
+ "tableFrom": "gen2_superset_run_events",
+ "tableTo": "gen2_superset_runs",
+ "columnsFrom": [
+ "run_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_run_events_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_superset_run_events_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_superset_run_events",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_run_events_actor_id_users_id_fk": {
+ "name": "gen2_superset_run_events_actor_id_users_id_fk",
+ "tableFrom": "gen2_superset_run_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_superset_runs": {
+ "name": "gen2_superset_runs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "host_workspace_id": {
+ "name": "host_workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "host_terminal_id": {
+ "name": "host_terminal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "host_agent_session_id": {
+ "name": "host_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "credential_provider",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_revision": {
+ "name": "credential_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "gen2_superset_run_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'creating'"
+ },
+ "lease_claimed": {
+ "name": "lease_claimed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "exit_reason": {
+ "name": "exit_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "recovery_count": {
+ "name": "recovery_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_superset_runs_workspace_idempotency_idx": {
+ "name": "gen2_superset_runs_workspace_idempotency_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "gen2_superset_runs_workspace_status_idx": {
+ "name": "gen2_superset_runs_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "gen2_superset_runs_chat_idx": {
+ "name": "gen2_superset_runs_chat_idx",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_superset_runs_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_superset_runs_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_runs_chat_id_gen2_chats_id_fk": {
+ "name": "gen2_superset_runs_chat_id_gen2_chats_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "gen2_chats",
+ "columnsFrom": [
+ "chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_runs_created_by_users_id_fk": {
+ "name": "gen2_superset_runs_created_by_users_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_runs_connection_id_provider_credentials_id_fk": {
+ "name": "gen2_superset_runs_connection_id_provider_credentials_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "provider_credentials",
+ "columnsFrom": [
+ "connection_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_workspace_members": {
+ "name": "gen2_workspace_members",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "gen2_workspace_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'editor'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_workspace_members_user_idx": {
+ "name": "gen2_workspace_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_workspace_members_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_workspace_members_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_workspace_members",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_workspace_members_user_id_users_id_fk": {
+ "name": "gen2_workspace_members_user_id_users_id_fk",
+ "tableFrom": "gen2_workspace_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "gen2_workspace_members_workspace_id_user_id_pk": {
+ "name": "gen2_workspace_members_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_workspaces": {
+ "name": "gen2_workspaces",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "gen2_workspace_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "sandbox_id": {
+ "name": "sandbox_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_token_hash": {
+ "name": "active_invite_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_created_by_user_id": {
+ "name": "active_invite_created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_role": {
+ "name": "active_invite_role",
+ "type": "gen2_workspace_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_created_at": {
+ "name": "active_invite_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_expires_at": {
+ "name": "active_invite_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_installation_id": {
+ "name": "github_installation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository": {
+ "name": "repository",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_private": {
+ "name": "repository_private",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "default_branch": {
+ "name": "default_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_workspaces_owner_idx": {
+ "name": "gen2_workspaces_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "gen2_workspaces_active_invite_token_hash_idx": {
+ "name": "gen2_workspaces_active_invite_token_hash_idx",
+ "columns": [
+ {
+ "expression": "active_invite_token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_workspaces_owner_id_users_id_fk": {
+ "name": "gen2_workspaces_owner_id_users_id_fk",
+ "tableFrom": "gen2_workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "gen2_workspaces_active_invite_created_by_user_id_users_id_fk": {
+ "name": "gen2_workspaces_active_invite_created_by_user_id_users_id_fk",
+ "tableFrom": "gen2_workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "active_invite_created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_yjs_documents": {
+ "name": "gen2_yjs_documents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'main'"
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "update_base64": {
+ "name": "update_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state_vector_base64": {
+ "name": "state_vector_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_contents": {
+ "name": "filesystem_contents",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_conflict": {
+ "name": "has_conflict",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "conflict_filesystem_revision": {
+ "name": "conflict_filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_detected_at": {
+ "name": "conflict_detected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_yjs_documents_workspace_worktree_path_idx": {
+ "name": "gen2_yjs_documents_workspace_worktree_path_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "worktree_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_yjs_documents_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_yjs_documents_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_yjs_documents",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_connections": {
+ "name": "github_connections",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "encrypted_access_token": {
+ "name": "encrypted_access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_refresh_token": {
+ "name": "encrypted_refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'bearer'"
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "github_connections_access_expiry_idx": {
+ "name": "github_connections_access_expiry_idx",
+ "columns": [
+ {
+ "expression": "access_token_expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "github_connections_user_id_users_id_fk": {
+ "name": "github_connections_user_id_users_id_fk",
+ "tableFrom": "github_connections",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_issue_assignments": {
+ "name": "github_issue_assignments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_number": {
+ "name": "issue_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_issue_id": {
+ "name": "github_issue_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "github_issue_assignments_repository_issue_idx": {
+ "name": "github_issue_assignments_repository_issue_idx",
+ "columns": [
+ {
+ "expression": "github_repository_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "issue_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "github_issue_assignments_session_idx": {
+ "name": "github_issue_assignments_session_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "github_issue_assignments_workspace_idx": {
+ "name": "github_issue_assignments_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "github_issue_assignments_workspace_id_workspaces_id_fk": {
+ "name": "github_issue_assignments_workspace_id_workspaces_id_fk",
+ "tableFrom": "github_issue_assignments",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "github_issue_assignments_session_id_agent_sessions_id_fk": {
+ "name": "github_issue_assignments_session_id_agent_sessions_id_fk",
+ "tableFrom": "github_issue_assignments",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.mobile_push_tokens": {
+ "name": "mobile_push_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expo_push_token": {
+ "name": "expo_push_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "mobile_platform",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "device_id": {
+ "name": "device_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_seen_at": {
+ "name": "last_seen_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": {
+ "mobile_push_tokens_token_idx": {
+ "name": "mobile_push_tokens_token_idx",
+ "columns": [
+ {
+ "expression": "expo_push_token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "mobile_push_tokens_user_idx": {
+ "name": "mobile_push_tokens_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mobile_push_tokens_user_id_users_id_fk": {
+ "name": "mobile_push_tokens_user_id_users_id_fk",
+ "tableFrom": "mobile_push_tokens",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_feature_overrides": {
+ "name": "organization_feature_overrides",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "organization_feature_overrides_organization_id_organizations_id_fk": {
+ "name": "organization_feature_overrides_organization_id_organizations_id_fk",
+ "tableFrom": "organization_feature_overrides",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_feature_overrides_created_by_users_id_fk": {
+ "name": "organization_feature_overrides_created_by_users_id_fk",
+ "tableFrom": "organization_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "organization_feature_overrides_organization_id_feature_pk": {
+ "name": "organization_feature_overrides_organization_id_feature_pk",
+ "columns": [
+ "organization_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_members": {
+ "name": "organization_members",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "organization_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organization_members_user_idx": {
+ "name": "organization_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organization_members_organization_id_organizations_id_fk": {
+ "name": "organization_members_organization_id_organizations_id_fk",
+ "tableFrom": "organization_members",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_members_user_id_users_id_fk": {
+ "name": "organization_members_user_id_users_id_fk",
+ "tableFrom": "organization_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "organization_members_organization_id_user_id_pk": {
+ "name": "organization_members_organization_id_user_id_pk",
+ "columns": [
+ "organization_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_subscriptions": {
+ "name": "organization_subscriptions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "organization_subscription_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_customer_id": {
+ "name": "provider_customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_subscription_id": {
+ "name": "provider_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_period_end": {
+ "name": "current_period_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "canceled_at": {
+ "name": "canceled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organization_subscriptions_org_idx": {
+ "name": "organization_subscriptions_org_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "organization_subscriptions_provider_idx": {
+ "name": "organization_subscriptions_provider_idx",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organization_subscriptions_organization_id_organizations_id_fk": {
+ "name": "organization_subscriptions_organization_id_organizations_id_fk",
+ "tableFrom": "organization_subscriptions",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_subscriptions_plan_id_plans_id_fk": {
+ "name": "organization_subscriptions_plan_id_plans_id_fk",
+ "tableFrom": "organization_subscriptions",
+ "tableTo": "plans",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organizations": {
+ "name": "organizations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organizations_slug_idx": {
+ "name": "organizations_slug_idx",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.page_views": {
+ "name": "page_views",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "referrer": {
+ "name": "referrer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ip_hash": {
+ "name": "ip_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "page_views_created_idx": {
+ "name": "page_views_created_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "page_views_user_created_idx": {
+ "name": "page_views_user_created_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "page_views_path_created_idx": {
+ "name": "page_views_path_created_idx",
+ "columns": [
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "page_views_user_id_users_id_fk": {
+ "name": "page_views_user_id_users_id_fk",
+ "tableFrom": "page_views",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.path_claims": {
+ "name": "path_claims",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path_glob": {
+ "name": "path_glob",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "intent": {
+ "name": "intent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "claim_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "path_claims_session_status_idx": {
+ "name": "path_claims_session_status_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "path_claims_expiry_idx": {
+ "name": "path_claims_expiry_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "path_claims_session_id_agent_sessions_id_fk": {
+ "name": "path_claims_session_id_agent_sessions_id_fk",
+ "tableFrom": "path_claims",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan_entitlements": {
+ "name": "plan_entitlements",
+ "schema": "",
+ "columns": {
+ "plan_id": {
+ "name": "plan_id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "plan_entitlements_plan_id_plans_id_fk": {
+ "name": "plan_entitlements_plan_id_plans_id_fk",
+ "tableFrom": "plan_entitlements",
+ "tableTo": "plans",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "plan_entitlements_plan_id_feature_pk": {
+ "name": "plan_entitlements_plan_id_feature_pk",
+ "columns": [
+ "plan_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plans": {
+ "name": "plans",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.provider_credential_events": {
+ "name": "provider_credential_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "credential_provider",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result": {
+ "name": "result",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "provider_credential_events_credential_created_idx": {
+ "name": "provider_credential_events_credential_created_idx",
+ "columns": [
+ {
+ "expression": "credential_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credential_events_actor_created_idx": {
+ "name": "provider_credential_events_actor_created_idx",
+ "columns": [
+ {
+ "expression": "actor_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "provider_credential_events_actor_id_users_id_fk": {
+ "name": "provider_credential_events_actor_id_users_id_fk",
+ "tableFrom": "provider_credential_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "provider_credential_events_workspace_id_workspaces_id_fk": {
+ "name": "provider_credential_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "provider_credential_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.provider_credential_runs": {
+ "name": "provider_credential_runs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surface": {
+ "name": "surface",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ref": {
+ "name": "ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heartbeat_at": {
+ "name": "heartbeat_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": {
+ "provider_credential_runs_credential_idx": {
+ "name": "provider_credential_runs_credential_idx",
+ "columns": [
+ {
+ "expression": "credential_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credential_runs_ref_idx": {
+ "name": "provider_credential_runs_ref_idx",
+ "columns": [
+ {
+ "expression": "ref",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "provider_credential_runs_user_id_users_id_fk": {
+ "name": "provider_credential_runs_user_id_users_id_fk",
+ "tableFrom": "provider_credential_runs",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.provider_credentials": {
+ "name": "provider_credentials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "credential_provider",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_type": {
+ "name": "credential_type",
+ "type": "credential_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "priority_order": {
+ "name": "priority_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "encrypted_api_key": {
+ "name": "encrypted_api_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_access_token": {
+ "name": "encrypted_access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_refresh_token": {
+ "name": "encrypted_refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "endpoint_url": {
+ "name": "endpoint_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "aws_role_arn": {
+ "name": "aws_role_arn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_connected": {
+ "name": "is_connected",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_four": {
+ "name": "last_four",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "provider_credential_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "provider_subject_hash": {
+ "name": "provider_subject_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_material": {
+ "name": "encrypted_material",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_refreshed_at": {
+ "name": "last_refreshed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sharing_enabled": {
+ "name": "sharing_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "connected_via": {
+ "name": "connected_via",
+ "type": "credential_connected_via",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "allow_in_shared_workspaces": {
+ "name": "allow_in_shared_workspaces",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "provider_credentials_scope_provider_type_idx": {
+ "name": "provider_credentials_scope_provider_type_idx",
+ "columns": [
+ {
+ "expression": "scope_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scope_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "credential_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credentials_scope_provider_priority_idx": {
+ "name": "provider_credentials_scope_provider_priority_idx",
+ "columns": [
+ {
+ "expression": "scope_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scope_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "priority_order",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credentials_status_idx": {
+ "name": "provider_credentials_status_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "provider_credentials_created_by_users_id_fk": {
+ "name": "provider_credentials_created_by_users_id_fk",
+ "tableFrom": "provider_credentials",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.published_branches": {
+ "name": "published_branches",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "published_by": {
+ "name": "published_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "branch_name": {
+ "name": "branch_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "publication_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "source_head_sha": {
+ "name": "source_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "commit_sha": {
+ "name": "commit_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_id": {
+ "name": "repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "remote_ref": {
+ "name": "remote_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "html_url": {
+ "name": "html_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pull_request_number": {
+ "name": "pull_request_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pull_request_url": {
+ "name": "pull_request_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "request_id": {
+ "name": "request_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "published_at": {
+ "name": "published_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "published_branches_workspace_name_idx": {
+ "name": "published_branches_workspace_name_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "branch_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "published_branches_workspace_request_idx": {
+ "name": "published_branches_workspace_request_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "request_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "published_branches_workspace_status_idx": {
+ "name": "published_branches_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "published_branches_workspace_id_workspaces_id_fk": {
+ "name": "published_branches_workspace_id_workspaces_id_fk",
+ "tableFrom": "published_branches",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "published_branches_published_by_users_id_fk": {
+ "name": "published_branches_published_by_users_id_fk",
+ "tableFrom": "published_branches",
+ "tableTo": "users",
+ "columnsFrom": [
+ "published_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.runtime_hosts": {
+ "name": "runtime_hosts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "runtime_address": {
+ "name": "runtime_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifecycle_state": {
+ "name": "lifecycle_state",
+ "type": "runtime_host_lifecycle",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'provisioning'"
+ },
+ "max_workspace_slots": {
+ "name": "max_workspace_slots",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 4
+ },
+ "free_workspace_slots": {
+ "name": "free_workspace_slots",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 4
+ },
+ "image_version": {
+ "name": "image_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_heartbeat_at": {
+ "name": "last_heartbeat_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "draining_at": {
+ "name": "draining_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "runtime_hosts_provider_id_idx": {
+ "name": "runtime_hosts_provider_id_idx",
+ "columns": [
+ {
+ "expression": "provider_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "runtime_hosts_runtime_address_idx": {
+ "name": "runtime_hosts_runtime_address_idx",
+ "columns": [
+ {
+ "expression": "runtime_address",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "runtime_hosts_capacity_idx": {
+ "name": "runtime_hosts_capacity_idx",
+ "columns": [
+ {
+ "expression": "lifecycle_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "free_workspace_slots",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sandbox_runtime_intervals": {
+ "name": "sandbox_runtime_intervals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ended_at": {
+ "name": "ended_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "sandbox_runtime_intervals_user_open_idx": {
+ "name": "sandbox_runtime_intervals_user_open_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "ended_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "sandbox_runtime_intervals_workspace_open_idx": {
+ "name": "sandbox_runtime_intervals_workspace_open_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "ended_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "sandbox_runtime_intervals_user_id_users_id_fk": {
+ "name": "sandbox_runtime_intervals_user_id_users_id_fk",
+ "tableFrom": "sandbox_runtime_intervals",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sandbox_runtime_intervals_workspace_id_workspaces_id_fk": {
+ "name": "sandbox_runtime_intervals_workspace_id_workspaces_id_fk",
+ "tableFrom": "sandbox_runtime_intervals",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chat_invites": {
+ "name": "shared_chat_invites",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "shared_chat_id": {
+ "name": "shared_chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_token": {
+ "name": "encrypted_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_by": {
+ "name": "accepted_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chat_invites_token_hash_idx": {
+ "name": "shared_chat_invites_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "shared_chat_invites_room_idx": {
+ "name": "shared_chat_invites_room_idx",
+ "columns": [
+ {
+ "expression": "shared_chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chat_invites_shared_chat_id_shared_chats_id_fk": {
+ "name": "shared_chat_invites_shared_chat_id_shared_chats_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "shared_chats",
+ "columnsFrom": [
+ "shared_chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_invites_created_by_users_id_fk": {
+ "name": "shared_chat_invites_created_by_users_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_invites_accepted_by_users_id_fk": {
+ "name": "shared_chat_invites_accepted_by_users_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "accepted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chat_members": {
+ "name": "shared_chat_members",
+ "schema": "",
+ "columns": {
+ "shared_chat_id": {
+ "name": "shared_chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chat_members_user_idx": {
+ "name": "shared_chat_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chat_members_shared_chat_id_shared_chats_id_fk": {
+ "name": "shared_chat_members_shared_chat_id_shared_chats_id_fk",
+ "tableFrom": "shared_chat_members",
+ "tableTo": "shared_chats",
+ "columnsFrom": [
+ "shared_chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_members_user_id_users_id_fk": {
+ "name": "shared_chat_members_user_id_users_id_fk",
+ "tableFrom": "shared_chat_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "shared_chat_members_shared_chat_id_user_id_pk": {
+ "name": "shared_chat_members_shared_chat_id_user_id_pk",
+ "columns": [
+ "shared_chat_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chats": {
+ "name": "shared_chats",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chats_conversation_idx": {
+ "name": "shared_chats_conversation_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "shared_chats_owner_updated_idx": {
+ "name": "shared_chats_owner_updated_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chats_conversation_id_conversations_id_fk": {
+ "name": "shared_chats_conversation_id_conversations_id_fk",
+ "tableFrom": "shared_chats",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chats_owner_id_users_id_fk": {
+ "name": "shared_chats_owner_id_users_id_fk",
+ "tableFrom": "shared_chats",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_compute_usage": {
+ "name": "user_compute_usage",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "minutes_used": {
+ "name": "minutes_used",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_compute_usage_user_id_users_id_fk": {
+ "name": "user_compute_usage_user_id_users_id_fk",
+ "tableFrom": "user_compute_usage",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_environment_variables": {
+ "name": "user_environment_variables",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_value": {
+ "name": "encrypted_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_four": {
+ "name": "last_four",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_environment_variables_user_name_idx": {
+ "name": "user_environment_variables_user_name_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_environment_variables_user_updated_idx": {
+ "name": "user_environment_variables_user_updated_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_environment_variables_user_id_users_id_fk": {
+ "name": "user_environment_variables_user_id_users_id_fk",
+ "tableFrom": "user_environment_variables",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_feature_overrides": {
+ "name": "user_feature_overrides",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_feature_overrides_user_idx": {
+ "name": "user_feature_overrides_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_feature_overrides_organization_id_organizations_id_fk": {
+ "name": "user_feature_overrides_organization_id_organizations_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_feature_overrides_user_id_users_id_fk": {
+ "name": "user_feature_overrides_user_id_users_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_feature_overrides_created_by_users_id_fk": {
+ "name": "user_feature_overrides_created_by_users_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "user_feature_overrides_organization_id_user_id_feature_pk": {
+ "name": "user_feature_overrides_organization_id_user_id_feature_pk",
+ "columns": [
+ "organization_id",
+ "user_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.users": {
+ "name": "users",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "github_user_id": {
+ "name": "github_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "google_user_id": {
+ "name": "google_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "clerk_user_id": {
+ "name": "clerk_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "login": {
+ "name": "login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password_hash": {
+ "name": "password_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avatar_url": {
+ "name": "avatar_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_admin": {
+ "name": "is_admin",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "users_github_user_id_idx": {
+ "name": "users_github_user_id_idx",
+ "columns": [
+ {
+ "expression": "github_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_google_user_id_idx": {
+ "name": "users_google_user_id_idx",
+ "columns": [
+ {
+ "expression": "google_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_clerk_user_id_idx": {
+ "name": "users_clerk_user_id_idx",
+ "columns": [
+ {
+ "expression": "clerk_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_login_idx": {
+ "name": "users_login_idx",
+ "columns": [
+ {
+ "expression": "login",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channel_messages": {
+ "name": "workspace_channel_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_kind": {
+ "name": "author_kind",
+ "type": "channel_message_author_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_label": {
+ "name": "author_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_session_id": {
+ "name": "agent_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mentions": {
+ "name": "mentions",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "mentions_agent": {
+ "name": "mentions_agent",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channel_messages_channel_idx": {
+ "name": "workspace_channel_messages_channel_idx",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_channel_messages_workspace_idx": {
+ "name": "workspace_channel_messages_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channel_messages_channel_id_workspace_channels_id_fk": {
+ "name": "workspace_channel_messages_channel_id_workspace_channels_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "workspace_channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_workspace_id_workspaces_id_fk": {
+ "name": "workspace_channel_messages_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_author_id_users_id_fk": {
+ "name": "workspace_channel_messages_author_id_users_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_agent_session_id_agent_sessions_id_fk": {
+ "name": "workspace_channel_messages_agent_session_id_agent_sessions_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "agent_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channel_reads": {
+ "name": "workspace_channel_reads",
+ "schema": "",
+ "columns": {
+ "channel_id": {
+ "name": "channel_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_read_at": {
+ "name": "last_read_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channel_reads_user_idx": {
+ "name": "workspace_channel_reads_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channel_reads_channel_id_workspace_channels_id_fk": {
+ "name": "workspace_channel_reads_channel_id_workspace_channels_id_fk",
+ "tableFrom": "workspace_channel_reads",
+ "tableTo": "workspace_channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_reads_user_id_users_id_fk": {
+ "name": "workspace_channel_reads_user_id_users_id_fk",
+ "tableFrom": "workspace_channel_reads",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_channel_reads_channel_id_user_id_pk": {
+ "name": "workspace_channel_reads_channel_id_user_id_pk",
+ "columns": [
+ "channel_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channels": {
+ "name": "workspace_channels",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "topic": {
+ "name": "topic",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_access": {
+ "name": "agent_access",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channels_workspace_slug_idx": {
+ "name": "workspace_channels_workspace_slug_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_channels_workspace_idx": {
+ "name": "workspace_channels_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "archived_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channels_workspace_id_workspaces_id_fk": {
+ "name": "workspace_channels_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_channels",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channels_created_by_users_id_fk": {
+ "name": "workspace_channels_created_by_users_id_fk",
+ "tableFrom": "workspace_channels",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_leases": {
+ "name": "workspace_chat_leases",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "holder_id": {
+ "name": "holder_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lease_token": {
+ "name": "lease_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_leases_expiry_idx": {
+ "name": "workspace_chat_leases_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_leases_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_leases_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_leases",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_leases_holder_id_users_id_fk": {
+ "name": "workspace_chat_leases_holder_id_users_id_fk",
+ "tableFrom": "workspace_chat_leases",
+ "tableTo": "users",
+ "columnsFrom": [
+ "holder_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_chat_leases_workspace_id_chat_id_pk": {
+ "name": "workspace_chat_leases_workspace_id_chat_id_pk",
+ "columns": [
+ "workspace_id",
+ "chat_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_participants": {
+ "name": "workspace_chat_participants",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_participants_expiry_idx": {
+ "name": "workspace_chat_participants_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_participants_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_participants_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_participants",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_participants_user_id_users_id_fk": {
+ "name": "workspace_chat_participants_user_id_users_id_fk",
+ "tableFrom": "workspace_chat_participants",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_chat_participants_workspace_id_chat_id_user_id_client_id_pk": {
+ "name": "workspace_chat_participants_workspace_id_chat_id_user_id_client_id_pk",
+ "columns": [
+ "workspace_id",
+ "chat_id",
+ "user_id",
+ "client_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_prompt_receipts": {
+ "name": "workspace_chat_prompt_receipts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_message_id": {
+ "name": "client_message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attachments": {
+ "name": "attachments",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "effort": {
+ "name": "effort",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_prompt_receipts_client_message_idx": {
+ "name": "workspace_chat_prompt_receipts_client_message_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "client_message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_chat_prompt_receipts_chat_created_idx": {
+ "name": "workspace_chat_prompt_receipts_chat_created_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_prompt_receipts_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_prompt_receipts_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_prompt_receipts",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_prompt_receipts_author_id_users_id_fk": {
+ "name": "workspace_chat_prompt_receipts_author_id_users_id_fk",
+ "tableFrom": "workspace_chat_prompt_receipts",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_events": {
+ "name": "workspace_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence": {
+ "name": "sequence",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_events_sequence_idx": {
+ "name": "workspace_events_sequence_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sequence",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_events_workspace_id_workspaces_id_fk": {
+ "name": "workspace_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_events_actor_id_users_id_fk": {
+ "name": "workspace_events_actor_id_users_id_fk",
+ "tableFrom": "workspace_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_invites": {
+ "name": "workspace_invites",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "invitee_email": {
+ "name": "invitee_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invitee_login": {
+ "name": "invitee_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_role": {
+ "name": "access_role",
+ "type": "workspace_access_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'viewer'"
+ },
+ "allow_link": {
+ "name": "allow_link",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_by": {
+ "name": "accepted_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_invites_token_hash_idx": {
+ "name": "workspace_invites_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_invites_workspace_idx": {
+ "name": "workspace_invites_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_invites_workspace_id_workspaces_id_fk": {
+ "name": "workspace_invites_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_invites_created_by_users_id_fk": {
+ "name": "workspace_invites_created_by_users_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_invites_accepted_by_users_id_fk": {
+ "name": "workspace_invites_accepted_by_users_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "accepted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_member_statuses": {
+ "name": "workspace_member_statuses",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emoji": {
+ "name": "emoji",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "headline": {
+ "name": "headline",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_member_statuses_workspace_idx": {
+ "name": "workspace_member_statuses_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_member_statuses_workspace_id_workspaces_id_fk": {
+ "name": "workspace_member_statuses_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_member_statuses",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_member_statuses_user_id_users_id_fk": {
+ "name": "workspace_member_statuses_user_id_users_id_fk",
+ "tableFrom": "workspace_member_statuses",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_member_statuses_workspace_id_user_id_pk": {
+ "name": "workspace_member_statuses_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_members": {
+ "name": "workspace_members",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "member_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "access_role": {
+ "name": "access_role",
+ "type": "workspace_access_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'viewer'"
+ },
+ "can_terminal": {
+ "name": "can_terminal",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "can_merge": {
+ "name": "can_merge",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_members_user_idx": {
+ "name": "workspace_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_members_workspace_id_workspaces_id_fk": {
+ "name": "workspace_members_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_members",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_members_user_id_users_id_fk": {
+ "name": "workspace_members_user_id_users_id_fk",
+ "tableFrom": "workspace_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_members_workspace_id_user_id_pk": {
+ "name": "workspace_members_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_runtime_assignments": {
+ "name": "workspace_runtime_assignments",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "host_id": {
+ "name": "host_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "generation": {
+ "name": "generation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "fencing_token": {
+ "name": "fencing_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "disk_id": {
+ "name": "disk_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "disk_lun": {
+ "name": "disk_lun",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "runtime_state": {
+ "name": "runtime_state",
+ "type": "workspace_runtime_assignment_state",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'assigned'"
+ },
+ "last_used_at": {
+ "name": "last_used_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": {
+ "workspace_runtime_assignments_host_state_idx": {
+ "name": "workspace_runtime_assignments_host_state_idx",
+ "columns": [
+ {
+ "expression": "host_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "runtime_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_runtime_assignments_state_updated_idx": {
+ "name": "workspace_runtime_assignments_state_updated_idx",
+ "columns": [
+ {
+ "expression": "runtime_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_runtime_assignments_workspace_id_workspaces_id_fk": {
+ "name": "workspace_runtime_assignments_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_runtime_assignments",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_runtime_assignments_host_id_runtime_hosts_id_fk": {
+ "name": "workspace_runtime_assignments_host_id_runtime_hosts_id_fk",
+ "tableFrom": "workspace_runtime_assignments",
+ "tableTo": "runtime_hosts",
+ "columnsFrom": [
+ "host_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_runtimes": {
+ "name": "workspace_runtimes",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "sandbox_id": {
+ "name": "sandbox_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "backend": {
+ "name": "backend",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'firecracker'"
+ },
+ "status": {
+ "name": "status",
+ "type": "sandbox_runtime_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'provisioning'"
+ },
+ "provisioned_head_sha": {
+ "name": "provisioned_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "snapshot_ref": {
+ "name": "snapshot_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_heartbeat_at": {
+ "name": "last_heartbeat_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hibernated_at": {
+ "name": "hibernated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provisioned_at": {
+ "name": "provisioned_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stopped_at": {
+ "name": "stopped_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_runtimes_status_updated_idx": {
+ "name": "workspace_runtimes_status_updated_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_runtimes_workspace_id_workspaces_id_fk": {
+ "name": "workspace_runtimes_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_runtimes",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "workspace_runtimes_sandbox_id_unique": {
+ "name": "workspace_runtimes_sandbox_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "sandbox_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_snapshots": {
+ "name": "workspace_snapshots",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "snapshot": {
+ "name": "snapshot",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_bytes": {
+ "name": "total_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_snapshots_updated_idx": {
+ "name": "workspace_snapshots_updated_idx",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_snapshots_workspace_id_workspaces_id_fk": {
+ "name": "workspace_snapshots_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_snapshots",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_state_documents": {
+ "name": "workspace_state_documents",
+ "schema": "",
+ "columns": {
+ "document_name": {
+ "name": "document_name",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state": {
+ "name": "state",
+ "type": "bytea",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_state_documents_workspace_idx": {
+ "name": "workspace_state_documents_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_state_documents_workspace_id_workspaces_id_fk": {
+ "name": "workspace_state_documents_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_state_documents",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspaces": {
+ "name": "workspaces",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_installation_id": {
+ "name": "github_installation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository": {
+ "name": "repository",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repository_visibility": {
+ "name": "repository_visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "default_branch": {
+ "name": "default_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "workspace_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "last_activity_at": {
+ "name": "last_activity_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "hibernate_at": {
+ "name": "hibernate_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspaces_owner_idx": {
+ "name": "workspaces_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_organization_idx": {
+ "name": "workspaces_organization_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_repository_idx": {
+ "name": "workspaces_repository_idx",
+ "columns": [
+ {
+ "expression": "github_repository_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_status_expiry_idx": {
+ "name": "workspaces_status_expiry_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_deleted_idx": {
+ "name": "workspaces_deleted_idx",
+ "columns": [
+ {
+ "expression": "deleted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspaces_owner_id_users_id_fk": {
+ "name": "workspaces_owner_id_users_id_fk",
+ "tableFrom": "workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "workspaces_organization_id_organizations_id_fk": {
+ "name": "workspaces_organization_id_organizations_id_fk",
+ "tableFrom": "workspaces",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.worktrees": {
+ "name": "worktrees",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "worktree_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "worktree_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "review_head_sha": {
+ "name": "review_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_base_sha": {
+ "name": "review_base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_diff_digest": {
+ "name": "review_diff_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_by": {
+ "name": "reviewed_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_at": {
+ "name": "reviewed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "merged_at": {
+ "name": "merged_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "discarded_at": {
+ "name": "discarded_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "worktrees_workspace_name_idx": {
+ "name": "worktrees_workspace_name_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "worktrees_workspace_status_idx": {
+ "name": "worktrees_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "worktrees_workspace_id_workspaces_id_fk": {
+ "name": "worktrees_workspace_id_workspaces_id_fk",
+ "tableFrom": "worktrees",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "worktrees_reviewed_by_users_id_fk": {
+ "name": "worktrees_reviewed_by_users_id_fk",
+ "tableFrom": "worktrees",
+ "tableTo": "users",
+ "columnsFrom": [
+ "reviewed_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.yjs_snapshots": {
+ "name": "yjs_snapshots",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "update_base64": {
+ "name": "update_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state_vector_base64": {
+ "name": "state_vector_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_contents": {
+ "name": "filesystem_contents",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_conflict": {
+ "name": "has_conflict",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "conflict_filesystem_revision": {
+ "name": "conflict_filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_detected_at": {
+ "name": "conflict_detected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolved_at": {
+ "name": "conflict_resolved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolved_by": {
+ "name": "conflict_resolved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolution": {
+ "name": "conflict_resolution",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "yjs_snapshots_worktree_path_idx": {
+ "name": "yjs_snapshots_worktree_path_idx",
+ "columns": [
+ {
+ "expression": "worktree_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "yjs_snapshots_worktree_id_worktrees_id_fk": {
+ "name": "yjs_snapshots_worktree_id_worktrees_id_fk",
+ "tableFrom": "yjs_snapshots",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "yjs_snapshots_conflict_resolved_by_users_id_fk": {
+ "name": "yjs_snapshots_conflict_resolved_by_users_id_fk",
+ "tableFrom": "yjs_snapshots",
+ "tableTo": "users",
+ "columnsFrom": [
+ "conflict_resolved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {
+ "public.access_request_status": {
+ "name": "access_request_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "invited",
+ "declined"
+ ]
+ },
+ "public.agent_brief_status": {
+ "name": "agent_brief_status",
+ "schema": "public",
+ "values": [
+ "planning",
+ "active",
+ "blocked",
+ "paused",
+ "done"
+ ]
+ },
+ "public.agent_session_import_status": {
+ "name": "agent_session_import_status",
+ "schema": "public",
+ "values": [
+ "storing",
+ "stored",
+ "restoring",
+ "ready",
+ "launching",
+ "active",
+ "failed",
+ "deleted"
+ ]
+ },
+ "public.agent_session_kind": {
+ "name": "agent_session_kind",
+ "schema": "public",
+ "values": [
+ "managed",
+ "cli"
+ ]
+ },
+ "public.agent_session_status": {
+ "name": "agent_session_status",
+ "schema": "public",
+ "values": [
+ "idle",
+ "running",
+ "waiting",
+ "completed",
+ "interrupted",
+ "failed"
+ ]
+ },
+ "public.agent_turn_status": {
+ "name": "agent_turn_status",
+ "schema": "public",
+ "values": [
+ "queued",
+ "running",
+ "completed",
+ "interrupted",
+ "failed"
+ ]
+ },
+ "public.brain_entry_kind": {
+ "name": "brain_entry_kind",
+ "schema": "public",
+ "values": [
+ "decision",
+ "attempt",
+ "dead_end",
+ "finding",
+ "convention",
+ "handoff"
+ ]
+ },
+ "public.brain_overlap_kind": {
+ "name": "brain_overlap_kind",
+ "schema": "public",
+ "values": [
+ "duplicate_intent",
+ "file_overlap",
+ "claim_contest"
+ ]
+ },
+ "public.brain_overlap_status": {
+ "name": "brain_overlap_status",
+ "schema": "public",
+ "values": [
+ "open",
+ "acknowledged",
+ "resolved"
+ ]
+ },
+ "public.channel_message_author_kind": {
+ "name": "channel_message_author_kind",
+ "schema": "public",
+ "values": [
+ "member",
+ "agent",
+ "system"
+ ]
+ },
+ "public.claim_status": {
+ "name": "claim_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "released",
+ "expired",
+ "contested"
+ ]
+ },
+ "public.claude_connection_session_status": {
+ "name": "claude_connection_session_status",
+ "schema": "public",
+ "values": [
+ "starting",
+ "awaiting_code",
+ "exchanging",
+ "connected",
+ "failed"
+ ]
+ },
+ "public.cli_client_type": {
+ "name": "cli_client_type",
+ "schema": "public",
+ "values": [
+ "cli",
+ "mobile"
+ ]
+ },
+ "public.cli_device_authorization_status": {
+ "name": "cli_device_authorization_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "approved",
+ "denied"
+ ]
+ },
+ "public.credential_connected_via": {
+ "name": "credential_connected_via",
+ "schema": "public",
+ "values": [
+ "browser",
+ "cli",
+ "api_key"
+ ]
+ },
+ "public.credential_provider": {
+ "name": "credential_provider",
+ "schema": "public",
+ "values": [
+ "anthropic",
+ "openai",
+ "bedrock",
+ "azure_foundry",
+ "cursor",
+ "custom"
+ ]
+ },
+ "public.credential_scope_type": {
+ "name": "credential_scope_type",
+ "schema": "public",
+ "values": [
+ "USER",
+ "WORKSPACE",
+ "ORGANIZATION"
+ ]
+ },
+ "public.credential_type": {
+ "name": "credential_type",
+ "schema": "public",
+ "values": [
+ "API_KEY",
+ "OAUTH_TOKEN",
+ "AWS_BEDROCK_ROLE",
+ "AZURE_ENDPOINT",
+ "HOSTED_CODEX_SUBSCRIPTION"
+ ]
+ },
+ "public.feature_key": {
+ "name": "feature_key",
+ "schema": "public",
+ "values": [
+ "hosted_codex_subscription"
+ ]
+ },
+ "public.feature_override_audit_action": {
+ "name": "feature_override_audit_action",
+ "schema": "public",
+ "values": [
+ "created",
+ "updated",
+ "deleted"
+ ]
+ },
+ "public.gen2_superset_run_status": {
+ "name": "gen2_superset_run_status",
+ "schema": "public",
+ "values": [
+ "creating",
+ "running",
+ "stopping",
+ "finished",
+ "failed",
+ "recovery_required"
+ ]
+ },
+ "public.gen2_workspace_role": {
+ "name": "gen2_workspace_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "editor",
+ "viewer"
+ ]
+ },
+ "public.gen2_workspace_status": {
+ "name": "gen2_workspace_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "provisioning",
+ "ready",
+ "failed",
+ "stopped",
+ "deleting"
+ ]
+ },
+ "public.member_role": {
+ "name": "member_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "member"
+ ]
+ },
+ "public.coordination_message_status": {
+ "name": "coordination_message_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "delivered",
+ "resolved"
+ ]
+ },
+ "public.mobile_platform": {
+ "name": "mobile_platform",
+ "schema": "public",
+ "values": [
+ "ios",
+ "android"
+ ]
+ },
+ "public.organization_role": {
+ "name": "organization_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "admin",
+ "billing_admin",
+ "member"
+ ]
+ },
+ "public.organization_subscription_status": {
+ "name": "organization_subscription_status",
+ "schema": "public",
+ "values": [
+ "trialing",
+ "active",
+ "past_due",
+ "canceled"
+ ]
+ },
+ "public.provider_credential_status": {
+ "name": "provider_credential_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "reauthorization_required",
+ "revoked",
+ "failed"
+ ]
+ },
+ "public.publication_status": {
+ "name": "publication_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "published",
+ "failed"
+ ]
+ },
+ "public.repository_restore_status": {
+ "name": "repository_restore_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "matched",
+ "restored",
+ "conflicted",
+ "unavailable",
+ "transcript_only"
+ ]
+ },
+ "public.runtime_host_lifecycle": {
+ "name": "runtime_host_lifecycle",
+ "schema": "public",
+ "values": [
+ "provisioning",
+ "ready",
+ "draining",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.sandbox_runtime_status": {
+ "name": "sandbox_runtime_status",
+ "schema": "public",
+ "values": [
+ "provisioning",
+ "ready",
+ "hibernated",
+ "stopping",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.session_continuation_mode": {
+ "name": "session_continuation_mode",
+ "schema": "public",
+ "values": [
+ "managed",
+ "native_resume"
+ ]
+ },
+ "public.subscription_plan": {
+ "name": "subscription_plan",
+ "schema": "public",
+ "values": [
+ "free",
+ "pro",
+ "team",
+ "enterprise"
+ ]
+ },
+ "public.workspace_access_role": {
+ "name": "workspace_access_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "co_steer",
+ "reviewer",
+ "viewer"
+ ]
+ },
+ "public.workspace_runtime_assignment_state": {
+ "name": "workspace_runtime_assignment_state",
+ "schema": "public",
+ "values": [
+ "assigned",
+ "starting",
+ "ready",
+ "draining",
+ "lost"
+ ]
+ },
+ "public.workspace_status": {
+ "name": "workspace_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "provisioning",
+ "ready",
+ "hibernated",
+ "stopping",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.worktree_kind": {
+ "name": "worktree_kind",
+ "schema": "public",
+ "values": [
+ "integration",
+ "agent"
+ ]
+ },
+ "public.worktree_status": {
+ "name": "worktree_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "frozen",
+ "merged",
+ "discarded"
+ ]
+ }
+ },
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/0061_snapshot.json b/packages/db/drizzle/meta/0061_snapshot.json
new file mode 100644
index 000000000..95557b1ad
--- /dev/null
+++ b/packages/db/drizzle/meta/0061_snapshot.json
@@ -0,0 +1,9885 @@
+{
+ "id": "1e2733a9-6e54-4bb8-a8a3-9ed72c565fbb",
+ "prevId": "3003777d-f0e0-4c4f-a4c7-cb3a82a6254b",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.access_requests": {
+ "name": "access_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_login": {
+ "name": "github_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "persona": {
+ "name": "persona",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building": {
+ "name": "building",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "referrer": {
+ "name": "referrer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ip_hash": {
+ "name": "ip_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "access_request_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "invited_at": {
+ "name": "invited_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invite_token_hash": {
+ "name": "invite_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invite_token_expires_at": {
+ "name": "invite_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "access_requests_email_idx": {
+ "name": "access_requests_email_idx",
+ "columns": [
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_status_created_idx": {
+ "name": "access_requests_status_created_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_ip_created_idx": {
+ "name": "access_requests_ip_created_idx",
+ "columns": [
+ {
+ "expression": "ip_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_invite_token_hash_idx": {
+ "name": "access_requests_invite_token_hash_idx",
+ "columns": [
+ {
+ "expression": "invite_token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_briefs": {
+ "name": "agent_briefs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "approach_summary": {
+ "name": "approach_summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "plan_steps": {
+ "name": "plan_steps",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "current_step": {
+ "name": "current_step",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "files_likely_to_touch": {
+ "name": "files_likely_to_touch",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "keywords": {
+ "name": "keywords",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_brief_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'planning'"
+ },
+ "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_briefs_session_idx": {
+ "name": "agent_briefs_session_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_briefs_workspace_status_idx": {
+ "name": "agent_briefs_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_briefs_workspace_id_workspaces_id_fk": {
+ "name": "agent_briefs_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_briefs",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_briefs_session_id_agent_sessions_id_fk": {
+ "name": "agent_briefs_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_briefs",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_events": {
+ "name": "agent_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "turn_id": {
+ "name": "turn_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_events_idempotency_idx": {
+ "name": "agent_events_idempotency_idx",
+ "columns": [
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_events_session_created_idx": {
+ "name": "agent_events_session_created_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_events_workspace_id_workspaces_id_fk": {
+ "name": "agent_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_events_session_id_agent_sessions_id_fk": {
+ "name": "agent_events_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_events_turn_id_agent_turns_id_fk": {
+ "name": "agent_events_turn_id_agent_turns_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "agent_turns",
+ "columnsFrom": [
+ "turn_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_session_import_artifacts": {
+ "name": "agent_session_import_artifacts",
+ "schema": "",
+ "columns": {
+ "import_id": {
+ "name": "import_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "media_type": {
+ "name": "media_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plaintext_sha256": {
+ "name": "plaintext_sha256",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plaintext_bytes": {
+ "name": "plaintext_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_payload": {
+ "name": "encrypted_payload",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_session_import_artifacts_created_idx": {
+ "name": "agent_session_import_artifacts_created_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_session_import_artifacts_import_id_agent_session_imports_id_fk": {
+ "name": "agent_session_import_artifacts_import_id_agent_session_imports_id_fk",
+ "tableFrom": "agent_session_import_artifacts",
+ "tableTo": "agent_session_imports",
+ "columnsFrom": [
+ "import_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_session_imports": {
+ "name": "agent_session_imports",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "imported_by": {
+ "name": "imported_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_import_id": {
+ "name": "parent_import_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_session_id": {
+ "name": "agent_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_provider": {
+ "name": "source_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_session_id": {
+ "name": "external_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capsule_schema_version": {
+ "name": "capsule_schema_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capsule_sha256": {
+ "name": "capsule_sha256",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_session_import_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'storing'"
+ },
+ "repository_status": {
+ "name": "repository_status",
+ "type": "repository_restore_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "continuation_mode": {
+ "name": "continuation_mode",
+ "type": "session_continuation_mode",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_session_imports_idempotency_idx": {
+ "name": "agent_session_imports_idempotency_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_workspace_status_idx": {
+ "name": "agent_session_imports_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_importer_idx": {
+ "name": "agent_session_imports_importer_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_source_idx": {
+ "name": "agent_session_imports_source_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_parent_idx": {
+ "name": "agent_session_imports_parent_idx",
+ "columns": [
+ {
+ "expression": "parent_import_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_active_writer_idx": {
+ "name": "agent_session_imports_active_writer_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_session_imports\".\"continuation_mode\" = 'native_resume' and \"agent_session_imports\".\"status\" in ('launching', 'active') and \"agent_session_imports\".\"deleted_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_session_imports_organization_id_organizations_id_fk": {
+ "name": "agent_session_imports_organization_id_organizations_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_workspace_id_workspaces_id_fk": {
+ "name": "agent_session_imports_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_imported_by_users_id_fk": {
+ "name": "agent_session_imports_imported_by_users_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "users",
+ "columnsFrom": [
+ "imported_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_parent_import_id_agent_session_imports_id_fk": {
+ "name": "agent_session_imports_parent_import_id_agent_session_imports_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "agent_session_imports",
+ "columnsFrom": [
+ "parent_import_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_worktree_id_worktrees_id_fk": {
+ "name": "agent_session_imports_worktree_id_worktrees_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_agent_session_id_agent_sessions_id_fk": {
+ "name": "agent_session_imports_agent_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "agent_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_sessions": {
+ "name": "agent_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_number": {
+ "name": "issue_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'Agent'"
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'gpt-5'"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'openai'"
+ },
+ "kind": {
+ "name": "kind",
+ "type": "agent_session_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'managed'"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_session_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'idle'"
+ },
+ "workflow_run_id": {
+ "name": "workflow_run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "interrupted_at": {
+ "name": "interrupted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_sessions_workspace_issue_idx": {
+ "name": "agent_sessions_workspace_issue_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "issue_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_sessions_workspace_status_idx": {
+ "name": "agent_sessions_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_sessions_workspace_id_workspaces_id_fk": {
+ "name": "agent_sessions_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_sessions_worktree_id_worktrees_id_fk": {
+ "name": "agent_sessions_worktree_id_worktrees_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_sessions_created_by_users_id_fk": {
+ "name": "agent_sessions_created_by_users_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_turns": {
+ "name": "agent_turns",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attachments": {
+ "name": "attachments",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_turn_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "workflow_run_id": {
+ "name": "workflow_run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_id": {
+ "name": "response_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output": {
+ "name": "output",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finished_at": {
+ "name": "finished_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_turns_session_created_idx": {
+ "name": "agent_turns_session_created_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_turns_session_id_agent_sessions_id_fk": {
+ "name": "agent_turns_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_turns",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_turns_author_id_users_id_fk": {
+ "name": "agent_turns_author_id_users_id_fk",
+ "tableFrom": "agent_turns",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.brain_entries": {
+ "name": "brain_entries",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "brain_entry_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "paths": {
+ "name": "paths",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "keywords": {
+ "name": "keywords",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "supersedes_id": {
+ "name": "supersedes_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "brain_entries_workspace_created_idx": {
+ "name": "brain_entries_workspace_created_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "brain_entries_workspace_kind_idx": {
+ "name": "brain_entries_workspace_kind_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "brain_entries_workspace_id_workspaces_id_fk": {
+ "name": "brain_entries_workspace_id_workspaces_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_entries_session_id_agent_sessions_id_fk": {
+ "name": "brain_entries_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "brain_entries_author_id_users_id_fk": {
+ "name": "brain_entries_author_id_users_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.brain_overlaps": {
+ "name": "brain_overlaps",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "left_session_id": {
+ "name": "left_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "right_session_id": {
+ "name": "right_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "brain_overlap_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "score": {
+ "name": "score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "evidence": {
+ "name": "evidence",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "rationale": {
+ "name": "rationale",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "status": {
+ "name": "status",
+ "type": "brain_overlap_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "detected_at": {
+ "name": "detected_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": {
+ "brain_overlaps_pair_kind_idx": {
+ "name": "brain_overlaps_pair_kind_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "left_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "right_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "brain_overlaps_workspace_status_idx": {
+ "name": "brain_overlaps_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "brain_overlaps_workspace_id_workspaces_id_fk": {
+ "name": "brain_overlaps_workspace_id_workspaces_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_overlaps_left_session_id_agent_sessions_id_fk": {
+ "name": "brain_overlaps_left_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "left_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_overlaps_right_session_id_agent_sessions_id_fk": {
+ "name": "brain_overlaps_right_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "right_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.claude_connection_sessions": {
+ "name": "claude_connection_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'USER'"
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "claude_connection_session_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'starting'"
+ },
+ "runner_id": {
+ "name": "runner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "authorize_url": {
+ "name": "authorize_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_reason": {
+ "name": "failure_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "claude_connection_sessions_user_idx": {
+ "name": "claude_connection_sessions_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "claude_connection_sessions_expiry_idx": {
+ "name": "claude_connection_sessions_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "claude_connection_sessions_user_id_users_id_fk": {
+ "name": "claude_connection_sessions_user_id_users_id_fk",
+ "tableFrom": "claude_connection_sessions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cli_access_tokens": {
+ "name": "cli_access_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'CoDev CLI'"
+ },
+ "client_type": {
+ "name": "client_type",
+ "type": "cli_client_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'cli'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_used_at": {
+ "name": "last_used_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "cli_access_tokens_token_hash_idx": {
+ "name": "cli_access_tokens_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_access_tokens_user_idx": {
+ "name": "cli_access_tokens_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_access_tokens_expiry_idx": {
+ "name": "cli_access_tokens_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cli_access_tokens_user_id_users_id_fk": {
+ "name": "cli_access_tokens_user_id_users_id_fk",
+ "tableFrom": "cli_access_tokens",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cli_device_authorizations": {
+ "name": "cli_device_authorizations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "device_code_hash": {
+ "name": "device_code_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_code": {
+ "name": "user_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "cli_device_authorization_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "client_type": {
+ "name": "client_type",
+ "type": "cli_client_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'cli'"
+ },
+ "approved_by": {
+ "name": "approved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "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": {
+ "cli_device_authorizations_device_code_idx": {
+ "name": "cli_device_authorizations_device_code_idx",
+ "columns": [
+ {
+ "expression": "device_code_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_device_authorizations_user_code_idx": {
+ "name": "cli_device_authorizations_user_code_idx",
+ "columns": [
+ {
+ "expression": "user_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_device_authorizations_expiry_idx": {
+ "name": "cli_device_authorizations_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cli_device_authorizations_approved_by_users_id_fk": {
+ "name": "cli_device_authorizations_approved_by_users_id_fk",
+ "tableFrom": "cli_device_authorizations",
+ "tableTo": "users",
+ "columnsFrom": [
+ "approved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.collaboration_conflict_resolutions": {
+ "name": "collaboration_conflict_resolutions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resolved_by": {
+ "name": "resolved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "strategy": {
+ "name": "strategy",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "snapshot_revision": {
+ "name": "snapshot_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result_revision": {
+ "name": "result_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "collaboration_conflict_resolutions_document_idx": {
+ "name": "collaboration_conflict_resolutions_document_idx",
+ "columns": [
+ {
+ "expression": "worktree_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "collaboration_conflict_resolutions_worktree_id_worktrees_id_fk": {
+ "name": "collaboration_conflict_resolutions_worktree_id_worktrees_id_fk",
+ "tableFrom": "collaboration_conflict_resolutions",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "collaboration_conflict_resolutions_resolved_by_users_id_fk": {
+ "name": "collaboration_conflict_resolutions_resolved_by_users_id_fk",
+ "tableFrom": "collaboration_conflict_resolutions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "resolved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversation_artifacts": {
+ "name": "conversation_artifacts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_url": {
+ "name": "source_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "downloadable": {
+ "name": "downloadable",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversation_artifacts_conversation_idx": {
+ "name": "conversation_artifacts_conversation_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "conversation_artifacts_message_idx": {
+ "name": "conversation_artifacts_message_idx",
+ "columns": [
+ {
+ "expression": "message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversation_artifacts_conversation_id_conversations_id_fk": {
+ "name": "conversation_artifacts_conversation_id_conversations_id_fk",
+ "tableFrom": "conversation_artifacts",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "conversation_artifacts_message_id_conversation_messages_id_fk": {
+ "name": "conversation_artifacts_message_id_conversation_messages_id_fk",
+ "tableFrom": "conversation_artifacts",
+ "tableTo": "conversation_messages",
+ "columnsFrom": [
+ "message_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversation_messages": {
+ "name": "conversation_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence": {
+ "name": "sequence",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_user_id": {
+ "name": "author_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_name": {
+ "name": "author_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_content_type": {
+ "name": "source_content_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_created_at": {
+ "name": "source_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversation_messages_sequence_idx": {
+ "name": "conversation_messages_sequence_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sequence",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversation_messages_conversation_id_conversations_id_fk": {
+ "name": "conversation_messages_conversation_id_conversations_id_fk",
+ "tableFrom": "conversation_messages",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "conversation_messages_author_user_id_users_id_fk": {
+ "name": "conversation_messages_author_user_id_users_id_fk",
+ "tableFrom": "conversation_messages",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversations": {
+ "name": "conversations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'imported'"
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_provider": {
+ "name": "source_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_external_id": {
+ "name": "source_external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_url": {
+ "name": "source_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_model": {
+ "name": "source_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_updated_at": {
+ "name": "source_updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "warnings": {
+ "name": "warnings",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversations_owner_updated_idx": {
+ "name": "conversations_owner_updated_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "conversations_owner_source_idx": {
+ "name": "conversations_owner_source_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_external_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversations_owner_id_users_id_fk": {
+ "name": "conversations_owner_id_users_id_fk",
+ "tableFrom": "conversations",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.coordination_messages": {
+ "name": "coordination_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "from_session_id": {
+ "name": "from_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "to_session_id": {
+ "name": "to_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "correlation_id": {
+ "name": "correlation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "response_to_id": {
+ "name": "response_to_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "coordination_message_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "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": {
+ "coordination_messages_target_status_idx": {
+ "name": "coordination_messages_target_status_idx",
+ "columns": [
+ {
+ "expression": "to_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "coordination_messages_workspace_id_workspaces_id_fk": {
+ "name": "coordination_messages_workspace_id_workspaces_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coordination_messages_from_session_id_agent_sessions_id_fk": {
+ "name": "coordination_messages_from_session_id_agent_sessions_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "from_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coordination_messages_to_session_id_agent_sessions_id_fk": {
+ "name": "coordination_messages_to_session_id_agent_sessions_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "to_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.design_partner_feedback": {
+ "name": "design_partner_feedback",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "category": {
+ "name": "category",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rating": {
+ "name": "rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "page": {
+ "name": "page",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "release": {
+ "name": "release",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'new'"
+ },
+ "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": {
+ "design_partner_feedback_user_created_idx": {
+ "name": "design_partner_feedback_user_created_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "design_partner_feedback_status_created_idx": {
+ "name": "design_partner_feedback_status_created_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "design_partner_feedback_user_id_users_id_fk": {
+ "name": "design_partner_feedback_user_id_users_id_fk",
+ "tableFrom": "design_partner_feedback",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "design_partner_feedback_workspace_id_workspaces_id_fk": {
+ "name": "design_partner_feedback_workspace_id_workspaces_id_fk",
+ "tableFrom": "design_partner_feedback",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.feature_override_audit_events": {
+ "name": "feature_override_audit_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_user_id": {
+ "name": "target_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_user_id": {
+ "name": "actor_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "feature_override_audit_action",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "previous_enabled": {
+ "name": "previous_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "previous_expires_at": {
+ "name": "previous_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "feature_override_audit_org_created_idx": {
+ "name": "feature_override_audit_org_created_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "feature_override_audit_user_created_idx": {
+ "name": "feature_override_audit_user_created_idx",
+ "columns": [
+ {
+ "expression": "target_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "feature_override_audit_events_organization_id_organizations_id_fk": {
+ "name": "feature_override_audit_events_organization_id_organizations_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "feature_override_audit_events_target_user_id_users_id_fk": {
+ "name": "feature_override_audit_events_target_user_id_users_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "target_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "feature_override_audit_events_actor_user_id_users_id_fk": {
+ "name": "feature_override_audit_events_actor_user_id_users_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_agent_turns": {
+ "name": "gen2_agent_turns",
+ "schema": "",
+ "columns": {
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "output": {
+ "name": "output",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "pending_base64": {
+ "name": "pending_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "exited": {
+ "name": "exited",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "reply_message_id": {
+ "name": "reply_message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_agent_turns_chat_idx": {
+ "name": "gen2_agent_turns_chat_idx",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_agent_turns_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_agent_turns_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_chat_id_gen2_chats_id_fk": {
+ "name": "gen2_agent_turns_chat_id_gen2_chats_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_chats",
+ "columnsFrom": [
+ "chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_user_id_users_id_fk": {
+ "name": "gen2_agent_turns_user_id_users_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_reply_message_id_gen2_chat_messages_id_fk": {
+ "name": "gen2_agent_turns_reply_message_id_gen2_chat_messages_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_chat_messages",
+ "columnsFrom": [
+ "reply_message_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_chat_messages": {
+ "name": "gen2_chat_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "items": {
+ "name": "items",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_chat_messages_chat_idx": {
+ "name": "gen2_chat_messages_chat_idx",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_chat_messages_chat_id_gen2_chats_id_fk": {
+ "name": "gen2_chat_messages_chat_id_gen2_chats_id_fk",
+ "tableFrom": "gen2_chat_messages",
+ "tableTo": "gen2_chats",
+ "columnsFrom": [
+ "chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_chats": {
+ "name": "gen2_chats",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_chats_workspace_updated_idx": {
+ "name": "gen2_chats_workspace_updated_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_chats_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_chats_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_chats",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_chats_created_by_user_id_users_id_fk": {
+ "name": "gen2_chats_created_by_user_id_users_id_fk",
+ "tableFrom": "gen2_chats",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_superset_run_events": {
+ "name": "gen2_superset_run_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "run_id": {
+ "name": "run_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result": {
+ "name": "result",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_superset_run_events_run_created_idx": {
+ "name": "gen2_superset_run_events_run_created_idx",
+ "columns": [
+ {
+ "expression": "run_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_superset_run_events_run_id_gen2_superset_runs_id_fk": {
+ "name": "gen2_superset_run_events_run_id_gen2_superset_runs_id_fk",
+ "tableFrom": "gen2_superset_run_events",
+ "tableTo": "gen2_superset_runs",
+ "columnsFrom": [
+ "run_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_run_events_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_superset_run_events_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_superset_run_events",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_run_events_actor_id_users_id_fk": {
+ "name": "gen2_superset_run_events_actor_id_users_id_fk",
+ "tableFrom": "gen2_superset_run_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_superset_runs": {
+ "name": "gen2_superset_runs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "host_workspace_id": {
+ "name": "host_workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "host_terminal_id": {
+ "name": "host_terminal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "host_agent_session_id": {
+ "name": "host_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "credential_provider",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_revision": {
+ "name": "credential_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "gen2_superset_run_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'creating'"
+ },
+ "lease_claimed": {
+ "name": "lease_claimed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "exit_reason": {
+ "name": "exit_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "recovery_count": {
+ "name": "recovery_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_superset_runs_workspace_idempotency_idx": {
+ "name": "gen2_superset_runs_workspace_idempotency_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "gen2_superset_runs_workspace_status_idx": {
+ "name": "gen2_superset_runs_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "gen2_superset_runs_chat_idx": {
+ "name": "gen2_superset_runs_chat_idx",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_superset_runs_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_superset_runs_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_runs_chat_id_gen2_chats_id_fk": {
+ "name": "gen2_superset_runs_chat_id_gen2_chats_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "gen2_chats",
+ "columnsFrom": [
+ "chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_runs_created_by_users_id_fk": {
+ "name": "gen2_superset_runs_created_by_users_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_runs_connection_id_provider_credentials_id_fk": {
+ "name": "gen2_superset_runs_connection_id_provider_credentials_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "provider_credentials",
+ "columnsFrom": [
+ "connection_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_workspace_members": {
+ "name": "gen2_workspace_members",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "gen2_workspace_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'editor'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_workspace_members_user_idx": {
+ "name": "gen2_workspace_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_workspace_members_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_workspace_members_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_workspace_members",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_workspace_members_user_id_users_id_fk": {
+ "name": "gen2_workspace_members_user_id_users_id_fk",
+ "tableFrom": "gen2_workspace_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "gen2_workspace_members_workspace_id_user_id_pk": {
+ "name": "gen2_workspace_members_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_workspaces": {
+ "name": "gen2_workspaces",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "gen2_workspace_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "sandbox_id": {
+ "name": "sandbox_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_token_hash": {
+ "name": "active_invite_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_created_by_user_id": {
+ "name": "active_invite_created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_role": {
+ "name": "active_invite_role",
+ "type": "gen2_workspace_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_created_at": {
+ "name": "active_invite_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_expires_at": {
+ "name": "active_invite_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_installation_id": {
+ "name": "github_installation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository": {
+ "name": "repository",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_private": {
+ "name": "repository_private",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "default_branch": {
+ "name": "default_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_workspaces_owner_idx": {
+ "name": "gen2_workspaces_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "gen2_workspaces_active_invite_token_hash_idx": {
+ "name": "gen2_workspaces_active_invite_token_hash_idx",
+ "columns": [
+ {
+ "expression": "active_invite_token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_workspaces_owner_id_users_id_fk": {
+ "name": "gen2_workspaces_owner_id_users_id_fk",
+ "tableFrom": "gen2_workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "gen2_workspaces_active_invite_created_by_user_id_users_id_fk": {
+ "name": "gen2_workspaces_active_invite_created_by_user_id_users_id_fk",
+ "tableFrom": "gen2_workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "active_invite_created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_yjs_documents": {
+ "name": "gen2_yjs_documents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'main'"
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "update_base64": {
+ "name": "update_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state_vector_base64": {
+ "name": "state_vector_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_contents": {
+ "name": "filesystem_contents",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_conflict": {
+ "name": "has_conflict",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "conflict_filesystem_revision": {
+ "name": "conflict_filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_detected_at": {
+ "name": "conflict_detected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_yjs_documents_workspace_worktree_path_idx": {
+ "name": "gen2_yjs_documents_workspace_worktree_path_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "worktree_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_yjs_documents_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_yjs_documents_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_yjs_documents",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_connections": {
+ "name": "github_connections",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "encrypted_access_token": {
+ "name": "encrypted_access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_refresh_token": {
+ "name": "encrypted_refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'bearer'"
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "github_connections_access_expiry_idx": {
+ "name": "github_connections_access_expiry_idx",
+ "columns": [
+ {
+ "expression": "access_token_expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "github_connections_user_id_users_id_fk": {
+ "name": "github_connections_user_id_users_id_fk",
+ "tableFrom": "github_connections",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_issue_assignments": {
+ "name": "github_issue_assignments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_number": {
+ "name": "issue_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_issue_id": {
+ "name": "github_issue_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "github_issue_assignments_repository_issue_idx": {
+ "name": "github_issue_assignments_repository_issue_idx",
+ "columns": [
+ {
+ "expression": "github_repository_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "issue_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "github_issue_assignments_session_idx": {
+ "name": "github_issue_assignments_session_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "github_issue_assignments_workspace_idx": {
+ "name": "github_issue_assignments_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "github_issue_assignments_workspace_id_workspaces_id_fk": {
+ "name": "github_issue_assignments_workspace_id_workspaces_id_fk",
+ "tableFrom": "github_issue_assignments",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "github_issue_assignments_session_id_agent_sessions_id_fk": {
+ "name": "github_issue_assignments_session_id_agent_sessions_id_fk",
+ "tableFrom": "github_issue_assignments",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.mobile_push_tokens": {
+ "name": "mobile_push_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expo_push_token": {
+ "name": "expo_push_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "mobile_platform",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "device_id": {
+ "name": "device_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_seen_at": {
+ "name": "last_seen_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": {
+ "mobile_push_tokens_token_idx": {
+ "name": "mobile_push_tokens_token_idx",
+ "columns": [
+ {
+ "expression": "expo_push_token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "mobile_push_tokens_user_idx": {
+ "name": "mobile_push_tokens_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mobile_push_tokens_user_id_users_id_fk": {
+ "name": "mobile_push_tokens_user_id_users_id_fk",
+ "tableFrom": "mobile_push_tokens",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_feature_overrides": {
+ "name": "organization_feature_overrides",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "organization_feature_overrides_organization_id_organizations_id_fk": {
+ "name": "organization_feature_overrides_organization_id_organizations_id_fk",
+ "tableFrom": "organization_feature_overrides",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_feature_overrides_created_by_users_id_fk": {
+ "name": "organization_feature_overrides_created_by_users_id_fk",
+ "tableFrom": "organization_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "organization_feature_overrides_organization_id_feature_pk": {
+ "name": "organization_feature_overrides_organization_id_feature_pk",
+ "columns": [
+ "organization_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_members": {
+ "name": "organization_members",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "organization_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organization_members_user_idx": {
+ "name": "organization_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organization_members_organization_id_organizations_id_fk": {
+ "name": "organization_members_organization_id_organizations_id_fk",
+ "tableFrom": "organization_members",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_members_user_id_users_id_fk": {
+ "name": "organization_members_user_id_users_id_fk",
+ "tableFrom": "organization_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "organization_members_organization_id_user_id_pk": {
+ "name": "organization_members_organization_id_user_id_pk",
+ "columns": [
+ "organization_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_subscriptions": {
+ "name": "organization_subscriptions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "organization_subscription_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_customer_id": {
+ "name": "provider_customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_subscription_id": {
+ "name": "provider_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_period_end": {
+ "name": "current_period_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "canceled_at": {
+ "name": "canceled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organization_subscriptions_org_idx": {
+ "name": "organization_subscriptions_org_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "organization_subscriptions_provider_idx": {
+ "name": "organization_subscriptions_provider_idx",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organization_subscriptions_organization_id_organizations_id_fk": {
+ "name": "organization_subscriptions_organization_id_organizations_id_fk",
+ "tableFrom": "organization_subscriptions",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_subscriptions_plan_id_plans_id_fk": {
+ "name": "organization_subscriptions_plan_id_plans_id_fk",
+ "tableFrom": "organization_subscriptions",
+ "tableTo": "plans",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organizations": {
+ "name": "organizations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organizations_slug_idx": {
+ "name": "organizations_slug_idx",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.page_views": {
+ "name": "page_views",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "referrer": {
+ "name": "referrer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ip_hash": {
+ "name": "ip_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "page_views_created_idx": {
+ "name": "page_views_created_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "page_views_user_created_idx": {
+ "name": "page_views_user_created_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "page_views_path_created_idx": {
+ "name": "page_views_path_created_idx",
+ "columns": [
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "page_views_user_id_users_id_fk": {
+ "name": "page_views_user_id_users_id_fk",
+ "tableFrom": "page_views",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.path_claims": {
+ "name": "path_claims",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path_glob": {
+ "name": "path_glob",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "intent": {
+ "name": "intent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "claim_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "path_claims_session_status_idx": {
+ "name": "path_claims_session_status_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "path_claims_expiry_idx": {
+ "name": "path_claims_expiry_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "path_claims_session_id_agent_sessions_id_fk": {
+ "name": "path_claims_session_id_agent_sessions_id_fk",
+ "tableFrom": "path_claims",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan_entitlements": {
+ "name": "plan_entitlements",
+ "schema": "",
+ "columns": {
+ "plan_id": {
+ "name": "plan_id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "plan_entitlements_plan_id_plans_id_fk": {
+ "name": "plan_entitlements_plan_id_plans_id_fk",
+ "tableFrom": "plan_entitlements",
+ "tableTo": "plans",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "plan_entitlements_plan_id_feature_pk": {
+ "name": "plan_entitlements_plan_id_feature_pk",
+ "columns": [
+ "plan_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plans": {
+ "name": "plans",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.provider_credential_events": {
+ "name": "provider_credential_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "credential_provider",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result": {
+ "name": "result",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "provider_credential_events_credential_created_idx": {
+ "name": "provider_credential_events_credential_created_idx",
+ "columns": [
+ {
+ "expression": "credential_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credential_events_actor_created_idx": {
+ "name": "provider_credential_events_actor_created_idx",
+ "columns": [
+ {
+ "expression": "actor_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "provider_credential_events_actor_id_users_id_fk": {
+ "name": "provider_credential_events_actor_id_users_id_fk",
+ "tableFrom": "provider_credential_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "provider_credential_events_workspace_id_workspaces_id_fk": {
+ "name": "provider_credential_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "provider_credential_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.provider_credential_runs": {
+ "name": "provider_credential_runs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surface": {
+ "name": "surface",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ref": {
+ "name": "ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heartbeat_at": {
+ "name": "heartbeat_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": {
+ "provider_credential_runs_credential_idx": {
+ "name": "provider_credential_runs_credential_idx",
+ "columns": [
+ {
+ "expression": "credential_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credential_runs_ref_idx": {
+ "name": "provider_credential_runs_ref_idx",
+ "columns": [
+ {
+ "expression": "ref",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "provider_credential_runs_user_id_users_id_fk": {
+ "name": "provider_credential_runs_user_id_users_id_fk",
+ "tableFrom": "provider_credential_runs",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.provider_credentials": {
+ "name": "provider_credentials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "credential_provider",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_type": {
+ "name": "credential_type",
+ "type": "credential_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "priority_order": {
+ "name": "priority_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "encrypted_api_key": {
+ "name": "encrypted_api_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_access_token": {
+ "name": "encrypted_access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_refresh_token": {
+ "name": "encrypted_refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "endpoint_url": {
+ "name": "endpoint_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "aws_role_arn": {
+ "name": "aws_role_arn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_connected": {
+ "name": "is_connected",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_four": {
+ "name": "last_four",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "provider_credential_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "provider_subject_hash": {
+ "name": "provider_subject_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_material": {
+ "name": "encrypted_material",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_refreshed_at": {
+ "name": "last_refreshed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sharing_enabled": {
+ "name": "sharing_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "connected_via": {
+ "name": "connected_via",
+ "type": "credential_connected_via",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "allow_in_shared_workspaces": {
+ "name": "allow_in_shared_workspaces",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "provider_credentials_scope_provider_type_idx": {
+ "name": "provider_credentials_scope_provider_type_idx",
+ "columns": [
+ {
+ "expression": "scope_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scope_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "credential_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credentials_scope_provider_priority_idx": {
+ "name": "provider_credentials_scope_provider_priority_idx",
+ "columns": [
+ {
+ "expression": "scope_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scope_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "priority_order",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credentials_status_idx": {
+ "name": "provider_credentials_status_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "provider_credentials_created_by_users_id_fk": {
+ "name": "provider_credentials_created_by_users_id_fk",
+ "tableFrom": "provider_credentials",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.published_branches": {
+ "name": "published_branches",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "published_by": {
+ "name": "published_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "branch_name": {
+ "name": "branch_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "publication_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "source_head_sha": {
+ "name": "source_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "commit_sha": {
+ "name": "commit_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_id": {
+ "name": "repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "remote_ref": {
+ "name": "remote_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "html_url": {
+ "name": "html_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pull_request_number": {
+ "name": "pull_request_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pull_request_url": {
+ "name": "pull_request_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "request_id": {
+ "name": "request_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "published_at": {
+ "name": "published_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "published_branches_workspace_name_idx": {
+ "name": "published_branches_workspace_name_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "branch_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "published_branches_workspace_request_idx": {
+ "name": "published_branches_workspace_request_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "request_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "published_branches_workspace_status_idx": {
+ "name": "published_branches_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "published_branches_workspace_id_workspaces_id_fk": {
+ "name": "published_branches_workspace_id_workspaces_id_fk",
+ "tableFrom": "published_branches",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "published_branches_published_by_users_id_fk": {
+ "name": "published_branches_published_by_users_id_fk",
+ "tableFrom": "published_branches",
+ "tableTo": "users",
+ "columnsFrom": [
+ "published_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.runtime_hosts": {
+ "name": "runtime_hosts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "runtime_address": {
+ "name": "runtime_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifecycle_state": {
+ "name": "lifecycle_state",
+ "type": "runtime_host_lifecycle",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'provisioning'"
+ },
+ "max_workspace_slots": {
+ "name": "max_workspace_slots",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 4
+ },
+ "free_workspace_slots": {
+ "name": "free_workspace_slots",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 4
+ },
+ "image_version": {
+ "name": "image_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_heartbeat_at": {
+ "name": "last_heartbeat_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "draining_at": {
+ "name": "draining_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "runtime_hosts_provider_id_idx": {
+ "name": "runtime_hosts_provider_id_idx",
+ "columns": [
+ {
+ "expression": "provider_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "runtime_hosts_runtime_address_idx": {
+ "name": "runtime_hosts_runtime_address_idx",
+ "columns": [
+ {
+ "expression": "runtime_address",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "runtime_hosts_capacity_idx": {
+ "name": "runtime_hosts_capacity_idx",
+ "columns": [
+ {
+ "expression": "lifecycle_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "free_workspace_slots",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sandbox_runtime_intervals": {
+ "name": "sandbox_runtime_intervals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ended_at": {
+ "name": "ended_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "sandbox_runtime_intervals_user_open_idx": {
+ "name": "sandbox_runtime_intervals_user_open_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "ended_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "sandbox_runtime_intervals_workspace_open_idx": {
+ "name": "sandbox_runtime_intervals_workspace_open_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "ended_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "sandbox_runtime_intervals_user_id_users_id_fk": {
+ "name": "sandbox_runtime_intervals_user_id_users_id_fk",
+ "tableFrom": "sandbox_runtime_intervals",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sandbox_runtime_intervals_workspace_id_workspaces_id_fk": {
+ "name": "sandbox_runtime_intervals_workspace_id_workspaces_id_fk",
+ "tableFrom": "sandbox_runtime_intervals",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chat_invites": {
+ "name": "shared_chat_invites",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "shared_chat_id": {
+ "name": "shared_chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_token": {
+ "name": "encrypted_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_by": {
+ "name": "accepted_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chat_invites_token_hash_idx": {
+ "name": "shared_chat_invites_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "shared_chat_invites_room_idx": {
+ "name": "shared_chat_invites_room_idx",
+ "columns": [
+ {
+ "expression": "shared_chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chat_invites_shared_chat_id_shared_chats_id_fk": {
+ "name": "shared_chat_invites_shared_chat_id_shared_chats_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "shared_chats",
+ "columnsFrom": [
+ "shared_chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_invites_created_by_users_id_fk": {
+ "name": "shared_chat_invites_created_by_users_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_invites_accepted_by_users_id_fk": {
+ "name": "shared_chat_invites_accepted_by_users_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "accepted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chat_members": {
+ "name": "shared_chat_members",
+ "schema": "",
+ "columns": {
+ "shared_chat_id": {
+ "name": "shared_chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chat_members_user_idx": {
+ "name": "shared_chat_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chat_members_shared_chat_id_shared_chats_id_fk": {
+ "name": "shared_chat_members_shared_chat_id_shared_chats_id_fk",
+ "tableFrom": "shared_chat_members",
+ "tableTo": "shared_chats",
+ "columnsFrom": [
+ "shared_chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_members_user_id_users_id_fk": {
+ "name": "shared_chat_members_user_id_users_id_fk",
+ "tableFrom": "shared_chat_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "shared_chat_members_shared_chat_id_user_id_pk": {
+ "name": "shared_chat_members_shared_chat_id_user_id_pk",
+ "columns": [
+ "shared_chat_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chats": {
+ "name": "shared_chats",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chats_conversation_idx": {
+ "name": "shared_chats_conversation_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "shared_chats_owner_updated_idx": {
+ "name": "shared_chats_owner_updated_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chats_conversation_id_conversations_id_fk": {
+ "name": "shared_chats_conversation_id_conversations_id_fk",
+ "tableFrom": "shared_chats",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chats_owner_id_users_id_fk": {
+ "name": "shared_chats_owner_id_users_id_fk",
+ "tableFrom": "shared_chats",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_compute_usage": {
+ "name": "user_compute_usage",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "minutes_used": {
+ "name": "minutes_used",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_compute_usage_user_id_users_id_fk": {
+ "name": "user_compute_usage_user_id_users_id_fk",
+ "tableFrom": "user_compute_usage",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_environment_variables": {
+ "name": "user_environment_variables",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_value": {
+ "name": "encrypted_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_four": {
+ "name": "last_four",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_environment_variables_user_name_idx": {
+ "name": "user_environment_variables_user_name_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_environment_variables_user_updated_idx": {
+ "name": "user_environment_variables_user_updated_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_environment_variables_user_id_users_id_fk": {
+ "name": "user_environment_variables_user_id_users_id_fk",
+ "tableFrom": "user_environment_variables",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_feature_overrides": {
+ "name": "user_feature_overrides",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_feature_overrides_user_idx": {
+ "name": "user_feature_overrides_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_feature_overrides_organization_id_organizations_id_fk": {
+ "name": "user_feature_overrides_organization_id_organizations_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_feature_overrides_user_id_users_id_fk": {
+ "name": "user_feature_overrides_user_id_users_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_feature_overrides_created_by_users_id_fk": {
+ "name": "user_feature_overrides_created_by_users_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "user_feature_overrides_organization_id_user_id_feature_pk": {
+ "name": "user_feature_overrides_organization_id_user_id_feature_pk",
+ "columns": [
+ "organization_id",
+ "user_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.users": {
+ "name": "users",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "github_user_id": {
+ "name": "github_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "google_user_id": {
+ "name": "google_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "clerk_user_id": {
+ "name": "clerk_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "login": {
+ "name": "login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password_hash": {
+ "name": "password_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avatar_url": {
+ "name": "avatar_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_admin": {
+ "name": "is_admin",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "users_github_user_id_idx": {
+ "name": "users_github_user_id_idx",
+ "columns": [
+ {
+ "expression": "github_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_google_user_id_idx": {
+ "name": "users_google_user_id_idx",
+ "columns": [
+ {
+ "expression": "google_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_clerk_user_id_idx": {
+ "name": "users_clerk_user_id_idx",
+ "columns": [
+ {
+ "expression": "clerk_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_login_idx": {
+ "name": "users_login_idx",
+ "columns": [
+ {
+ "expression": "login",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channel_messages": {
+ "name": "workspace_channel_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_kind": {
+ "name": "author_kind",
+ "type": "channel_message_author_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_label": {
+ "name": "author_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_session_id": {
+ "name": "agent_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mentions": {
+ "name": "mentions",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "mentions_agent": {
+ "name": "mentions_agent",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channel_messages_channel_idx": {
+ "name": "workspace_channel_messages_channel_idx",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_channel_messages_workspace_idx": {
+ "name": "workspace_channel_messages_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channel_messages_channel_id_workspace_channels_id_fk": {
+ "name": "workspace_channel_messages_channel_id_workspace_channels_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "workspace_channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_workspace_id_workspaces_id_fk": {
+ "name": "workspace_channel_messages_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_author_id_users_id_fk": {
+ "name": "workspace_channel_messages_author_id_users_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_agent_session_id_agent_sessions_id_fk": {
+ "name": "workspace_channel_messages_agent_session_id_agent_sessions_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "agent_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channel_reads": {
+ "name": "workspace_channel_reads",
+ "schema": "",
+ "columns": {
+ "channel_id": {
+ "name": "channel_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_read_at": {
+ "name": "last_read_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channel_reads_user_idx": {
+ "name": "workspace_channel_reads_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channel_reads_channel_id_workspace_channels_id_fk": {
+ "name": "workspace_channel_reads_channel_id_workspace_channels_id_fk",
+ "tableFrom": "workspace_channel_reads",
+ "tableTo": "workspace_channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_reads_user_id_users_id_fk": {
+ "name": "workspace_channel_reads_user_id_users_id_fk",
+ "tableFrom": "workspace_channel_reads",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_channel_reads_channel_id_user_id_pk": {
+ "name": "workspace_channel_reads_channel_id_user_id_pk",
+ "columns": [
+ "channel_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channels": {
+ "name": "workspace_channels",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "topic": {
+ "name": "topic",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_access": {
+ "name": "agent_access",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channels_workspace_slug_idx": {
+ "name": "workspace_channels_workspace_slug_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_channels_workspace_idx": {
+ "name": "workspace_channels_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "archived_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channels_workspace_id_workspaces_id_fk": {
+ "name": "workspace_channels_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_channels",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channels_created_by_users_id_fk": {
+ "name": "workspace_channels_created_by_users_id_fk",
+ "tableFrom": "workspace_channels",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_leases": {
+ "name": "workspace_chat_leases",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "holder_id": {
+ "name": "holder_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lease_token": {
+ "name": "lease_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_leases_expiry_idx": {
+ "name": "workspace_chat_leases_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_leases_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_leases_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_leases",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_leases_holder_id_users_id_fk": {
+ "name": "workspace_chat_leases_holder_id_users_id_fk",
+ "tableFrom": "workspace_chat_leases",
+ "tableTo": "users",
+ "columnsFrom": [
+ "holder_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_chat_leases_workspace_id_chat_id_pk": {
+ "name": "workspace_chat_leases_workspace_id_chat_id_pk",
+ "columns": [
+ "workspace_id",
+ "chat_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_participants": {
+ "name": "workspace_chat_participants",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_participants_expiry_idx": {
+ "name": "workspace_chat_participants_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_participants_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_participants_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_participants",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_participants_user_id_users_id_fk": {
+ "name": "workspace_chat_participants_user_id_users_id_fk",
+ "tableFrom": "workspace_chat_participants",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_chat_participants_workspace_id_chat_id_user_id_client_id_pk": {
+ "name": "workspace_chat_participants_workspace_id_chat_id_user_id_client_id_pk",
+ "columns": [
+ "workspace_id",
+ "chat_id",
+ "user_id",
+ "client_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_prompt_receipts": {
+ "name": "workspace_chat_prompt_receipts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_message_id": {
+ "name": "client_message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attachments": {
+ "name": "attachments",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "effort": {
+ "name": "effort",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_prompt_receipts_client_message_idx": {
+ "name": "workspace_chat_prompt_receipts_client_message_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "client_message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_chat_prompt_receipts_chat_created_idx": {
+ "name": "workspace_chat_prompt_receipts_chat_created_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_prompt_receipts_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_prompt_receipts_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_prompt_receipts",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_prompt_receipts_author_id_users_id_fk": {
+ "name": "workspace_chat_prompt_receipts_author_id_users_id_fk",
+ "tableFrom": "workspace_chat_prompt_receipts",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_events": {
+ "name": "workspace_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence": {
+ "name": "sequence",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_events_sequence_idx": {
+ "name": "workspace_events_sequence_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sequence",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_events_workspace_id_workspaces_id_fk": {
+ "name": "workspace_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_events_actor_id_users_id_fk": {
+ "name": "workspace_events_actor_id_users_id_fk",
+ "tableFrom": "workspace_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_invites": {
+ "name": "workspace_invites",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "invitee_email": {
+ "name": "invitee_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invitee_login": {
+ "name": "invitee_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_role": {
+ "name": "access_role",
+ "type": "workspace_access_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'viewer'"
+ },
+ "allow_link": {
+ "name": "allow_link",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_by": {
+ "name": "accepted_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_invites_token_hash_idx": {
+ "name": "workspace_invites_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_invites_workspace_idx": {
+ "name": "workspace_invites_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_invites_workspace_id_workspaces_id_fk": {
+ "name": "workspace_invites_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_invites_created_by_users_id_fk": {
+ "name": "workspace_invites_created_by_users_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_invites_accepted_by_users_id_fk": {
+ "name": "workspace_invites_accepted_by_users_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "accepted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_member_statuses": {
+ "name": "workspace_member_statuses",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emoji": {
+ "name": "emoji",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "headline": {
+ "name": "headline",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_member_statuses_workspace_idx": {
+ "name": "workspace_member_statuses_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_member_statuses_workspace_id_workspaces_id_fk": {
+ "name": "workspace_member_statuses_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_member_statuses",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_member_statuses_user_id_users_id_fk": {
+ "name": "workspace_member_statuses_user_id_users_id_fk",
+ "tableFrom": "workspace_member_statuses",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_member_statuses_workspace_id_user_id_pk": {
+ "name": "workspace_member_statuses_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_members": {
+ "name": "workspace_members",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "member_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "access_role": {
+ "name": "access_role",
+ "type": "workspace_access_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'viewer'"
+ },
+ "can_terminal": {
+ "name": "can_terminal",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "can_merge": {
+ "name": "can_merge",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_members_user_idx": {
+ "name": "workspace_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_members_workspace_id_workspaces_id_fk": {
+ "name": "workspace_members_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_members",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_members_user_id_users_id_fk": {
+ "name": "workspace_members_user_id_users_id_fk",
+ "tableFrom": "workspace_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_members_workspace_id_user_id_pk": {
+ "name": "workspace_members_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_runtime_assignments": {
+ "name": "workspace_runtime_assignments",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "host_id": {
+ "name": "host_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "generation": {
+ "name": "generation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "fencing_token": {
+ "name": "fencing_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "disk_id": {
+ "name": "disk_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "disk_lun": {
+ "name": "disk_lun",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "runtime_state": {
+ "name": "runtime_state",
+ "type": "workspace_runtime_assignment_state",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'assigned'"
+ },
+ "last_used_at": {
+ "name": "last_used_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": {
+ "workspace_runtime_assignments_host_state_idx": {
+ "name": "workspace_runtime_assignments_host_state_idx",
+ "columns": [
+ {
+ "expression": "host_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "runtime_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_runtime_assignments_state_updated_idx": {
+ "name": "workspace_runtime_assignments_state_updated_idx",
+ "columns": [
+ {
+ "expression": "runtime_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_runtime_assignments_workspace_id_workspaces_id_fk": {
+ "name": "workspace_runtime_assignments_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_runtime_assignments",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_runtime_assignments_host_id_runtime_hosts_id_fk": {
+ "name": "workspace_runtime_assignments_host_id_runtime_hosts_id_fk",
+ "tableFrom": "workspace_runtime_assignments",
+ "tableTo": "runtime_hosts",
+ "columnsFrom": [
+ "host_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_runtimes": {
+ "name": "workspace_runtimes",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "sandbox_id": {
+ "name": "sandbox_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "backend": {
+ "name": "backend",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'firecracker'"
+ },
+ "status": {
+ "name": "status",
+ "type": "sandbox_runtime_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'provisioning'"
+ },
+ "provisioned_head_sha": {
+ "name": "provisioned_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "snapshot_ref": {
+ "name": "snapshot_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_heartbeat_at": {
+ "name": "last_heartbeat_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hibernated_at": {
+ "name": "hibernated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provisioned_at": {
+ "name": "provisioned_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stopped_at": {
+ "name": "stopped_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_runtimes_status_updated_idx": {
+ "name": "workspace_runtimes_status_updated_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_runtimes_workspace_id_workspaces_id_fk": {
+ "name": "workspace_runtimes_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_runtimes",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "workspace_runtimes_sandbox_id_unique": {
+ "name": "workspace_runtimes_sandbox_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "sandbox_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_snapshots": {
+ "name": "workspace_snapshots",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "snapshot": {
+ "name": "snapshot",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_bytes": {
+ "name": "total_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_snapshots_updated_idx": {
+ "name": "workspace_snapshots_updated_idx",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_snapshots_workspace_id_workspaces_id_fk": {
+ "name": "workspace_snapshots_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_snapshots",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_state_documents": {
+ "name": "workspace_state_documents",
+ "schema": "",
+ "columns": {
+ "document_name": {
+ "name": "document_name",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state": {
+ "name": "state",
+ "type": "bytea",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_state_documents_workspace_idx": {
+ "name": "workspace_state_documents_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_state_documents_workspace_id_workspaces_id_fk": {
+ "name": "workspace_state_documents_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_state_documents",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspaces": {
+ "name": "workspaces",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_installation_id": {
+ "name": "github_installation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository": {
+ "name": "repository",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repository_visibility": {
+ "name": "repository_visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "default_branch": {
+ "name": "default_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "workspace_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "last_activity_at": {
+ "name": "last_activity_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "hibernate_at": {
+ "name": "hibernate_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspaces_owner_idx": {
+ "name": "workspaces_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_organization_idx": {
+ "name": "workspaces_organization_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_repository_idx": {
+ "name": "workspaces_repository_idx",
+ "columns": [
+ {
+ "expression": "github_repository_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_status_expiry_idx": {
+ "name": "workspaces_status_expiry_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_deleted_idx": {
+ "name": "workspaces_deleted_idx",
+ "columns": [
+ {
+ "expression": "deleted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspaces_owner_id_users_id_fk": {
+ "name": "workspaces_owner_id_users_id_fk",
+ "tableFrom": "workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "workspaces_organization_id_organizations_id_fk": {
+ "name": "workspaces_organization_id_organizations_id_fk",
+ "tableFrom": "workspaces",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.worktrees": {
+ "name": "worktrees",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "worktree_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "worktree_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "review_head_sha": {
+ "name": "review_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_base_sha": {
+ "name": "review_base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_diff_digest": {
+ "name": "review_diff_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_by": {
+ "name": "reviewed_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_at": {
+ "name": "reviewed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "merged_at": {
+ "name": "merged_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "discarded_at": {
+ "name": "discarded_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "worktrees_workspace_name_idx": {
+ "name": "worktrees_workspace_name_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "worktrees_workspace_status_idx": {
+ "name": "worktrees_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "worktrees_workspace_id_workspaces_id_fk": {
+ "name": "worktrees_workspace_id_workspaces_id_fk",
+ "tableFrom": "worktrees",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "worktrees_reviewed_by_users_id_fk": {
+ "name": "worktrees_reviewed_by_users_id_fk",
+ "tableFrom": "worktrees",
+ "tableTo": "users",
+ "columnsFrom": [
+ "reviewed_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.yjs_snapshots": {
+ "name": "yjs_snapshots",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "update_base64": {
+ "name": "update_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state_vector_base64": {
+ "name": "state_vector_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_contents": {
+ "name": "filesystem_contents",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_conflict": {
+ "name": "has_conflict",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "conflict_filesystem_revision": {
+ "name": "conflict_filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_detected_at": {
+ "name": "conflict_detected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolved_at": {
+ "name": "conflict_resolved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolved_by": {
+ "name": "conflict_resolved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolution": {
+ "name": "conflict_resolution",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "yjs_snapshots_worktree_path_idx": {
+ "name": "yjs_snapshots_worktree_path_idx",
+ "columns": [
+ {
+ "expression": "worktree_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "yjs_snapshots_worktree_id_worktrees_id_fk": {
+ "name": "yjs_snapshots_worktree_id_worktrees_id_fk",
+ "tableFrom": "yjs_snapshots",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "yjs_snapshots_conflict_resolved_by_users_id_fk": {
+ "name": "yjs_snapshots_conflict_resolved_by_users_id_fk",
+ "tableFrom": "yjs_snapshots",
+ "tableTo": "users",
+ "columnsFrom": [
+ "conflict_resolved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {
+ "public.access_request_status": {
+ "name": "access_request_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "invited",
+ "declined"
+ ]
+ },
+ "public.agent_brief_status": {
+ "name": "agent_brief_status",
+ "schema": "public",
+ "values": [
+ "planning",
+ "active",
+ "blocked",
+ "paused",
+ "done"
+ ]
+ },
+ "public.agent_session_import_status": {
+ "name": "agent_session_import_status",
+ "schema": "public",
+ "values": [
+ "storing",
+ "stored",
+ "restoring",
+ "ready",
+ "launching",
+ "active",
+ "failed",
+ "deleted"
+ ]
+ },
+ "public.agent_session_kind": {
+ "name": "agent_session_kind",
+ "schema": "public",
+ "values": [
+ "managed",
+ "cli"
+ ]
+ },
+ "public.agent_session_status": {
+ "name": "agent_session_status",
+ "schema": "public",
+ "values": [
+ "idle",
+ "running",
+ "waiting",
+ "completed",
+ "interrupted",
+ "failed"
+ ]
+ },
+ "public.agent_turn_status": {
+ "name": "agent_turn_status",
+ "schema": "public",
+ "values": [
+ "queued",
+ "running",
+ "completed",
+ "interrupted",
+ "failed"
+ ]
+ },
+ "public.brain_entry_kind": {
+ "name": "brain_entry_kind",
+ "schema": "public",
+ "values": [
+ "decision",
+ "attempt",
+ "dead_end",
+ "finding",
+ "convention",
+ "handoff"
+ ]
+ },
+ "public.brain_overlap_kind": {
+ "name": "brain_overlap_kind",
+ "schema": "public",
+ "values": [
+ "duplicate_intent",
+ "file_overlap",
+ "claim_contest"
+ ]
+ },
+ "public.brain_overlap_status": {
+ "name": "brain_overlap_status",
+ "schema": "public",
+ "values": [
+ "open",
+ "acknowledged",
+ "resolved"
+ ]
+ },
+ "public.channel_message_author_kind": {
+ "name": "channel_message_author_kind",
+ "schema": "public",
+ "values": [
+ "member",
+ "agent",
+ "system"
+ ]
+ },
+ "public.claim_status": {
+ "name": "claim_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "released",
+ "expired",
+ "contested"
+ ]
+ },
+ "public.claude_connection_session_status": {
+ "name": "claude_connection_session_status",
+ "schema": "public",
+ "values": [
+ "starting",
+ "awaiting_code",
+ "exchanging",
+ "connected",
+ "failed"
+ ]
+ },
+ "public.cli_client_type": {
+ "name": "cli_client_type",
+ "schema": "public",
+ "values": [
+ "cli",
+ "mobile"
+ ]
+ },
+ "public.cli_device_authorization_status": {
+ "name": "cli_device_authorization_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "approved",
+ "denied"
+ ]
+ },
+ "public.credential_connected_via": {
+ "name": "credential_connected_via",
+ "schema": "public",
+ "values": [
+ "browser",
+ "cli",
+ "api_key"
+ ]
+ },
+ "public.credential_provider": {
+ "name": "credential_provider",
+ "schema": "public",
+ "values": [
+ "anthropic",
+ "openai",
+ "bedrock",
+ "azure_foundry",
+ "cursor",
+ "custom"
+ ]
+ },
+ "public.credential_scope_type": {
+ "name": "credential_scope_type",
+ "schema": "public",
+ "values": [
+ "USER",
+ "WORKSPACE"
+ ]
+ },
+ "public.credential_type": {
+ "name": "credential_type",
+ "schema": "public",
+ "values": [
+ "API_KEY",
+ "OAUTH_TOKEN",
+ "AWS_BEDROCK_ROLE",
+ "AZURE_ENDPOINT",
+ "HOSTED_CODEX_SUBSCRIPTION"
+ ]
+ },
+ "public.feature_key": {
+ "name": "feature_key",
+ "schema": "public",
+ "values": [
+ "hosted_codex_subscription"
+ ]
+ },
+ "public.feature_override_audit_action": {
+ "name": "feature_override_audit_action",
+ "schema": "public",
+ "values": [
+ "created",
+ "updated",
+ "deleted"
+ ]
+ },
+ "public.gen2_superset_run_status": {
+ "name": "gen2_superset_run_status",
+ "schema": "public",
+ "values": [
+ "creating",
+ "running",
+ "stopping",
+ "finished",
+ "failed",
+ "recovery_required"
+ ]
+ },
+ "public.gen2_workspace_role": {
+ "name": "gen2_workspace_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "editor",
+ "viewer"
+ ]
+ },
+ "public.gen2_workspace_status": {
+ "name": "gen2_workspace_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "provisioning",
+ "ready",
+ "failed",
+ "stopped",
+ "deleting"
+ ]
+ },
+ "public.member_role": {
+ "name": "member_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "member"
+ ]
+ },
+ "public.coordination_message_status": {
+ "name": "coordination_message_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "delivered",
+ "resolved"
+ ]
+ },
+ "public.mobile_platform": {
+ "name": "mobile_platform",
+ "schema": "public",
+ "values": [
+ "ios",
+ "android"
+ ]
+ },
+ "public.organization_role": {
+ "name": "organization_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "admin",
+ "billing_admin",
+ "member"
+ ]
+ },
+ "public.organization_subscription_status": {
+ "name": "organization_subscription_status",
+ "schema": "public",
+ "values": [
+ "trialing",
+ "active",
+ "past_due",
+ "canceled"
+ ]
+ },
+ "public.provider_credential_status": {
+ "name": "provider_credential_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "reauthorization_required",
+ "revoked",
+ "failed"
+ ]
+ },
+ "public.publication_status": {
+ "name": "publication_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "published",
+ "failed"
+ ]
+ },
+ "public.repository_restore_status": {
+ "name": "repository_restore_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "matched",
+ "restored",
+ "conflicted",
+ "unavailable",
+ "transcript_only"
+ ]
+ },
+ "public.runtime_host_lifecycle": {
+ "name": "runtime_host_lifecycle",
+ "schema": "public",
+ "values": [
+ "provisioning",
+ "ready",
+ "draining",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.sandbox_runtime_status": {
+ "name": "sandbox_runtime_status",
+ "schema": "public",
+ "values": [
+ "provisioning",
+ "ready",
+ "hibernated",
+ "stopping",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.session_continuation_mode": {
+ "name": "session_continuation_mode",
+ "schema": "public",
+ "values": [
+ "managed",
+ "native_resume"
+ ]
+ },
+ "public.subscription_plan": {
+ "name": "subscription_plan",
+ "schema": "public",
+ "values": [
+ "free",
+ "pro",
+ "team",
+ "enterprise"
+ ]
+ },
+ "public.workspace_access_role": {
+ "name": "workspace_access_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "co_steer",
+ "reviewer",
+ "viewer"
+ ]
+ },
+ "public.workspace_runtime_assignment_state": {
+ "name": "workspace_runtime_assignment_state",
+ "schema": "public",
+ "values": [
+ "assigned",
+ "starting",
+ "ready",
+ "draining",
+ "lost"
+ ]
+ },
+ "public.workspace_status": {
+ "name": "workspace_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "provisioning",
+ "ready",
+ "hibernated",
+ "stopping",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.worktree_kind": {
+ "name": "worktree_kind",
+ "schema": "public",
+ "values": [
+ "integration",
+ "agent"
+ ]
+ },
+ "public.worktree_status": {
+ "name": "worktree_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "frozen",
+ "merged",
+ "discarded"
+ ]
+ }
+ },
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/0062_snapshot.json b/packages/db/drizzle/meta/0062_snapshot.json
new file mode 100644
index 000000000..6893cca59
--- /dev/null
+++ b/packages/db/drizzle/meta/0062_snapshot.json
@@ -0,0 +1,9878 @@
+{
+ "id": "064234ae-0e69-47e9-abe5-11964342de7a",
+ "prevId": "1e2733a9-6e54-4bb8-a8a3-9ed72c565fbb",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.access_requests": {
+ "name": "access_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_login": {
+ "name": "github_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "persona": {
+ "name": "persona",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building": {
+ "name": "building",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "referrer": {
+ "name": "referrer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ip_hash": {
+ "name": "ip_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "access_request_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "invited_at": {
+ "name": "invited_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invite_token_hash": {
+ "name": "invite_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invite_token_expires_at": {
+ "name": "invite_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "access_requests_email_idx": {
+ "name": "access_requests_email_idx",
+ "columns": [
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_status_created_idx": {
+ "name": "access_requests_status_created_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_ip_created_idx": {
+ "name": "access_requests_ip_created_idx",
+ "columns": [
+ {
+ "expression": "ip_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "access_requests_invite_token_hash_idx": {
+ "name": "access_requests_invite_token_hash_idx",
+ "columns": [
+ {
+ "expression": "invite_token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_briefs": {
+ "name": "agent_briefs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "approach_summary": {
+ "name": "approach_summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "plan_steps": {
+ "name": "plan_steps",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "current_step": {
+ "name": "current_step",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "files_likely_to_touch": {
+ "name": "files_likely_to_touch",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "keywords": {
+ "name": "keywords",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_brief_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'planning'"
+ },
+ "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_briefs_session_idx": {
+ "name": "agent_briefs_session_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_briefs_workspace_status_idx": {
+ "name": "agent_briefs_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_briefs_workspace_id_workspaces_id_fk": {
+ "name": "agent_briefs_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_briefs",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_briefs_session_id_agent_sessions_id_fk": {
+ "name": "agent_briefs_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_briefs",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_events": {
+ "name": "agent_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "turn_id": {
+ "name": "turn_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_events_idempotency_idx": {
+ "name": "agent_events_idempotency_idx",
+ "columns": [
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_events_session_created_idx": {
+ "name": "agent_events_session_created_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_events_workspace_id_workspaces_id_fk": {
+ "name": "agent_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_events_session_id_agent_sessions_id_fk": {
+ "name": "agent_events_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_events_turn_id_agent_turns_id_fk": {
+ "name": "agent_events_turn_id_agent_turns_id_fk",
+ "tableFrom": "agent_events",
+ "tableTo": "agent_turns",
+ "columnsFrom": [
+ "turn_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_session_import_artifacts": {
+ "name": "agent_session_import_artifacts",
+ "schema": "",
+ "columns": {
+ "import_id": {
+ "name": "import_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "media_type": {
+ "name": "media_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plaintext_sha256": {
+ "name": "plaintext_sha256",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plaintext_bytes": {
+ "name": "plaintext_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_payload": {
+ "name": "encrypted_payload",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_session_import_artifacts_created_idx": {
+ "name": "agent_session_import_artifacts_created_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_session_import_artifacts_import_id_agent_session_imports_id_fk": {
+ "name": "agent_session_import_artifacts_import_id_agent_session_imports_id_fk",
+ "tableFrom": "agent_session_import_artifacts",
+ "tableTo": "agent_session_imports",
+ "columnsFrom": [
+ "import_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_session_imports": {
+ "name": "agent_session_imports",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "imported_by": {
+ "name": "imported_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_import_id": {
+ "name": "parent_import_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_session_id": {
+ "name": "agent_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_provider": {
+ "name": "source_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_session_id": {
+ "name": "external_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capsule_schema_version": {
+ "name": "capsule_schema_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capsule_sha256": {
+ "name": "capsule_sha256",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_session_import_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'storing'"
+ },
+ "repository_status": {
+ "name": "repository_status",
+ "type": "repository_restore_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "continuation_mode": {
+ "name": "continuation_mode",
+ "type": "session_continuation_mode",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_session_imports_idempotency_idx": {
+ "name": "agent_session_imports_idempotency_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_workspace_status_idx": {
+ "name": "agent_session_imports_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_importer_idx": {
+ "name": "agent_session_imports_importer_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_source_idx": {
+ "name": "agent_session_imports_source_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_parent_idx": {
+ "name": "agent_session_imports_parent_idx",
+ "columns": [
+ {
+ "expression": "parent_import_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_session_imports_active_writer_idx": {
+ "name": "agent_session_imports_active_writer_idx",
+ "columns": [
+ {
+ "expression": "imported_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_session_imports\".\"continuation_mode\" = 'native_resume' and \"agent_session_imports\".\"status\" in ('launching', 'active') and \"agent_session_imports\".\"deleted_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_session_imports_organization_id_organizations_id_fk": {
+ "name": "agent_session_imports_organization_id_organizations_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_workspace_id_workspaces_id_fk": {
+ "name": "agent_session_imports_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_imported_by_users_id_fk": {
+ "name": "agent_session_imports_imported_by_users_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "users",
+ "columnsFrom": [
+ "imported_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_parent_import_id_agent_session_imports_id_fk": {
+ "name": "agent_session_imports_parent_import_id_agent_session_imports_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "agent_session_imports",
+ "columnsFrom": [
+ "parent_import_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_worktree_id_worktrees_id_fk": {
+ "name": "agent_session_imports_worktree_id_worktrees_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_session_imports_agent_session_id_agent_sessions_id_fk": {
+ "name": "agent_session_imports_agent_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_session_imports",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "agent_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_sessions": {
+ "name": "agent_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_number": {
+ "name": "issue_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'Agent'"
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'gpt-5'"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'openai'"
+ },
+ "kind": {
+ "name": "kind",
+ "type": "agent_session_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'managed'"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_session_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'idle'"
+ },
+ "workflow_run_id": {
+ "name": "workflow_run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "interrupted_at": {
+ "name": "interrupted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_sessions_workspace_issue_idx": {
+ "name": "agent_sessions_workspace_issue_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "issue_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_sessions_workspace_status_idx": {
+ "name": "agent_sessions_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_sessions_workspace_id_workspaces_id_fk": {
+ "name": "agent_sessions_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_sessions_worktree_id_worktrees_id_fk": {
+ "name": "agent_sessions_worktree_id_worktrees_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_sessions_created_by_users_id_fk": {
+ "name": "agent_sessions_created_by_users_id_fk",
+ "tableFrom": "agent_sessions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_turns": {
+ "name": "agent_turns",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attachments": {
+ "name": "attachments",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "status": {
+ "name": "status",
+ "type": "agent_turn_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "workflow_run_id": {
+ "name": "workflow_run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_id": {
+ "name": "response_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output": {
+ "name": "output",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finished_at": {
+ "name": "finished_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_turns_session_created_idx": {
+ "name": "agent_turns_session_created_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_turns_session_id_agent_sessions_id_fk": {
+ "name": "agent_turns_session_id_agent_sessions_id_fk",
+ "tableFrom": "agent_turns",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_turns_author_id_users_id_fk": {
+ "name": "agent_turns_author_id_users_id_fk",
+ "tableFrom": "agent_turns",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.brain_entries": {
+ "name": "brain_entries",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "brain_entry_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "paths": {
+ "name": "paths",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "keywords": {
+ "name": "keywords",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "supersedes_id": {
+ "name": "supersedes_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "brain_entries_workspace_created_idx": {
+ "name": "brain_entries_workspace_created_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "brain_entries_workspace_kind_idx": {
+ "name": "brain_entries_workspace_kind_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "brain_entries_workspace_id_workspaces_id_fk": {
+ "name": "brain_entries_workspace_id_workspaces_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_entries_session_id_agent_sessions_id_fk": {
+ "name": "brain_entries_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "brain_entries_author_id_users_id_fk": {
+ "name": "brain_entries_author_id_users_id_fk",
+ "tableFrom": "brain_entries",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.brain_overlaps": {
+ "name": "brain_overlaps",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "left_session_id": {
+ "name": "left_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "right_session_id": {
+ "name": "right_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "brain_overlap_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "score": {
+ "name": "score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "evidence": {
+ "name": "evidence",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "rationale": {
+ "name": "rationale",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "status": {
+ "name": "status",
+ "type": "brain_overlap_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "detected_at": {
+ "name": "detected_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": {
+ "brain_overlaps_pair_kind_idx": {
+ "name": "brain_overlaps_pair_kind_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "left_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "right_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "brain_overlaps_workspace_status_idx": {
+ "name": "brain_overlaps_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "brain_overlaps_workspace_id_workspaces_id_fk": {
+ "name": "brain_overlaps_workspace_id_workspaces_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_overlaps_left_session_id_agent_sessions_id_fk": {
+ "name": "brain_overlaps_left_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "left_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "brain_overlaps_right_session_id_agent_sessions_id_fk": {
+ "name": "brain_overlaps_right_session_id_agent_sessions_id_fk",
+ "tableFrom": "brain_overlaps",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "right_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.claude_connection_sessions": {
+ "name": "claude_connection_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'USER'"
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "claude_connection_session_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'starting'"
+ },
+ "runner_id": {
+ "name": "runner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "authorize_url": {
+ "name": "authorize_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_reason": {
+ "name": "failure_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "claude_connection_sessions_user_idx": {
+ "name": "claude_connection_sessions_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "claude_connection_sessions_expiry_idx": {
+ "name": "claude_connection_sessions_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "claude_connection_sessions_user_id_users_id_fk": {
+ "name": "claude_connection_sessions_user_id_users_id_fk",
+ "tableFrom": "claude_connection_sessions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cli_access_tokens": {
+ "name": "cli_access_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'CoDev CLI'"
+ },
+ "client_type": {
+ "name": "client_type",
+ "type": "cli_client_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'cli'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_used_at": {
+ "name": "last_used_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "cli_access_tokens_token_hash_idx": {
+ "name": "cli_access_tokens_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_access_tokens_user_idx": {
+ "name": "cli_access_tokens_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_access_tokens_expiry_idx": {
+ "name": "cli_access_tokens_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cli_access_tokens_user_id_users_id_fk": {
+ "name": "cli_access_tokens_user_id_users_id_fk",
+ "tableFrom": "cli_access_tokens",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cli_device_authorizations": {
+ "name": "cli_device_authorizations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "device_code_hash": {
+ "name": "device_code_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_code": {
+ "name": "user_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "cli_device_authorization_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "client_type": {
+ "name": "client_type",
+ "type": "cli_client_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'cli'"
+ },
+ "approved_by": {
+ "name": "approved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "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": {
+ "cli_device_authorizations_device_code_idx": {
+ "name": "cli_device_authorizations_device_code_idx",
+ "columns": [
+ {
+ "expression": "device_code_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_device_authorizations_user_code_idx": {
+ "name": "cli_device_authorizations_user_code_idx",
+ "columns": [
+ {
+ "expression": "user_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "cli_device_authorizations_expiry_idx": {
+ "name": "cli_device_authorizations_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cli_device_authorizations_approved_by_users_id_fk": {
+ "name": "cli_device_authorizations_approved_by_users_id_fk",
+ "tableFrom": "cli_device_authorizations",
+ "tableTo": "users",
+ "columnsFrom": [
+ "approved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.collaboration_conflict_resolutions": {
+ "name": "collaboration_conflict_resolutions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resolved_by": {
+ "name": "resolved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "strategy": {
+ "name": "strategy",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "snapshot_revision": {
+ "name": "snapshot_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result_revision": {
+ "name": "result_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "collaboration_conflict_resolutions_document_idx": {
+ "name": "collaboration_conflict_resolutions_document_idx",
+ "columns": [
+ {
+ "expression": "worktree_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "collaboration_conflict_resolutions_worktree_id_worktrees_id_fk": {
+ "name": "collaboration_conflict_resolutions_worktree_id_worktrees_id_fk",
+ "tableFrom": "collaboration_conflict_resolutions",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "collaboration_conflict_resolutions_resolved_by_users_id_fk": {
+ "name": "collaboration_conflict_resolutions_resolved_by_users_id_fk",
+ "tableFrom": "collaboration_conflict_resolutions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "resolved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversation_artifacts": {
+ "name": "conversation_artifacts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_url": {
+ "name": "source_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "downloadable": {
+ "name": "downloadable",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversation_artifacts_conversation_idx": {
+ "name": "conversation_artifacts_conversation_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "conversation_artifacts_message_idx": {
+ "name": "conversation_artifacts_message_idx",
+ "columns": [
+ {
+ "expression": "message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversation_artifacts_conversation_id_conversations_id_fk": {
+ "name": "conversation_artifacts_conversation_id_conversations_id_fk",
+ "tableFrom": "conversation_artifacts",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "conversation_artifacts_message_id_conversation_messages_id_fk": {
+ "name": "conversation_artifacts_message_id_conversation_messages_id_fk",
+ "tableFrom": "conversation_artifacts",
+ "tableTo": "conversation_messages",
+ "columnsFrom": [
+ "message_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversation_messages": {
+ "name": "conversation_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence": {
+ "name": "sequence",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_user_id": {
+ "name": "author_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_name": {
+ "name": "author_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_content_type": {
+ "name": "source_content_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_created_at": {
+ "name": "source_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversation_messages_sequence_idx": {
+ "name": "conversation_messages_sequence_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sequence",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversation_messages_conversation_id_conversations_id_fk": {
+ "name": "conversation_messages_conversation_id_conversations_id_fk",
+ "tableFrom": "conversation_messages",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "conversation_messages_author_user_id_users_id_fk": {
+ "name": "conversation_messages_author_user_id_users_id_fk",
+ "tableFrom": "conversation_messages",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.conversations": {
+ "name": "conversations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'imported'"
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_provider": {
+ "name": "source_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_external_id": {
+ "name": "source_external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_url": {
+ "name": "source_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_model": {
+ "name": "source_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_updated_at": {
+ "name": "source_updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "warnings": {
+ "name": "warnings",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "conversations_owner_updated_idx": {
+ "name": "conversations_owner_updated_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "conversations_owner_source_idx": {
+ "name": "conversations_owner_source_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_external_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversations_owner_id_users_id_fk": {
+ "name": "conversations_owner_id_users_id_fk",
+ "tableFrom": "conversations",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.coordination_messages": {
+ "name": "coordination_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "from_session_id": {
+ "name": "from_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "to_session_id": {
+ "name": "to_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "correlation_id": {
+ "name": "correlation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "response_to_id": {
+ "name": "response_to_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "coordination_message_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "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": {
+ "coordination_messages_target_status_idx": {
+ "name": "coordination_messages_target_status_idx",
+ "columns": [
+ {
+ "expression": "to_session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "coordination_messages_workspace_id_workspaces_id_fk": {
+ "name": "coordination_messages_workspace_id_workspaces_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coordination_messages_from_session_id_agent_sessions_id_fk": {
+ "name": "coordination_messages_from_session_id_agent_sessions_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "from_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "coordination_messages_to_session_id_agent_sessions_id_fk": {
+ "name": "coordination_messages_to_session_id_agent_sessions_id_fk",
+ "tableFrom": "coordination_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "to_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.design_partner_feedback": {
+ "name": "design_partner_feedback",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "category": {
+ "name": "category",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rating": {
+ "name": "rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "page": {
+ "name": "page",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "release": {
+ "name": "release",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'new'"
+ },
+ "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": {
+ "design_partner_feedback_user_created_idx": {
+ "name": "design_partner_feedback_user_created_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "design_partner_feedback_status_created_idx": {
+ "name": "design_partner_feedback_status_created_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "design_partner_feedback_user_id_users_id_fk": {
+ "name": "design_partner_feedback_user_id_users_id_fk",
+ "tableFrom": "design_partner_feedback",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "design_partner_feedback_workspace_id_workspaces_id_fk": {
+ "name": "design_partner_feedback_workspace_id_workspaces_id_fk",
+ "tableFrom": "design_partner_feedback",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.feature_override_audit_events": {
+ "name": "feature_override_audit_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_user_id": {
+ "name": "target_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_user_id": {
+ "name": "actor_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "feature_override_audit_action",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "previous_enabled": {
+ "name": "previous_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "previous_expires_at": {
+ "name": "previous_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "feature_override_audit_org_created_idx": {
+ "name": "feature_override_audit_org_created_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "feature_override_audit_user_created_idx": {
+ "name": "feature_override_audit_user_created_idx",
+ "columns": [
+ {
+ "expression": "target_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "feature_override_audit_events_organization_id_organizations_id_fk": {
+ "name": "feature_override_audit_events_organization_id_organizations_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "feature_override_audit_events_target_user_id_users_id_fk": {
+ "name": "feature_override_audit_events_target_user_id_users_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "target_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "feature_override_audit_events_actor_user_id_users_id_fk": {
+ "name": "feature_override_audit_events_actor_user_id_users_id_fk",
+ "tableFrom": "feature_override_audit_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_agent_turns": {
+ "name": "gen2_agent_turns",
+ "schema": "",
+ "columns": {
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "output": {
+ "name": "output",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "pending_base64": {
+ "name": "pending_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "exited": {
+ "name": "exited",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "reply_message_id": {
+ "name": "reply_message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_agent_turns_chat_idx": {
+ "name": "gen2_agent_turns_chat_idx",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_agent_turns_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_agent_turns_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_chat_id_gen2_chats_id_fk": {
+ "name": "gen2_agent_turns_chat_id_gen2_chats_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_chats",
+ "columnsFrom": [
+ "chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_user_id_users_id_fk": {
+ "name": "gen2_agent_turns_user_id_users_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_agent_turns_reply_message_id_gen2_chat_messages_id_fk": {
+ "name": "gen2_agent_turns_reply_message_id_gen2_chat_messages_id_fk",
+ "tableFrom": "gen2_agent_turns",
+ "tableTo": "gen2_chat_messages",
+ "columnsFrom": [
+ "reply_message_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_chat_messages": {
+ "name": "gen2_chat_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "items": {
+ "name": "items",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_chat_messages_chat_idx": {
+ "name": "gen2_chat_messages_chat_idx",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_chat_messages_chat_id_gen2_chats_id_fk": {
+ "name": "gen2_chat_messages_chat_id_gen2_chats_id_fk",
+ "tableFrom": "gen2_chat_messages",
+ "tableTo": "gen2_chats",
+ "columnsFrom": [
+ "chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_chats": {
+ "name": "gen2_chats",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_chats_workspace_updated_idx": {
+ "name": "gen2_chats_workspace_updated_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_chats_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_chats_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_chats",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_chats_created_by_user_id_users_id_fk": {
+ "name": "gen2_chats_created_by_user_id_users_id_fk",
+ "tableFrom": "gen2_chats",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_superset_run_events": {
+ "name": "gen2_superset_run_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "run_id": {
+ "name": "run_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result": {
+ "name": "result",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_superset_run_events_run_created_idx": {
+ "name": "gen2_superset_run_events_run_created_idx",
+ "columns": [
+ {
+ "expression": "run_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_superset_run_events_run_id_gen2_superset_runs_id_fk": {
+ "name": "gen2_superset_run_events_run_id_gen2_superset_runs_id_fk",
+ "tableFrom": "gen2_superset_run_events",
+ "tableTo": "gen2_superset_runs",
+ "columnsFrom": [
+ "run_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_run_events_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_superset_run_events_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_superset_run_events",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_run_events_actor_id_users_id_fk": {
+ "name": "gen2_superset_run_events_actor_id_users_id_fk",
+ "tableFrom": "gen2_superset_run_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_superset_runs": {
+ "name": "gen2_superset_runs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "host_workspace_id": {
+ "name": "host_workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "host_terminal_id": {
+ "name": "host_terminal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "host_agent_session_id": {
+ "name": "host_agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "credential_provider",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_revision": {
+ "name": "credential_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "gen2_superset_run_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'creating'"
+ },
+ "lease_claimed": {
+ "name": "lease_claimed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "exit_reason": {
+ "name": "exit_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "recovery_count": {
+ "name": "recovery_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_superset_runs_workspace_idempotency_idx": {
+ "name": "gen2_superset_runs_workspace_idempotency_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "gen2_superset_runs_workspace_status_idx": {
+ "name": "gen2_superset_runs_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "gen2_superset_runs_chat_idx": {
+ "name": "gen2_superset_runs_chat_idx",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_superset_runs_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_superset_runs_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_runs_chat_id_gen2_chats_id_fk": {
+ "name": "gen2_superset_runs_chat_id_gen2_chats_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "gen2_chats",
+ "columnsFrom": [
+ "chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_runs_created_by_users_id_fk": {
+ "name": "gen2_superset_runs_created_by_users_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "gen2_superset_runs_connection_id_provider_credentials_id_fk": {
+ "name": "gen2_superset_runs_connection_id_provider_credentials_id_fk",
+ "tableFrom": "gen2_superset_runs",
+ "tableTo": "provider_credentials",
+ "columnsFrom": [
+ "connection_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_workspace_members": {
+ "name": "gen2_workspace_members",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "gen2_workspace_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'editor'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_workspace_members_user_idx": {
+ "name": "gen2_workspace_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_workspace_members_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_workspace_members_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_workspace_members",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gen2_workspace_members_user_id_users_id_fk": {
+ "name": "gen2_workspace_members_user_id_users_id_fk",
+ "tableFrom": "gen2_workspace_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "gen2_workspace_members_workspace_id_user_id_pk": {
+ "name": "gen2_workspace_members_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_workspaces": {
+ "name": "gen2_workspaces",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "gen2_workspace_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "sandbox_id": {
+ "name": "sandbox_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_token_hash": {
+ "name": "active_invite_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_created_by_user_id": {
+ "name": "active_invite_created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_role": {
+ "name": "active_invite_role",
+ "type": "gen2_workspace_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_created_at": {
+ "name": "active_invite_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_invite_expires_at": {
+ "name": "active_invite_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_installation_id": {
+ "name": "github_installation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository": {
+ "name": "repository",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_private": {
+ "name": "repository_private",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "default_branch": {
+ "name": "default_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_workspaces_owner_idx": {
+ "name": "gen2_workspaces_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "gen2_workspaces_active_invite_token_hash_idx": {
+ "name": "gen2_workspaces_active_invite_token_hash_idx",
+ "columns": [
+ {
+ "expression": "active_invite_token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_workspaces_owner_id_users_id_fk": {
+ "name": "gen2_workspaces_owner_id_users_id_fk",
+ "tableFrom": "gen2_workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "gen2_workspaces_active_invite_created_by_user_id_users_id_fk": {
+ "name": "gen2_workspaces_active_invite_created_by_user_id_users_id_fk",
+ "tableFrom": "gen2_workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "active_invite_created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gen2_yjs_documents": {
+ "name": "gen2_yjs_documents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'main'"
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "update_base64": {
+ "name": "update_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state_vector_base64": {
+ "name": "state_vector_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_contents": {
+ "name": "filesystem_contents",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_conflict": {
+ "name": "has_conflict",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "conflict_filesystem_revision": {
+ "name": "conflict_filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_detected_at": {
+ "name": "conflict_detected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "gen2_yjs_documents_workspace_worktree_path_idx": {
+ "name": "gen2_yjs_documents_workspace_worktree_path_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "worktree_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gen2_yjs_documents_workspace_id_gen2_workspaces_id_fk": {
+ "name": "gen2_yjs_documents_workspace_id_gen2_workspaces_id_fk",
+ "tableFrom": "gen2_yjs_documents",
+ "tableTo": "gen2_workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_connections": {
+ "name": "github_connections",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "encrypted_access_token": {
+ "name": "encrypted_access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_refresh_token": {
+ "name": "encrypted_refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'bearer'"
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "github_connections_access_expiry_idx": {
+ "name": "github_connections_access_expiry_idx",
+ "columns": [
+ {
+ "expression": "access_token_expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "github_connections_user_id_users_id_fk": {
+ "name": "github_connections_user_id_users_id_fk",
+ "tableFrom": "github_connections",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_issue_assignments": {
+ "name": "github_issue_assignments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_number": {
+ "name": "issue_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_issue_id": {
+ "name": "github_issue_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "github_issue_assignments_repository_issue_idx": {
+ "name": "github_issue_assignments_repository_issue_idx",
+ "columns": [
+ {
+ "expression": "github_repository_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "issue_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "github_issue_assignments_session_idx": {
+ "name": "github_issue_assignments_session_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "github_issue_assignments_workspace_idx": {
+ "name": "github_issue_assignments_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "github_issue_assignments_workspace_id_workspaces_id_fk": {
+ "name": "github_issue_assignments_workspace_id_workspaces_id_fk",
+ "tableFrom": "github_issue_assignments",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "github_issue_assignments_session_id_agent_sessions_id_fk": {
+ "name": "github_issue_assignments_session_id_agent_sessions_id_fk",
+ "tableFrom": "github_issue_assignments",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.mobile_push_tokens": {
+ "name": "mobile_push_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expo_push_token": {
+ "name": "expo_push_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "mobile_platform",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "device_id": {
+ "name": "device_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_seen_at": {
+ "name": "last_seen_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": {
+ "mobile_push_tokens_token_idx": {
+ "name": "mobile_push_tokens_token_idx",
+ "columns": [
+ {
+ "expression": "expo_push_token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "mobile_push_tokens_user_idx": {
+ "name": "mobile_push_tokens_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mobile_push_tokens_user_id_users_id_fk": {
+ "name": "mobile_push_tokens_user_id_users_id_fk",
+ "tableFrom": "mobile_push_tokens",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_feature_overrides": {
+ "name": "organization_feature_overrides",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "organization_feature_overrides_organization_id_organizations_id_fk": {
+ "name": "organization_feature_overrides_organization_id_organizations_id_fk",
+ "tableFrom": "organization_feature_overrides",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_feature_overrides_created_by_users_id_fk": {
+ "name": "organization_feature_overrides_created_by_users_id_fk",
+ "tableFrom": "organization_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "organization_feature_overrides_organization_id_feature_pk": {
+ "name": "organization_feature_overrides_organization_id_feature_pk",
+ "columns": [
+ "organization_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_members": {
+ "name": "organization_members",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "organization_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organization_members_user_idx": {
+ "name": "organization_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organization_members_organization_id_organizations_id_fk": {
+ "name": "organization_members_organization_id_organizations_id_fk",
+ "tableFrom": "organization_members",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_members_user_id_users_id_fk": {
+ "name": "organization_members_user_id_users_id_fk",
+ "tableFrom": "organization_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "organization_members_organization_id_user_id_pk": {
+ "name": "organization_members_organization_id_user_id_pk",
+ "columns": [
+ "organization_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_subscriptions": {
+ "name": "organization_subscriptions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "organization_subscription_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_customer_id": {
+ "name": "provider_customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_subscription_id": {
+ "name": "provider_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_period_end": {
+ "name": "current_period_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "canceled_at": {
+ "name": "canceled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organization_subscriptions_org_idx": {
+ "name": "organization_subscriptions_org_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "organization_subscriptions_provider_idx": {
+ "name": "organization_subscriptions_provider_idx",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_subscription_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organization_subscriptions_organization_id_organizations_id_fk": {
+ "name": "organization_subscriptions_organization_id_organizations_id_fk",
+ "tableFrom": "organization_subscriptions",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "organization_subscriptions_plan_id_plans_id_fk": {
+ "name": "organization_subscriptions_plan_id_plans_id_fk",
+ "tableFrom": "organization_subscriptions",
+ "tableTo": "plans",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organizations": {
+ "name": "organizations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "organizations_slug_idx": {
+ "name": "organizations_slug_idx",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.page_views": {
+ "name": "page_views",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "referrer": {
+ "name": "referrer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ip_hash": {
+ "name": "ip_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "page_views_created_idx": {
+ "name": "page_views_created_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "page_views_user_created_idx": {
+ "name": "page_views_user_created_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "page_views_path_created_idx": {
+ "name": "page_views_path_created_idx",
+ "columns": [
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "page_views_user_id_users_id_fk": {
+ "name": "page_views_user_id_users_id_fk",
+ "tableFrom": "page_views",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.path_claims": {
+ "name": "path_claims",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path_glob": {
+ "name": "path_glob",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "intent": {
+ "name": "intent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "claim_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "path_claims_session_status_idx": {
+ "name": "path_claims_session_status_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "path_claims_expiry_idx": {
+ "name": "path_claims_expiry_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "path_claims_session_id_agent_sessions_id_fk": {
+ "name": "path_claims_session_id_agent_sessions_id_fk",
+ "tableFrom": "path_claims",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan_entitlements": {
+ "name": "plan_entitlements",
+ "schema": "",
+ "columns": {
+ "plan_id": {
+ "name": "plan_id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "plan_entitlements_plan_id_plans_id_fk": {
+ "name": "plan_entitlements_plan_id_plans_id_fk",
+ "tableFrom": "plan_entitlements",
+ "tableTo": "plans",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "plan_entitlements_plan_id_feature_pk": {
+ "name": "plan_entitlements_plan_id_feature_pk",
+ "columns": [
+ "plan_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plans": {
+ "name": "plans",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "subscription_plan",
+ "typeSchema": "public",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.provider_credential_events": {
+ "name": "provider_credential_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "credential_provider",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result": {
+ "name": "result",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "provider_credential_events_credential_created_idx": {
+ "name": "provider_credential_events_credential_created_idx",
+ "columns": [
+ {
+ "expression": "credential_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credential_events_actor_created_idx": {
+ "name": "provider_credential_events_actor_created_idx",
+ "columns": [
+ {
+ "expression": "actor_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "provider_credential_events_actor_id_users_id_fk": {
+ "name": "provider_credential_events_actor_id_users_id_fk",
+ "tableFrom": "provider_credential_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "provider_credential_events_workspace_id_workspaces_id_fk": {
+ "name": "provider_credential_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "provider_credential_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.provider_credential_runs": {
+ "name": "provider_credential_runs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surface": {
+ "name": "surface",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ref": {
+ "name": "ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heartbeat_at": {
+ "name": "heartbeat_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": {
+ "provider_credential_runs_credential_idx": {
+ "name": "provider_credential_runs_credential_idx",
+ "columns": [
+ {
+ "expression": "credential_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credential_runs_ref_idx": {
+ "name": "provider_credential_runs_ref_idx",
+ "columns": [
+ {
+ "expression": "ref",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "provider_credential_runs_user_id_users_id_fk": {
+ "name": "provider_credential_runs_user_id_users_id_fk",
+ "tableFrom": "provider_credential_runs",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.provider_credentials": {
+ "name": "provider_credentials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "scope_type": {
+ "name": "scope_type",
+ "type": "credential_scope_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "credential_provider",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_type": {
+ "name": "credential_type",
+ "type": "credential_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "priority_order": {
+ "name": "priority_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "encrypted_api_key": {
+ "name": "encrypted_api_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_access_token": {
+ "name": "encrypted_access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_refresh_token": {
+ "name": "encrypted_refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "endpoint_url": {
+ "name": "endpoint_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "aws_role_arn": {
+ "name": "aws_role_arn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_connected": {
+ "name": "is_connected",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_four": {
+ "name": "last_four",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "provider_credential_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "provider_subject_hash": {
+ "name": "provider_subject_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "encrypted_material": {
+ "name": "encrypted_material",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_refreshed_at": {
+ "name": "last_refreshed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "connected_via": {
+ "name": "connected_via",
+ "type": "credential_connected_via",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "allow_in_shared_workspaces": {
+ "name": "allow_in_shared_workspaces",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "provider_credentials_scope_provider_type_idx": {
+ "name": "provider_credentials_scope_provider_type_idx",
+ "columns": [
+ {
+ "expression": "scope_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scope_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "credential_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credentials_scope_provider_priority_idx": {
+ "name": "provider_credentials_scope_provider_priority_idx",
+ "columns": [
+ {
+ "expression": "scope_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scope_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "priority_order",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "provider_credentials_status_idx": {
+ "name": "provider_credentials_status_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "provider_credentials_created_by_users_id_fk": {
+ "name": "provider_credentials_created_by_users_id_fk",
+ "tableFrom": "provider_credentials",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.published_branches": {
+ "name": "published_branches",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "published_by": {
+ "name": "published_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "branch_name": {
+ "name": "branch_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "publication_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "source_head_sha": {
+ "name": "source_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "commit_sha": {
+ "name": "commit_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository_id": {
+ "name": "repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "remote_ref": {
+ "name": "remote_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "html_url": {
+ "name": "html_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pull_request_number": {
+ "name": "pull_request_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pull_request_url": {
+ "name": "pull_request_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "request_id": {
+ "name": "request_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "published_at": {
+ "name": "published_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "published_branches_workspace_name_idx": {
+ "name": "published_branches_workspace_name_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "branch_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "published_branches_workspace_request_idx": {
+ "name": "published_branches_workspace_request_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "request_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "published_branches_workspace_status_idx": {
+ "name": "published_branches_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "published_branches_workspace_id_workspaces_id_fk": {
+ "name": "published_branches_workspace_id_workspaces_id_fk",
+ "tableFrom": "published_branches",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "published_branches_published_by_users_id_fk": {
+ "name": "published_branches_published_by_users_id_fk",
+ "tableFrom": "published_branches",
+ "tableTo": "users",
+ "columnsFrom": [
+ "published_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.runtime_hosts": {
+ "name": "runtime_hosts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "runtime_address": {
+ "name": "runtime_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifecycle_state": {
+ "name": "lifecycle_state",
+ "type": "runtime_host_lifecycle",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'provisioning'"
+ },
+ "max_workspace_slots": {
+ "name": "max_workspace_slots",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 4
+ },
+ "free_workspace_slots": {
+ "name": "free_workspace_slots",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 4
+ },
+ "image_version": {
+ "name": "image_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_heartbeat_at": {
+ "name": "last_heartbeat_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "draining_at": {
+ "name": "draining_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "runtime_hosts_provider_id_idx": {
+ "name": "runtime_hosts_provider_id_idx",
+ "columns": [
+ {
+ "expression": "provider_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "runtime_hosts_runtime_address_idx": {
+ "name": "runtime_hosts_runtime_address_idx",
+ "columns": [
+ {
+ "expression": "runtime_address",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "runtime_hosts_capacity_idx": {
+ "name": "runtime_hosts_capacity_idx",
+ "columns": [
+ {
+ "expression": "lifecycle_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "free_workspace_slots",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sandbox_runtime_intervals": {
+ "name": "sandbox_runtime_intervals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ended_at": {
+ "name": "ended_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "sandbox_runtime_intervals_user_open_idx": {
+ "name": "sandbox_runtime_intervals_user_open_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "ended_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "sandbox_runtime_intervals_workspace_open_idx": {
+ "name": "sandbox_runtime_intervals_workspace_open_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "ended_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "sandbox_runtime_intervals_user_id_users_id_fk": {
+ "name": "sandbox_runtime_intervals_user_id_users_id_fk",
+ "tableFrom": "sandbox_runtime_intervals",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sandbox_runtime_intervals_workspace_id_workspaces_id_fk": {
+ "name": "sandbox_runtime_intervals_workspace_id_workspaces_id_fk",
+ "tableFrom": "sandbox_runtime_intervals",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chat_invites": {
+ "name": "shared_chat_invites",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "shared_chat_id": {
+ "name": "shared_chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_token": {
+ "name": "encrypted_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_by": {
+ "name": "accepted_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chat_invites_token_hash_idx": {
+ "name": "shared_chat_invites_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "shared_chat_invites_room_idx": {
+ "name": "shared_chat_invites_room_idx",
+ "columns": [
+ {
+ "expression": "shared_chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chat_invites_shared_chat_id_shared_chats_id_fk": {
+ "name": "shared_chat_invites_shared_chat_id_shared_chats_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "shared_chats",
+ "columnsFrom": [
+ "shared_chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_invites_created_by_users_id_fk": {
+ "name": "shared_chat_invites_created_by_users_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_invites_accepted_by_users_id_fk": {
+ "name": "shared_chat_invites_accepted_by_users_id_fk",
+ "tableFrom": "shared_chat_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "accepted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chat_members": {
+ "name": "shared_chat_members",
+ "schema": "",
+ "columns": {
+ "shared_chat_id": {
+ "name": "shared_chat_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chat_members_user_idx": {
+ "name": "shared_chat_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chat_members_shared_chat_id_shared_chats_id_fk": {
+ "name": "shared_chat_members_shared_chat_id_shared_chats_id_fk",
+ "tableFrom": "shared_chat_members",
+ "tableTo": "shared_chats",
+ "columnsFrom": [
+ "shared_chat_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chat_members_user_id_users_id_fk": {
+ "name": "shared_chat_members_user_id_users_id_fk",
+ "tableFrom": "shared_chat_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "shared_chat_members_shared_chat_id_user_id_pk": {
+ "name": "shared_chat_members_shared_chat_id_user_id_pk",
+ "columns": [
+ "shared_chat_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shared_chats": {
+ "name": "shared_chats",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_chats_conversation_idx": {
+ "name": "shared_chats_conversation_idx",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "shared_chats_owner_updated_idx": {
+ "name": "shared_chats_owner_updated_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_chats_conversation_id_conversations_id_fk": {
+ "name": "shared_chats_conversation_id_conversations_id_fk",
+ "tableFrom": "shared_chats",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_chats_owner_id_users_id_fk": {
+ "name": "shared_chats_owner_id_users_id_fk",
+ "tableFrom": "shared_chats",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_compute_usage": {
+ "name": "user_compute_usage",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "minutes_used": {
+ "name": "minutes_used",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_compute_usage_user_id_users_id_fk": {
+ "name": "user_compute_usage_user_id_users_id_fk",
+ "tableFrom": "user_compute_usage",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_environment_variables": {
+ "name": "user_environment_variables",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_value": {
+ "name": "encrypted_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key_version": {
+ "name": "key_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "last_four": {
+ "name": "last_four",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_environment_variables_user_name_idx": {
+ "name": "user_environment_variables_user_name_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_environment_variables_user_updated_idx": {
+ "name": "user_environment_variables_user_updated_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_environment_variables_user_id_users_id_fk": {
+ "name": "user_environment_variables_user_id_users_id_fk",
+ "tableFrom": "user_environment_variables",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_feature_overrides": {
+ "name": "user_feature_overrides",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "feature_key",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_feature_overrides_user_idx": {
+ "name": "user_feature_overrides_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_feature_overrides_organization_id_organizations_id_fk": {
+ "name": "user_feature_overrides_organization_id_organizations_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_feature_overrides_user_id_users_id_fk": {
+ "name": "user_feature_overrides_user_id_users_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_feature_overrides_created_by_users_id_fk": {
+ "name": "user_feature_overrides_created_by_users_id_fk",
+ "tableFrom": "user_feature_overrides",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "user_feature_overrides_organization_id_user_id_feature_pk": {
+ "name": "user_feature_overrides_organization_id_user_id_feature_pk",
+ "columns": [
+ "organization_id",
+ "user_id",
+ "feature"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.users": {
+ "name": "users",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "github_user_id": {
+ "name": "github_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "google_user_id": {
+ "name": "google_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "clerk_user_id": {
+ "name": "clerk_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "login": {
+ "name": "login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password_hash": {
+ "name": "password_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avatar_url": {
+ "name": "avatar_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_admin": {
+ "name": "is_admin",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "users_github_user_id_idx": {
+ "name": "users_github_user_id_idx",
+ "columns": [
+ {
+ "expression": "github_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_google_user_id_idx": {
+ "name": "users_google_user_id_idx",
+ "columns": [
+ {
+ "expression": "google_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_clerk_user_id_idx": {
+ "name": "users_clerk_user_id_idx",
+ "columns": [
+ {
+ "expression": "clerk_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_login_idx": {
+ "name": "users_login_idx",
+ "columns": [
+ {
+ "expression": "login",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channel_messages": {
+ "name": "workspace_channel_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_kind": {
+ "name": "author_kind",
+ "type": "channel_message_author_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_label": {
+ "name": "author_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_session_id": {
+ "name": "agent_session_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mentions": {
+ "name": "mentions",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "mentions_agent": {
+ "name": "mentions_agent",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channel_messages_channel_idx": {
+ "name": "workspace_channel_messages_channel_idx",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_channel_messages_workspace_idx": {
+ "name": "workspace_channel_messages_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channel_messages_channel_id_workspace_channels_id_fk": {
+ "name": "workspace_channel_messages_channel_id_workspace_channels_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "workspace_channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_workspace_id_workspaces_id_fk": {
+ "name": "workspace_channel_messages_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_author_id_users_id_fk": {
+ "name": "workspace_channel_messages_author_id_users_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_messages_agent_session_id_agent_sessions_id_fk": {
+ "name": "workspace_channel_messages_agent_session_id_agent_sessions_id_fk",
+ "tableFrom": "workspace_channel_messages",
+ "tableTo": "agent_sessions",
+ "columnsFrom": [
+ "agent_session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channel_reads": {
+ "name": "workspace_channel_reads",
+ "schema": "",
+ "columns": {
+ "channel_id": {
+ "name": "channel_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_read_at": {
+ "name": "last_read_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channel_reads_user_idx": {
+ "name": "workspace_channel_reads_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channel_reads_channel_id_workspace_channels_id_fk": {
+ "name": "workspace_channel_reads_channel_id_workspace_channels_id_fk",
+ "tableFrom": "workspace_channel_reads",
+ "tableTo": "workspace_channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channel_reads_user_id_users_id_fk": {
+ "name": "workspace_channel_reads_user_id_users_id_fk",
+ "tableFrom": "workspace_channel_reads",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_channel_reads_channel_id_user_id_pk": {
+ "name": "workspace_channel_reads_channel_id_user_id_pk",
+ "columns": [
+ "channel_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_channels": {
+ "name": "workspace_channels",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "topic": {
+ "name": "topic",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_access": {
+ "name": "agent_access",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_channels_workspace_slug_idx": {
+ "name": "workspace_channels_workspace_slug_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_channels_workspace_idx": {
+ "name": "workspace_channels_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "archived_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_channels_workspace_id_workspaces_id_fk": {
+ "name": "workspace_channels_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_channels",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_channels_created_by_users_id_fk": {
+ "name": "workspace_channels_created_by_users_id_fk",
+ "tableFrom": "workspace_channels",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_leases": {
+ "name": "workspace_chat_leases",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "holder_id": {
+ "name": "holder_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lease_token": {
+ "name": "lease_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_leases_expiry_idx": {
+ "name": "workspace_chat_leases_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_leases_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_leases_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_leases",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_leases_holder_id_users_id_fk": {
+ "name": "workspace_chat_leases_holder_id_users_id_fk",
+ "tableFrom": "workspace_chat_leases",
+ "tableTo": "users",
+ "columnsFrom": [
+ "holder_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_chat_leases_workspace_id_chat_id_pk": {
+ "name": "workspace_chat_leases_workspace_id_chat_id_pk",
+ "columns": [
+ "workspace_id",
+ "chat_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_participants": {
+ "name": "workspace_chat_participants",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_participants_expiry_idx": {
+ "name": "workspace_chat_participants_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_participants_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_participants_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_participants",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_participants_user_id_users_id_fk": {
+ "name": "workspace_chat_participants_user_id_users_id_fk",
+ "tableFrom": "workspace_chat_participants",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_chat_participants_workspace_id_chat_id_user_id_client_id_pk": {
+ "name": "workspace_chat_participants_workspace_id_chat_id_user_id_client_id_pk",
+ "columns": [
+ "workspace_id",
+ "chat_id",
+ "user_id",
+ "client_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_chat_prompt_receipts": {
+ "name": "workspace_chat_prompt_receipts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_message_id": {
+ "name": "client_message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attachments": {
+ "name": "attachments",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "effort": {
+ "name": "effort",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_chat_prompt_receipts_client_message_idx": {
+ "name": "workspace_chat_prompt_receipts_client_message_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "client_message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_chat_prompt_receipts_chat_created_idx": {
+ "name": "workspace_chat_prompt_receipts_chat_created_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_chat_prompt_receipts_workspace_id_workspaces_id_fk": {
+ "name": "workspace_chat_prompt_receipts_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_chat_prompt_receipts",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_chat_prompt_receipts_author_id_users_id_fk": {
+ "name": "workspace_chat_prompt_receipts_author_id_users_id_fk",
+ "tableFrom": "workspace_chat_prompt_receipts",
+ "tableTo": "users",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_events": {
+ "name": "workspace_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence": {
+ "name": "sequence",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_events_sequence_idx": {
+ "name": "workspace_events_sequence_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sequence",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_events_workspace_id_workspaces_id_fk": {
+ "name": "workspace_events_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_events",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_events_actor_id_users_id_fk": {
+ "name": "workspace_events_actor_id_users_id_fk",
+ "tableFrom": "workspace_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "actor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_invites": {
+ "name": "workspace_invites",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "invitee_email": {
+ "name": "invitee_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invitee_login": {
+ "name": "invitee_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_role": {
+ "name": "access_role",
+ "type": "workspace_access_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'viewer'"
+ },
+ "allow_link": {
+ "name": "allow_link",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_by": {
+ "name": "accepted_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_invites_token_hash_idx": {
+ "name": "workspace_invites_token_hash_idx",
+ "columns": [
+ {
+ "expression": "token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_invites_workspace_idx": {
+ "name": "workspace_invites_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_invites_workspace_id_workspaces_id_fk": {
+ "name": "workspace_invites_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_invites_created_by_users_id_fk": {
+ "name": "workspace_invites_created_by_users_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_invites_accepted_by_users_id_fk": {
+ "name": "workspace_invites_accepted_by_users_id_fk",
+ "tableFrom": "workspace_invites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "accepted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_member_statuses": {
+ "name": "workspace_member_statuses",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emoji": {
+ "name": "emoji",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "headline": {
+ "name": "headline",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_member_statuses_workspace_idx": {
+ "name": "workspace_member_statuses_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_member_statuses_workspace_id_workspaces_id_fk": {
+ "name": "workspace_member_statuses_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_member_statuses",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_member_statuses_user_id_users_id_fk": {
+ "name": "workspace_member_statuses_user_id_users_id_fk",
+ "tableFrom": "workspace_member_statuses",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_member_statuses_workspace_id_user_id_pk": {
+ "name": "workspace_member_statuses_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_members": {
+ "name": "workspace_members",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "member_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "access_role": {
+ "name": "access_role",
+ "type": "workspace_access_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'viewer'"
+ },
+ "can_terminal": {
+ "name": "can_terminal",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "can_merge": {
+ "name": "can_merge",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_members_user_idx": {
+ "name": "workspace_members_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_members_workspace_id_workspaces_id_fk": {
+ "name": "workspace_members_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_members",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_members_user_id_users_id_fk": {
+ "name": "workspace_members_user_id_users_id_fk",
+ "tableFrom": "workspace_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_members_workspace_id_user_id_pk": {
+ "name": "workspace_members_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_runtime_assignments": {
+ "name": "workspace_runtime_assignments",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "host_id": {
+ "name": "host_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "generation": {
+ "name": "generation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "fencing_token": {
+ "name": "fencing_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "disk_id": {
+ "name": "disk_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "disk_lun": {
+ "name": "disk_lun",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "runtime_state": {
+ "name": "runtime_state",
+ "type": "workspace_runtime_assignment_state",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'assigned'"
+ },
+ "last_used_at": {
+ "name": "last_used_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": {
+ "workspace_runtime_assignments_host_state_idx": {
+ "name": "workspace_runtime_assignments_host_state_idx",
+ "columns": [
+ {
+ "expression": "host_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "runtime_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_runtime_assignments_state_updated_idx": {
+ "name": "workspace_runtime_assignments_state_updated_idx",
+ "columns": [
+ {
+ "expression": "runtime_state",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_runtime_assignments_workspace_id_workspaces_id_fk": {
+ "name": "workspace_runtime_assignments_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_runtime_assignments",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_runtime_assignments_host_id_runtime_hosts_id_fk": {
+ "name": "workspace_runtime_assignments_host_id_runtime_hosts_id_fk",
+ "tableFrom": "workspace_runtime_assignments",
+ "tableTo": "runtime_hosts",
+ "columnsFrom": [
+ "host_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_runtimes": {
+ "name": "workspace_runtimes",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "sandbox_id": {
+ "name": "sandbox_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "backend": {
+ "name": "backend",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'firecracker'"
+ },
+ "status": {
+ "name": "status",
+ "type": "sandbox_runtime_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'provisioning'"
+ },
+ "provisioned_head_sha": {
+ "name": "provisioned_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "snapshot_ref": {
+ "name": "snapshot_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_heartbeat_at": {
+ "name": "last_heartbeat_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hibernated_at": {
+ "name": "hibernated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provisioned_at": {
+ "name": "provisioned_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stopped_at": {
+ "name": "stopped_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_runtimes_status_updated_idx": {
+ "name": "workspace_runtimes_status_updated_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_runtimes_workspace_id_workspaces_id_fk": {
+ "name": "workspace_runtimes_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_runtimes",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "workspace_runtimes_sandbox_id_unique": {
+ "name": "workspace_runtimes_sandbox_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "sandbox_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_snapshots": {
+ "name": "workspace_snapshots",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "snapshot": {
+ "name": "snapshot",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_bytes": {
+ "name": "total_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_snapshots_updated_idx": {
+ "name": "workspace_snapshots_updated_idx",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_snapshots_workspace_id_workspaces_id_fk": {
+ "name": "workspace_snapshots_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_snapshots",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_state_documents": {
+ "name": "workspace_state_documents",
+ "schema": "",
+ "columns": {
+ "document_name": {
+ "name": "document_name",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state": {
+ "name": "state",
+ "type": "bytea",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_state_documents_workspace_idx": {
+ "name": "workspace_state_documents_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_state_documents_workspace_id_workspaces_id_fk": {
+ "name": "workspace_state_documents_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_state_documents",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspaces": {
+ "name": "workspaces",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "github_installation_id": {
+ "name": "github_installation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "github_repository_id": {
+ "name": "github_repository_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repository": {
+ "name": "repository",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repository_visibility": {
+ "name": "repository_visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "default_branch": {
+ "name": "default_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "base_sha": {
+ "name": "base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "workspace_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "last_activity_at": {
+ "name": "last_activity_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "hibernate_at": {
+ "name": "hibernate_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspaces_owner_idx": {
+ "name": "workspaces_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_organization_idx": {
+ "name": "workspaces_organization_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_repository_idx": {
+ "name": "workspaces_repository_idx",
+ "columns": [
+ {
+ "expression": "github_repository_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_status_expiry_idx": {
+ "name": "workspaces_status_expiry_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_deleted_idx": {
+ "name": "workspaces_deleted_idx",
+ "columns": [
+ {
+ "expression": "deleted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspaces_owner_id_users_id_fk": {
+ "name": "workspaces_owner_id_users_id_fk",
+ "tableFrom": "workspaces",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "workspaces_organization_id_organizations_id_fk": {
+ "name": "workspaces_organization_id_organizations_id_fk",
+ "tableFrom": "workspaces",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.worktrees": {
+ "name": "worktrees",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "worktree_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "worktree_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "review_head_sha": {
+ "name": "review_head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_base_sha": {
+ "name": "review_base_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_diff_digest": {
+ "name": "review_diff_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_by": {
+ "name": "reviewed_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_at": {
+ "name": "reviewed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "merged_at": {
+ "name": "merged_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "discarded_at": {
+ "name": "discarded_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "worktrees_workspace_name_idx": {
+ "name": "worktrees_workspace_name_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "worktrees_workspace_status_idx": {
+ "name": "worktrees_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "worktrees_workspace_id_workspaces_id_fk": {
+ "name": "worktrees_workspace_id_workspaces_id_fk",
+ "tableFrom": "worktrees",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "worktrees_reviewed_by_users_id_fk": {
+ "name": "worktrees_reviewed_by_users_id_fk",
+ "tableFrom": "worktrees",
+ "tableTo": "users",
+ "columnsFrom": [
+ "reviewed_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.yjs_snapshots": {
+ "name": "yjs_snapshots",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "worktree_id": {
+ "name": "worktree_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "update_base64": {
+ "name": "update_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state_vector_base64": {
+ "name": "state_vector_base64",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_contents": {
+ "name": "filesystem_contents",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "filesystem_revision": {
+ "name": "filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_conflict": {
+ "name": "has_conflict",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "conflict_filesystem_revision": {
+ "name": "conflict_filesystem_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_detected_at": {
+ "name": "conflict_detected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolved_at": {
+ "name": "conflict_resolved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolved_by": {
+ "name": "conflict_resolved_by",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conflict_resolution": {
+ "name": "conflict_resolution",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "yjs_snapshots_worktree_path_idx": {
+ "name": "yjs_snapshots_worktree_path_idx",
+ "columns": [
+ {
+ "expression": "worktree_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "yjs_snapshots_worktree_id_worktrees_id_fk": {
+ "name": "yjs_snapshots_worktree_id_worktrees_id_fk",
+ "tableFrom": "yjs_snapshots",
+ "tableTo": "worktrees",
+ "columnsFrom": [
+ "worktree_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "yjs_snapshots_conflict_resolved_by_users_id_fk": {
+ "name": "yjs_snapshots_conflict_resolved_by_users_id_fk",
+ "tableFrom": "yjs_snapshots",
+ "tableTo": "users",
+ "columnsFrom": [
+ "conflict_resolved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {
+ "public.access_request_status": {
+ "name": "access_request_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "invited",
+ "declined"
+ ]
+ },
+ "public.agent_brief_status": {
+ "name": "agent_brief_status",
+ "schema": "public",
+ "values": [
+ "planning",
+ "active",
+ "blocked",
+ "paused",
+ "done"
+ ]
+ },
+ "public.agent_session_import_status": {
+ "name": "agent_session_import_status",
+ "schema": "public",
+ "values": [
+ "storing",
+ "stored",
+ "restoring",
+ "ready",
+ "launching",
+ "active",
+ "failed",
+ "deleted"
+ ]
+ },
+ "public.agent_session_kind": {
+ "name": "agent_session_kind",
+ "schema": "public",
+ "values": [
+ "managed",
+ "cli"
+ ]
+ },
+ "public.agent_session_status": {
+ "name": "agent_session_status",
+ "schema": "public",
+ "values": [
+ "idle",
+ "running",
+ "waiting",
+ "completed",
+ "interrupted",
+ "failed"
+ ]
+ },
+ "public.agent_turn_status": {
+ "name": "agent_turn_status",
+ "schema": "public",
+ "values": [
+ "queued",
+ "running",
+ "completed",
+ "interrupted",
+ "failed"
+ ]
+ },
+ "public.brain_entry_kind": {
+ "name": "brain_entry_kind",
+ "schema": "public",
+ "values": [
+ "decision",
+ "attempt",
+ "dead_end",
+ "finding",
+ "convention",
+ "handoff"
+ ]
+ },
+ "public.brain_overlap_kind": {
+ "name": "brain_overlap_kind",
+ "schema": "public",
+ "values": [
+ "duplicate_intent",
+ "file_overlap",
+ "claim_contest"
+ ]
+ },
+ "public.brain_overlap_status": {
+ "name": "brain_overlap_status",
+ "schema": "public",
+ "values": [
+ "open",
+ "acknowledged",
+ "resolved"
+ ]
+ },
+ "public.channel_message_author_kind": {
+ "name": "channel_message_author_kind",
+ "schema": "public",
+ "values": [
+ "member",
+ "agent",
+ "system"
+ ]
+ },
+ "public.claim_status": {
+ "name": "claim_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "released",
+ "expired",
+ "contested"
+ ]
+ },
+ "public.claude_connection_session_status": {
+ "name": "claude_connection_session_status",
+ "schema": "public",
+ "values": [
+ "starting",
+ "awaiting_code",
+ "exchanging",
+ "connected",
+ "failed"
+ ]
+ },
+ "public.cli_client_type": {
+ "name": "cli_client_type",
+ "schema": "public",
+ "values": [
+ "cli",
+ "mobile"
+ ]
+ },
+ "public.cli_device_authorization_status": {
+ "name": "cli_device_authorization_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "approved",
+ "denied"
+ ]
+ },
+ "public.credential_connected_via": {
+ "name": "credential_connected_via",
+ "schema": "public",
+ "values": [
+ "browser",
+ "cli",
+ "api_key"
+ ]
+ },
+ "public.credential_provider": {
+ "name": "credential_provider",
+ "schema": "public",
+ "values": [
+ "anthropic",
+ "openai",
+ "bedrock",
+ "azure_foundry",
+ "cursor",
+ "custom"
+ ]
+ },
+ "public.credential_scope_type": {
+ "name": "credential_scope_type",
+ "schema": "public",
+ "values": [
+ "USER",
+ "WORKSPACE"
+ ]
+ },
+ "public.credential_type": {
+ "name": "credential_type",
+ "schema": "public",
+ "values": [
+ "API_KEY",
+ "OAUTH_TOKEN",
+ "AWS_BEDROCK_ROLE",
+ "AZURE_ENDPOINT",
+ "HOSTED_CODEX_SUBSCRIPTION"
+ ]
+ },
+ "public.feature_key": {
+ "name": "feature_key",
+ "schema": "public",
+ "values": [
+ "hosted_codex_subscription"
+ ]
+ },
+ "public.feature_override_audit_action": {
+ "name": "feature_override_audit_action",
+ "schema": "public",
+ "values": [
+ "created",
+ "updated",
+ "deleted"
+ ]
+ },
+ "public.gen2_superset_run_status": {
+ "name": "gen2_superset_run_status",
+ "schema": "public",
+ "values": [
+ "creating",
+ "running",
+ "stopping",
+ "finished",
+ "failed",
+ "recovery_required"
+ ]
+ },
+ "public.gen2_workspace_role": {
+ "name": "gen2_workspace_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "editor",
+ "viewer"
+ ]
+ },
+ "public.gen2_workspace_status": {
+ "name": "gen2_workspace_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "provisioning",
+ "ready",
+ "failed",
+ "stopped",
+ "deleting"
+ ]
+ },
+ "public.member_role": {
+ "name": "member_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "member"
+ ]
+ },
+ "public.coordination_message_status": {
+ "name": "coordination_message_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "delivered",
+ "resolved"
+ ]
+ },
+ "public.mobile_platform": {
+ "name": "mobile_platform",
+ "schema": "public",
+ "values": [
+ "ios",
+ "android"
+ ]
+ },
+ "public.organization_role": {
+ "name": "organization_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "admin",
+ "billing_admin",
+ "member"
+ ]
+ },
+ "public.organization_subscription_status": {
+ "name": "organization_subscription_status",
+ "schema": "public",
+ "values": [
+ "trialing",
+ "active",
+ "past_due",
+ "canceled"
+ ]
+ },
+ "public.provider_credential_status": {
+ "name": "provider_credential_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "reauthorization_required",
+ "revoked",
+ "failed"
+ ]
+ },
+ "public.publication_status": {
+ "name": "publication_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "published",
+ "failed"
+ ]
+ },
+ "public.repository_restore_status": {
+ "name": "repository_restore_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "matched",
+ "restored",
+ "conflicted",
+ "unavailable",
+ "transcript_only"
+ ]
+ },
+ "public.runtime_host_lifecycle": {
+ "name": "runtime_host_lifecycle",
+ "schema": "public",
+ "values": [
+ "provisioning",
+ "ready",
+ "draining",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.sandbox_runtime_status": {
+ "name": "sandbox_runtime_status",
+ "schema": "public",
+ "values": [
+ "provisioning",
+ "ready",
+ "hibernated",
+ "stopping",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.session_continuation_mode": {
+ "name": "session_continuation_mode",
+ "schema": "public",
+ "values": [
+ "managed",
+ "native_resume"
+ ]
+ },
+ "public.subscription_plan": {
+ "name": "subscription_plan",
+ "schema": "public",
+ "values": [
+ "free",
+ "pro",
+ "team",
+ "enterprise"
+ ]
+ },
+ "public.workspace_access_role": {
+ "name": "workspace_access_role",
+ "schema": "public",
+ "values": [
+ "owner",
+ "co_steer",
+ "reviewer",
+ "viewer"
+ ]
+ },
+ "public.workspace_runtime_assignment_state": {
+ "name": "workspace_runtime_assignment_state",
+ "schema": "public",
+ "values": [
+ "assigned",
+ "starting",
+ "ready",
+ "draining",
+ "lost"
+ ]
+ },
+ "public.workspace_status": {
+ "name": "workspace_status",
+ "schema": "public",
+ "values": [
+ "pending",
+ "provisioning",
+ "ready",
+ "hibernated",
+ "stopping",
+ "stopped",
+ "failed"
+ ]
+ },
+ "public.worktree_kind": {
+ "name": "worktree_kind",
+ "schema": "public",
+ "values": [
+ "integration",
+ "agent"
+ ]
+ },
+ "public.worktree_status": {
+ "name": "worktree_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "frozen",
+ "merged",
+ "discarded"
+ ]
+ }
+ },
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/_journal.json b/packages/db/drizzle/meta/_journal.json
index e4d3c7996..7a2ecd171 100644
--- a/packages/db/drizzle/meta/_journal.json
+++ b/packages/db/drizzle/meta/_journal.json
@@ -400,6 +400,48 @@
"when": 1790556400000,
"tag": "0056_gen2_yjs_document_worktrees",
"breakpoints": true
+ },
+ {
+ "idx": 57,
+ "version": "7",
+ "when": 1790577333017,
+ "tag": "0057_sloppy_zodiak",
+ "breakpoints": true
+ },
+ {
+ "idx": 58,
+ "version": "7",
+ "when": 1790648560704,
+ "tag": "0058_milky_ultimates",
+ "breakpoints": true
+ },
+ {
+ "idx": 59,
+ "version": "7",
+ "when": 1790648571064,
+ "tag": "0059_flippant_zuras",
+ "breakpoints": true
+ },
+ {
+ "idx": 60,
+ "version": "7",
+ "when": 1790650475930,
+ "tag": "0060_empty_may_parker",
+ "breakpoints": true
+ },
+ {
+ "idx": 61,
+ "version": "7",
+ "when": 1790652246306,
+ "tag": "0061_bored_paladin",
+ "breakpoints": true
+ },
+ {
+ "idx": 62,
+ "version": "7",
+ "when": 1790652273853,
+ "tag": "0062_left_timeslip",
+ "breakpoints": true
}
]
-}
+}
\ No newline at end of file
diff --git a/packages/db/src/schema.ts b/packages/db/src/schema.ts
index 3ed9ac191..7825cd572 100644
--- a/packages/db/src/schema.ts
+++ b/packages/db/src/schema.ts
@@ -180,10 +180,15 @@ export const publicationStatus = pgEnum("publication_status", [
"published",
"failed",
]);
+/**
+ * Who a credential belongs to. There were once two spellings of "shared" —
+ * `WORKSPACE` for the older fallback key pool and `ORGANIZATION`, whose scope
+ * id was also a workspace id, for `--org` logins — so reading a row meant
+ * knowing which mechanism had written it. They are one scope now.
+ */
export const credentialScopeType = pgEnum("credential_scope_type", [
"USER",
"WORKSPACE",
- "ORGANIZATION",
]);
export const credentialProvider = pgEnum("credential_provider", [
"anthropic",
@@ -696,17 +701,19 @@ export const providerCredentials = pgTable(
onDelete: "set null",
}),
revokedAt: timestamp("revoked_at", { withTimezone: true }),
- sharingEnabled: boolean("sharing_enabled").default(false).notNull(),
- unavailableUntil: timestamp("unavailable_until", { withTimezone: true }),
// Provenance (see credentialConnectedVia). Nullable for pre-existing rows;
// the 0042 migration backfills them and code treats NULL conservatively
// (not workspace-eligible).
connectedVia: credentialConnectedVia("connected_via"),
- // Per-surface applicability — the isolation + opt-in-sharing toggles. Default
- // on so existing credentials keep working on both surfaces after deploy;
- // provider capability and the explicit toggle determine eligibility.
- enabledForRooms: boolean("enabled_for_rooms").default(true).notNull(),
- enabledForWorkspace: boolean("enabled_for_workspace")
+ // Whether this credential may fund a turn inside a workspace other people
+ // can see. It replaced `enabled_for_rooms` / `enabled_for_workspace`,
+ // which claimed to gate surfaces but were read on one path out of three —
+ // the subscription resolvers ignored them entirely, so the settings
+ // toggles changed a badge and nothing else. Where a credential *can* run
+ // is a property of the credential kind and belongs in the provider
+ // registry, not in a column; the only thing left for a member to decide
+ // is this one, which is about whose subscription gets spent.
+ allowInSharedWorkspaces: boolean("allow_in_shared_workspaces")
.default(true)
.notNull(),
...timestamps,
@@ -728,6 +735,53 @@ export const providerCredentials = pgTable(
],
);
+/**
+ * The seat a running turn holds on a provider credential.
+ *
+ * A subscription is one human seat: the provider runs one turn at a time on
+ * it. That used to be a mutable `unavailable_until` stamp on the credential
+ * row, set sixteen minutes ahead — with no reaper, so the stamp *was* the
+ * reaper. A turn that died without releasing blocked every other surface for
+ * a quarter of an hour, and because each executor claimed it differently
+ * (Gen 2 claimed it and then ignored a busy result; chat rooms hard-failed on
+ * one) the same lock meant different things depending on who asked.
+ *
+ * A row here is instead owned by a live run and refreshed as that run is
+ * polled. A run that stops polling stops holding the seat within
+ * `SEAT_STALE_AFTER_MS`, and `ref` names what holds it so a waiting turn can
+ * say so rather than reporting a bare failure.
+ *
+ * `credentialId` carries no foreign key because a seat can be taken on either
+ * credential store — `provider_credentials` or, until the browser login
+ * runtime is retired, `claude_connection_sessions`. An orphaned row is
+ * harmless: nothing resolves to that credential any more, and it ages out.
+ */
+export const providerCredentialRuns = pgTable(
+ "provider_credential_runs",
+ {
+ id: uuid("id").defaultRandom().primaryKey(),
+ credentialId: uuid("credential_id").notNull(),
+ userId: uuid("user_id")
+ .references(() => users.id, { onDelete: "cascade" })
+ .notNull(),
+ /** Which executor holds it: rooms, workspace or gen2. */
+ surface: text("surface").notNull(),
+ /** The run holding the seat — a reply id, turn session id or run id. */
+ ref: text("ref").notNull(),
+ /** Refreshed on every poll; staleness frees the seat. */
+ heartbeatAt: timestamp("heartbeat_at", { withTimezone: true })
+ .defaultNow()
+ .notNull(),
+ ...timestamps,
+ },
+ (table) => [
+ uniqueIndex("provider_credential_runs_credential_idx").on(
+ table.credentialId,
+ ),
+ index("provider_credential_runs_ref_idx").on(table.ref),
+ ],
+);
+
export const cliDeviceAuthorizations = pgTable(
"cli_device_authorizations",
{
@@ -2196,3 +2250,95 @@ export const gen2AgentTurns = pgTable(
index("gen2_agent_turns_chat_idx").on(table.chatId, table.createdAt),
],
);
+
+/**
+ * Durable mapping between a Gen 2 workspace and one Superset terminal-agent
+ * session, per docs/SUPERSET_AGENT_SESSION_PLAN.md. CoDev owns this row as
+ * the source of truth for identity, credential lease, and lifecycle state;
+ * Superset's own SQLite database is never queried for that state. No
+ * credential material is stored here -- `connectionId` points at the
+ * existing encrypted `provider_credentials` row and `credentialRevision` is
+ * a fingerprint only.
+ */
+export const gen2SupersetRunStatus = pgEnum("gen2_superset_run_status", [
+ "creating",
+ "running",
+ "stopping",
+ "finished",
+ "failed",
+ "recovery_required",
+]);
+
+export const gen2SupersetRuns = pgTable(
+ "gen2_superset_runs",
+ {
+ id: uuid("id").defaultRandom().primaryKey(),
+ workspaceId: uuid("workspace_id")
+ .references(() => gen2Workspaces.id, { onDelete: "cascade" })
+ .notNull(),
+ chatId: uuid("chat_id").references(() => gen2Chats.id, {
+ onDelete: "set null",
+ }),
+ createdBy: uuid("created_by")
+ .references(() => users.id, { onDelete: "restrict" })
+ .notNull(),
+ /** Superset owns worktree identity host-side; see gen2SupersetWorktreeIdSchema. */
+ worktreeId: text("worktree_id").notNull(),
+ hostWorkspaceId: text("host_workspace_id"),
+ hostTerminalId: text("host_terminal_id"),
+ hostAgentSessionId: text("host_agent_session_id"),
+ provider: credentialProvider("provider").notNull(),
+ connectionId: uuid("connection_id").references(
+ () => providerCredentials.id,
+ { onDelete: "set null" },
+ ),
+ credentialRevision: text("credential_revision"),
+ status: gen2SupersetRunStatus("status").default("creating").notNull(),
+ leaseClaimed: boolean("lease_claimed").default(false).notNull(),
+ exitReason: text("exit_reason"),
+ recoveryCount: integer("recovery_count").default(0).notNull(),
+ /** Caller-supplied key; a retry with the same key returns the same run. */
+ idempotencyKey: text("idempotency_key").notNull(),
+ lastError: text("last_error"),
+ ...timestamps,
+ },
+ (table) => [
+ uniqueIndex("gen2_superset_runs_workspace_idempotency_idx").on(
+ table.workspaceId,
+ table.idempotencyKey,
+ ),
+ index("gen2_superset_runs_workspace_status_idx").on(
+ table.workspaceId,
+ table.status,
+ ),
+ index("gen2_superset_runs_chat_idx").on(table.chatId, table.createdAt),
+ ],
+);
+
+/** Append-only audit trail for a Superset run's lease and lifecycle events. */
+export const gen2SupersetRunEvents = pgTable(
+ "gen2_superset_run_events",
+ {
+ id: uuid("id").defaultRandom().primaryKey(),
+ runId: uuid("run_id")
+ .references(() => gen2SupersetRuns.id, { onDelete: "cascade" })
+ .notNull(),
+ workspaceId: uuid("workspace_id")
+ .references(() => gen2Workspaces.id, { onDelete: "cascade" })
+ .notNull(),
+ actorId: uuid("actor_id").references(() => users.id, {
+ onDelete: "set null",
+ }),
+ type: text("type").notNull(),
+ result: text("result").notNull(),
+ createdAt: timestamp("created_at", { withTimezone: true })
+ .defaultNow()
+ .notNull(),
+ },
+ (table) => [
+ index("gen2_superset_run_events_run_created_idx").on(
+ table.runId,
+ table.createdAt,
+ ),
+ ],
+);
diff --git a/packages/shared-types/src/credentials.ts b/packages/shared-types/src/credentials.ts
index f37e89e8e..b6fa872b5 100644
--- a/packages/shared-types/src/credentials.ts
+++ b/packages/shared-types/src/credentials.ts
@@ -15,18 +15,14 @@ export const credentialTypeSchema = z.enum([
"AZURE_ENDPOINT",
"HOSTED_CODEX_SUBSCRIPTION",
]);
-export const credentialScopeTypeSchema = z.enum([
- "USER",
- "WORKSPACE",
- "ORGANIZATION",
-]);
+export const credentialScopeTypeSchema = z.enum(["USER", "WORKSPACE"]);
export const providerCredentialStatusSchema = z.enum([
"active",
"reauthorization_required",
"revoked",
"failed",
]);
-export const hostedCodexScopeTypeSchema = z.enum(["USER", "ORGANIZATION"]);
+export const hostedCodexScopeTypeSchema = z.enum(["USER", "WORKSPACE"]);
export type AuthProvider = z.infer;
export type CredentialType = z.infer;
diff --git a/services/orchestrator/src/backend/firecracker.rs b/services/orchestrator/src/backend/firecracker.rs
index c511dde6f..021379957 100644
--- a/services/orchestrator/src/backend/firecracker.rs
+++ b/services/orchestrator/src/backend/firecracker.rs
@@ -34,7 +34,9 @@ use crate::{
CodexExecStartRequest, CreateRequest, ExecRequest, ExecResponse, FileResponse, Instance,
PublicationExportRequest, PublicationExportResponse, RepositorySnapshot, Result,
RuntimeError, SessionRestoreBeginRequest, SessionRestoreChunkRequest,
- SessionRestoreFinalizeResponse, SupersetCreateEntryRequest, SupersetDeleteEntryRequest,
+ SessionRestoreFinalizeResponse, SupersetAgentInputRequest, SupersetAgentPollRequest,
+ SupersetAgentPollResponse, SupersetAgentRecoveryResponse, SupersetAgentStartRequest,
+ SupersetAgentStartResponse, SupersetCreateEntryRequest, SupersetDeleteEntryRequest,
SupersetMoveEntryRequest, TerminalInputRequest, TerminalPollRequest, TerminalPollResponse,
TerminalResizeRequest, TerminalStartRequest, WorktreeCheckpointRequest,
WorktreeCheckpointResponse, WorktreeCreateRequest, WorktreeMergeRequest,
@@ -942,6 +944,62 @@ impl FirecrackerBackend {
Ok(())
}
+ pub async fn start_superset_agent(
+ &self,
+ workspace_id: &str,
+ request: SupersetAgentStartRequest,
+ ) -> Result {
+ let machine = self.machine(workspace_id).await?;
+ let result = machine.guest.start_superset_agent(&request).await?;
+ self.mark_activity(&machine);
+ Ok(result)
+ }
+
+ pub async fn input_superset_agent(
+ &self,
+ workspace_id: &str,
+ agent_id: &str,
+ request: SupersetAgentInputRequest,
+ ) -> Result<()> {
+ let machine = self.machine(workspace_id).await?;
+ machine
+ .guest
+ .input_superset_agent(agent_id, &request)
+ .await?;
+ self.mark_activity(&machine);
+ Ok(())
+ }
+
+ pub async fn poll_superset_agent(
+ &self,
+ workspace_id: &str,
+ agent_id: &str,
+ request: SupersetAgentPollRequest,
+ ) -> Result {
+ // A Superset agent's empty long-poll is transport, not user activity —
+ // matches poll_terminal's reasoning for not marking activity here.
+ let machine = self.machine_without_activity(workspace_id).await?;
+ let _reaper_exempt = ReaperExemptRequest::new(&machine.reaper_exempt_requests);
+ machine.guest.poll_superset_agent(agent_id, &request).await
+ }
+
+ pub async fn close_superset_agent(&self, workspace_id: &str, agent_id: &str) -> Result<()> {
+ let machine = self.machine(workspace_id).await?;
+ machine.guest.close_superset_agent(agent_id).await?;
+ self.mark_activity(&machine);
+ Ok(())
+ }
+
+ pub async fn recover_superset_agent(
+ &self,
+ workspace_id: &str,
+ agent_id: &str,
+ ) -> Result {
+ let machine = self.machine_without_activity(workspace_id).await?;
+ let _reaper_exempt = ReaperExemptRequest::new(&machine.reaper_exempt_requests);
+ machine.guest.recover_superset_agent(agent_id).await
+ }
+
pub async fn start_claude_setup(
&self,
workspace_id: &str,
diff --git a/services/orchestrator/src/backend/mod.rs b/services/orchestrator/src/backend/mod.rs
index d003c0eee..7e8dd1102 100644
--- a/services/orchestrator/src/backend/mod.rs
+++ b/services/orchestrator/src/backend/mod.rs
@@ -13,6 +13,8 @@ use crate::model::{
IdeSession, IdeStartRequest, IdeWriteFileRequest, Instance, PublicationExportRequest,
PublicationExportResponse, Result, RuntimeError, SessionRestoreBeginRequest,
SessionRestoreChunkRequest, SessionRestoreFinalizeResponse, SessionRestoreStatus,
+ SupersetAgentInputRequest, SupersetAgentPollRequest, SupersetAgentPollResponse,
+ SupersetAgentRecoveryResponse, SupersetAgentStartRequest, SupersetAgentStartResponse,
SupersetCreateEntryRequest, SupersetDeleteEntryRequest, SupersetMoveEntryRequest,
TerminalInputRequest, TerminalPollRequest, TerminalPollResponse, TerminalResizeRequest,
TerminalStartRequest, WorktreeCheckpointRequest, WorktreeCheckpointResponse,
@@ -579,6 +581,82 @@ impl Backend {
}
}
+ pub async fn start_superset_agent(
+ &self,
+ workspace_id: &str,
+ request: SupersetAgentStartRequest,
+ ) -> Result {
+ #[cfg(not(target_os = "linux"))]
+ let _ = &request;
+ match self {
+ Self::Fake(backend) => backend.start_superset_agent(workspace_id),
+ #[cfg(target_os = "linux")]
+ Self::Firecracker(backend) => backend.start_superset_agent(workspace_id, request).await,
+ }
+ }
+
+ pub async fn input_superset_agent(
+ &self,
+ workspace_id: &str,
+ agent_id: &str,
+ request: SupersetAgentInputRequest,
+ ) -> Result<()> {
+ #[cfg(not(target_os = "linux"))]
+ let _ = &request;
+ match self {
+ Self::Fake(backend) => backend.input_superset_agent(workspace_id, agent_id),
+ #[cfg(target_os = "linux")]
+ Self::Firecracker(backend) => {
+ backend
+ .input_superset_agent(workspace_id, agent_id, request)
+ .await
+ }
+ }
+ }
+
+ pub async fn poll_superset_agent(
+ &self,
+ workspace_id: &str,
+ agent_id: &str,
+ request: SupersetAgentPollRequest,
+ ) -> Result {
+ #[cfg(not(target_os = "linux"))]
+ let _ = &request;
+ match self {
+ Self::Fake(backend) => backend.poll_superset_agent(workspace_id, agent_id),
+ #[cfg(target_os = "linux")]
+ Self::Firecracker(backend) => {
+ backend
+ .poll_superset_agent(workspace_id, agent_id, request)
+ .await
+ }
+ }
+ }
+
+ pub async fn close_superset_agent(&self, workspace_id: &str, agent_id: &str) -> Result<()> {
+ match self {
+ Self::Fake(backend) => backend.close_superset_agent(workspace_id, agent_id),
+ #[cfg(target_os = "linux")]
+ Self::Firecracker(backend) => {
+ backend.close_superset_agent(workspace_id, agent_id).await
+ }
+ }
+ }
+
+ pub async fn recover_superset_agent(
+ &self,
+ workspace_id: &str,
+ agent_id: &str,
+ ) -> Result {
+ match self {
+ Self::Fake(backend) => backend.recover_superset_agent(workspace_id, agent_id),
+ #[cfg(target_os = "linux")]
+ Self::Firecracker(backend) => {
+ backend.recover_superset_agent(workspace_id, agent_id).await
+ }
+ }
+ }
+
pub async fn start_claude_setup(
&self,
workspace_id: &str,
@@ -1117,6 +1195,51 @@ impl FakeBackend {
Ok(())
}
+ fn start_superset_agent(&self, workspace_id: &str) -> Result {
+ self.get(workspace_id)?;
+ Ok(SupersetAgentStartResponse {
+ host_workspace_id: "fake-host-workspace".into(),
+ host_terminal_id: "fake-terminal-1".into(),
+ host_agent_session_id: "fake-agent-1".into(),
+ })
+ }
+
+ fn input_superset_agent(&self, workspace_id: &str, _agent_id: &str) -> Result<()> {
+ self.get(workspace_id)?;
+ Ok(())
+ }
+
+ fn poll_superset_agent(
+ &self,
+ workspace_id: &str,
+ _agent_id: &str,
+ ) -> Result {
+ self.get(workspace_id)?;
+ Ok(SupersetAgentPollResponse {
+ chunks: Vec::new(),
+ next_sequence: 1,
+ exited: true,
+ exit_code: Some(0),
+ refresh_ready: true,
+ })
+ }
+
+ fn close_superset_agent(&self, workspace_id: &str, _agent_id: &str) -> Result<()> {
+ self.get(workspace_id)?;
+ Ok(())
+ }
+
+ fn recover_superset_agent(
+ &self,
+ workspace_id: &str,
+ _agent_id: &str,
+ ) -> Result {
+ self.get(workspace_id)?;
+ // No real Superset host backs the fake backend, so there is never
+ // anything to adopt.
+ Ok(SupersetAgentRecoveryResponse { adoptable: false })
+ }
+
fn start_claude_setup(&self, workspace_id: &str) -> Result {
self.get(workspace_id)?;
Ok(serde_json::json!({
diff --git a/services/orchestrator/src/guest.rs b/services/orchestrator/src/guest.rs
index 5550f7663..723be9e13 100644
--- a/services/orchestrator/src/guest.rs
+++ b/services/orchestrator/src/guest.rs
@@ -1,5 +1,5 @@
use std::{
- collections::{HashMap, HashSet, VecDeque},
+ collections::{BTreeMap, HashMap, HashSet, VecDeque},
fs::{self, OpenOptions},
io::{BufRead, BufReader, Read, Write},
net::{SocketAddr, TcpStream},
@@ -24,16 +24,21 @@ use wait_timeout::ChildExt;
use crate::model::{
ClaudeSetupCodeRequest, ClaudeSetupPollRequest, ClaudeSetupPollResponse,
ClaudeSetupStartRequest, CodexExecChunk, CodexExecPollRequest, CodexExecPollResponse,
- CodexExecStartRequest, ExecRequest, ExecResponse, FileResponse, PublicationExportRequest,
- PublicationExportResponse, PublicationFile, RuntimeError, SESSION_RESTORE_CHUNK_BYTES,
- SESSION_RESTORE_FILE_BYTES, SESSION_RESTORE_TOTAL_BYTES, SessionRestoreBeginRequest,
- SessionRestoreChunkRequest, SessionRestoreFileKind, SessionRestoreFinalizeResponse,
- SessionRestoreStatus, SupersetCreateEntryRequest, SupersetDeleteEntryRequest,
- SupersetMoveEntryRequest, TerminalChunk, TerminalInputRequest, TerminalPollRequest,
- TerminalPollResponse, TerminalResizeRequest, TerminalStartRequest, WorktreeCheckpointRequest,
+ CodexExecStartRequest, ExecRequest, ExecResponse, FileResponse, LaunchProfile,
+ LaunchProfileFile, PublicationExportRequest, PublicationExportResponse, PublicationFile,
+ RuntimeError, SESSION_RESTORE_CHUNK_BYTES, SESSION_RESTORE_FILE_BYTES,
+ SESSION_RESTORE_TOTAL_BYTES, SessionRestoreBeginRequest, SessionRestoreChunkRequest,
+ SessionRestoreFileKind, SessionRestoreFinalizeResponse, SessionRestoreStatus,
+ SupersetAgentInputRequest, SupersetAgentPollRequest, SupersetAgentStartRequest,
+ SupersetCreateEntryRequest, SupersetDeleteEntryRequest, SupersetMoveEntryRequest,
+ TerminalChunk, TerminalInputRequest, TerminalPollRequest, TerminalPollResponse,
+ TerminalResizeRequest, TerminalStartRequest, WorktreeCheckpointRequest,
WorktreeCheckpointResponse, WorktreeCreateRequest, WorktreeMergeRequest, WorktreeMergeResponse,
WorktreeRebaseRequest, WorktreeRebaseResponse, WorktreeReviewResponse, WriteFileRequest,
};
+use crate::provider_profile::{
+ PROFILE_DIR_TOKEN, materialize_launch_profile, validate_launch_profile,
+};
const MAX_BODY_BYTES: usize = 2 << 20;
const MAX_OUTPUT_BYTES: usize = 2 << 20;
@@ -63,6 +68,38 @@ impl Drop for TemporaryCodexHome {
}
}
+/// The profile a caller that still sends `codexAuthCacheJson` means: the
+/// auth cache at the root of the profile directory, with `CODEX_HOME`
+/// pointing at it — byte for byte what this route did before profiles
+/// existed, including reading the refreshed cache back from the same path
+/// once the process exits.
+fn launch_profile_files(profile: &LaunchProfile) -> impl Iterator- {
+ profile
+ .files
+ .iter()
+ .map(|file| (file.path.as_str(), file.contents.as_str()))
+}
+
+fn launch_profile_env(profile: &LaunchProfile) -> impl Iterator
- {
+ profile
+ .env
+ .iter()
+ .map(|(name, value)| (name.as_str(), value.as_str()))
+}
+
+fn legacy_codex_launch_profile(auth_cache_json: &str) -> LaunchProfile {
+ let mut env = BTreeMap::new();
+ env.insert("CODEX_HOME".to_string(), PROFILE_DIR_TOKEN.to_string());
+ let mut files = Vec::new();
+ if !auth_cache_json.is_empty() {
+ files.push(LaunchProfileFile {
+ path: "auth.json".to_string(),
+ contents: auth_cache_json.to_string(),
+ });
+ }
+ LaunchProfile { files, env }
+}
+
pub struct GuestResponse {
pub status: u16,
pub body: Vec
,
@@ -257,6 +294,18 @@ impl GuestService {
if let Some(operation) = path.strip_prefix("/v1/superset/runtime/") {
return self.superset_runtime(method, operation, body);
}
+ if path == "/v1/superset-agents" && method == "POST" {
+ return self.start_superset_agent(body);
+ }
+ if let Some((agent_id, action)) = superset_agent_route(path) {
+ return match (method, action) {
+ ("POST", "input") => self.input_superset_agent(agent_id, body),
+ ("POST", "poll") => self.poll_superset_agent(agent_id, body),
+ ("DELETE", "") => self.close_superset_agent(agent_id),
+ ("GET", "recovery") => self.recover_superset_agent(agent_id),
+ _ => GuestResponse::error(400, "invalid Superset agent action"),
+ };
+ }
if let Some(worktree_id) = path.strip_prefix("/v1/worktrees/") {
let (worktree_id, action_and_query) =
worktree_id.split_once('/').unwrap_or((worktree_id, ""));
@@ -650,6 +699,90 @@ impl GuestService {
}
}
+ /// Validates and forwards a Superset agent-session launch request over
+ /// the bridge. This guest does not exec the provider process itself for
+ /// these sessions -- Superset's host-service does, on the other side of
+ /// this loopback bridge -- so unlike `start_codex_exec` there is no
+ /// local session table or process handle to keep here.
+ ///
+ /// The launch profile primitive in `provider_profile.rs` intentionally
+ /// is not used on this path: it materializes credentials under this
+ /// guest daemon's *private* `/tmp` (`PrivateTmp=true` in the
+ /// `codev-guestd` systemd unit), which is a separate mount namespace
+ /// Superset's own service cannot see. Forwarding the validated request
+ /// body once, over this bridge-secret-authenticated, guest-internal-only
+ /// channel, is itself the "trusted guest/host launch path" Superset
+ /// Agent Session Plan Phase 2 allows to see a credential -- see that
+ /// plan's Phase 2 for the isolation guarantees this relies on.
+ fn start_superset_agent(&self, body: &[u8]) -> GuestResponse {
+ let request: SupersetAgentStartRequest = match decode(body) {
+ Ok(request) => request,
+ Err(error) => return GuestResponse::error(400, error),
+ };
+ if let Err(error) = validate_worktree_id(&request.worktree_id) {
+ return GuestResponse::error(400, error);
+ }
+ if request.command.is_empty() || request.command.len() > 32 {
+ return GuestResponse::error(400, "command must contain between 1 and 32 arguments");
+ }
+ if request.idempotency_key.is_empty() || request.idempotency_key.len() > 128 {
+ return GuestResponse::error(400, "invalid idempotency key");
+ }
+ // The body is forwarded verbatim, so this is the only place a
+ // malformed profile can be rejected before Superset sees it.
+ if let Some(profile) = request.launch_profile.as_ref() {
+ let files = launch_profile_files(profile);
+ let env = launch_profile_env(profile);
+ if let Err(error) = validate_launch_profile(files, env) {
+ return GuestResponse::error(400, &error);
+ }
+ }
+ self.superset_bridge_request("POST", "/codev/agents", body)
+ }
+
+ fn input_superset_agent(&self, agent_id: &str, body: &[u8]) -> GuestResponse {
+ let request: SupersetAgentInputRequest = match decode(body) {
+ Ok(request) => request,
+ Err(error) => return GuestResponse::error(400, error),
+ };
+ if request.data.len() > MAX_TERMINAL_INPUT_BYTES {
+ return GuestResponse::error(400, "input exceeds 64 KiB");
+ }
+ self.superset_bridge_request(
+ "POST",
+ &format!("/codev/agents/{}/input", percent_encode(agent_id)),
+ body,
+ )
+ }
+
+ fn poll_superset_agent(&self, agent_id: &str, body: &[u8]) -> GuestResponse {
+ let _request: SupersetAgentPollRequest = match decode(body) {
+ Ok(request) => request,
+ Err(error) => return GuestResponse::error(400, error),
+ };
+ self.superset_bridge_request(
+ "POST",
+ &format!("/codev/agents/{}/poll", percent_encode(agent_id)),
+ body,
+ )
+ }
+
+ fn close_superset_agent(&self, agent_id: &str) -> GuestResponse {
+ self.superset_bridge_request(
+ "DELETE",
+ &format!("/codev/agents/{}", percent_encode(agent_id)),
+ &[],
+ )
+ }
+
+ fn recover_superset_agent(&self, agent_id: &str) -> GuestResponse {
+ self.superset_bridge_request(
+ "GET",
+ &format!("/codev/agents/{}/recovery", percent_encode(agent_id)),
+ &[],
+ )
+ }
+
fn superset_bridge_request(&self, method: &str, path: &str, body: &[u8]) -> GuestResponse {
let secret = match std::env::var("CODEV_SUPERSET_BRIDGE_SECRET") {
Ok(secret) if !secret.is_empty() => secret,
@@ -1968,6 +2101,18 @@ impl GuestService {
"Codex auth cache is invalid or too large".into(),
));
}
+ // One code path below: a caller that still sends the Codex-shaped
+ // field gets it converted into the same profile a caller sending
+ // `launchProfile` supplies directly.
+ let launch_profile = match request.launch_profile.clone() {
+ Some(profile) => profile,
+ None => legacy_codex_launch_profile(&request.codex_auth_cache_json),
+ };
+ validate_launch_profile(
+ launch_profile_files(&launch_profile),
+ launch_profile_env(&launch_profile),
+ )
+ .map_err(RuntimeError::BadRequest)?;
let _mutation = self.mutations.lock().expect("mutation lock");
// Fast path: reattach to an existing session for this idempotency
// key, without waiting on codex_busy first — the run this key
@@ -2038,13 +2183,22 @@ impl GuestService {
fs::create_dir(&codex_home_path).map_err(RuntimeError::internal)?;
fs::set_permissions(&codex_home_path, fs::Permissions::from_mode(0o700))
.map_err(RuntimeError::internal)?;
- let auth_path = codex_home_path.join("auth.json");
- if !request.codex_auth_cache_json.is_empty() {
- fs::write(&auth_path, &request.codex_auth_cache_json)
- .map_err(RuntimeError::internal)?;
- fs::set_permissions(&auth_path, fs::Permissions::from_mode(0o600))
- .map_err(RuntimeError::internal)?;
- }
+ let profile_env = materialize_launch_profile(
+ &codex_home_path,
+ launch_profile_files(&launch_profile),
+ launch_profile_env(&launch_profile),
+ )
+ .map_err(RuntimeError::internal)?;
+ // Where to read a refreshed Codex cache back from once the process
+ // exits. It follows the profile rather than assuming the root, so a
+ // caller that places the cache under a `CODEX_HOME` subdirectory
+ // still has its refresh captured.
+ let refresh_relative_path = launch_profile
+ .files
+ .iter()
+ .map(|file| file.path.clone())
+ .find(|path| path.ends_with("auth.json"))
+ .unwrap_or_else(|| "auth.json".to_string());
let codex_home = TemporaryCodexHome(codex_home_path);
let pty = native_pty_system()
@@ -2064,7 +2218,11 @@ impl GuestService {
command.env("TERM", "xterm-256color");
command.env("HISTFILE", "/dev/null");
command.env("HISTSIZE", "0");
- command.env("CODEX_HOME", &codex_home.0);
+ // Last, so a profile that names a variable wins over the defaults
+ // above. Values are never logged: this is the credential.
+ for (name, value) in &profile_env {
+ command.env(name, value);
+ }
let mut child = match pty.slave.spawn_command(command) {
Ok(child) => child,
Err(error) => {
@@ -2162,7 +2320,7 @@ impl GuestService {
thread::sleep(Duration::from_millis(25));
};
drop(pty.master);
- let updated_auth_cache = fs::read_to_string(codex_home.0.join("auth.json"))
+ let updated_auth_cache = fs::read_to_string(codex_home.0.join(&refresh_relative_path))
.ok()
.filter(|value| {
value.len() <= (128 << 10)
@@ -3063,6 +3221,12 @@ fn codex_exec_route(path: &str) -> Option<(&str, &str)> {
(!session_id.is_empty()).then_some((session_id, action))
}
+fn superset_agent_route(path: &str) -> Option<(&str, &str)> {
+ let suffix = path.strip_prefix("/v1/superset-agents/")?;
+ let (agent_id, action) = suffix.split_once('/').unwrap_or((suffix, ""));
+ (!agent_id.is_empty()).then_some((agent_id, action))
+}
+
fn session_restore_route(path: &str) -> Option<(&str, &str)> {
let suffix = path.strip_prefix("/v1/session-restores/")?;
let (operation_id, action) = suffix.split_once('/').unwrap_or((suffix, ""));
@@ -3536,6 +3700,106 @@ mod tests {
assert!(!Path::new(result.output.trim()).exists());
}
+ #[test]
+ fn superset_agent_start_rejects_an_invalid_worktree_id() {
+ let directory = tempdir().expect("tempdir");
+ let service = GuestService::new(directory.path()).expect("service");
+ let request = serde_json::json!({
+ "worktreeId": "../escape",
+ "provider": "openai",
+ "command": ["codex", "exec"],
+ "idempotencyKey": "key-1",
+ });
+ let response = service.handle(
+ "POST",
+ "/v1/superset-agents",
+ serde_json::to_vec(&request).expect("request").as_slice(),
+ );
+ assert_eq!(response.status, 400);
+ }
+
+ #[test]
+ fn superset_agent_start_rejects_an_empty_command() {
+ let directory = tempdir().expect("tempdir");
+ let service = GuestService::new(directory.path()).expect("service");
+ let request = serde_json::json!({
+ "worktreeId": "main",
+ "provider": "openai",
+ "command": [],
+ "idempotencyKey": "key-1",
+ });
+ let response = service.handle(
+ "POST",
+ "/v1/superset-agents",
+ serde_json::to_vec(&request).expect("request").as_slice(),
+ );
+ assert_eq!(response.status, 400);
+ }
+
+ #[test]
+ fn superset_agent_start_rejects_a_missing_idempotency_key() {
+ let directory = tempdir().expect("tempdir");
+ let service = GuestService::new(directory.path()).expect("service");
+ let request = serde_json::json!({
+ "worktreeId": "main",
+ "provider": "openai",
+ "command": ["codex", "exec"],
+ "idempotencyKey": "",
+ });
+ let response = service.handle(
+ "POST",
+ "/v1/superset-agents",
+ serde_json::to_vec(&request).expect("request").as_slice(),
+ );
+ assert_eq!(response.status, 400);
+ }
+
+ #[test]
+ fn superset_agent_input_rejects_oversized_input() {
+ let directory = tempdir().expect("tempdir");
+ let service = GuestService::new(directory.path()).expect("service");
+ let request = serde_json::json!({ "data": "x".repeat(MAX_TERMINAL_INPUT_BYTES + 1) });
+ let response = service.handle(
+ "POST",
+ "/v1/superset-agents/agent-1/input",
+ serde_json::to_vec(&request).expect("request").as_slice(),
+ );
+ assert_eq!(response.status, 400);
+ }
+
+ #[test]
+ fn superset_agent_unknown_action_is_a_bad_request() {
+ let directory = tempdir().expect("tempdir");
+ let service = GuestService::new(directory.path()).expect("service");
+ let response = service.handle("POST", "/v1/superset-agents/agent-1/bogus", b"{}");
+ assert_eq!(response.status, 400);
+ }
+
+ #[test]
+ fn superset_agent_routes_reach_the_bridge_once_validated() {
+ // No CODEV_SUPERSET_BRIDGE_SECRET is set in this test process, so a
+ // well-formed request should fail closed at the bridge call rather
+ // than at request validation -- proving these routes actually
+ // forward instead of silently succeeding.
+ let directory = tempdir().expect("tempdir");
+ let service = GuestService::new(directory.path()).expect("service");
+ let start = serde_json::json!({
+ "worktreeId": "main",
+ "provider": "openai",
+ "command": ["codex", "exec"],
+ "idempotencyKey": "key-1",
+ });
+ let response = service.handle(
+ "POST",
+ "/v1/superset-agents",
+ serde_json::to_vec(&start).expect("request").as_slice(),
+ );
+ assert_eq!(response.status, 503);
+
+ let recovery = service.handle("GET", "/v1/superset-agents/agent-1/recovery", &[]);
+ assert_eq!(recovery.status, 503);
+ }
+
#[test]
fn agent_worktree_lifecycle_and_scoped_operations() {
let directory = tempdir().expect("tempdir");
@@ -4503,6 +4767,71 @@ sleep 5
assert!(service.terminals.lock().expect("terminals").is_empty());
}
+ #[test]
+ fn codex_exec_accepts_a_provider_neutral_launch_profile() {
+ // The point of the profile: the guest is told what files and
+ // environment the process needs, and has to know nothing about
+ // which provider they belong to.
+ let directory = tempdir().expect("tempdir");
+ let service = GuestService::new(directory.path()).expect("service");
+ let request = serde_json::json!({
+ "command": [
+ "/bin/sh",
+ "-c",
+ "test -f \"$CODEX_HOME/auth.json\"; printf '%s' \"$AGENT_MARKER\""
+ ],
+ "launchProfile": {
+ "files": [
+ { "path": "home/auth.json", "contents": "{\"tokens\":{}}" }
+ ],
+ "env": {
+ "CODEX_HOME": "{{profileDir}}/home",
+ "AGENT_MARKER": "profile-ok"
+ }
+ },
+ "idempotencyKey": "profile-key",
+ });
+ let start = service.handle(
+ "POST",
+ "/v1/codex-execs",
+ serde_json::to_vec(&request).expect("request").as_slice(),
+ );
+ assert_eq!(
+ start.status,
+ 200,
+ "{}",
+ String::from_utf8_lossy(&start.body)
+ );
+ let body: serde_json::Value = serde_json::from_slice(&start.body).expect("json");
+ let session_id = body["sessionId"].as_str().expect("session id").to_string();
+ let result = poll_codex_exec_until_exited(
+ &service,
+ &session_id,
+ Instant::now() + Duration::from_secs(5),
+ );
+ assert_eq!(result.exit_code, Some(0));
+ assert!(result.output.contains("profile-ok"));
+ }
+
+ #[test]
+ fn codex_exec_rejects_a_launch_profile_that_escapes_its_directory() {
+ let directory = tempdir().expect("tempdir");
+ let service = GuestService::new(directory.path()).expect("service");
+ let request = serde_json::json!({
+ "command": ["/bin/true"],
+ "launchProfile": {
+ "files": [{ "path": "../escape.json", "contents": "{}" }],
+ },
+ "idempotencyKey": "escape-key",
+ });
+ let start = service.handle(
+ "POST",
+ "/v1/codex-execs",
+ serde_json::to_vec(&request).expect("request").as_slice(),
+ );
+ assert_eq!(start.status, 400);
+ }
+
#[test]
fn codex_exec_start_is_idempotent() {
let directory = tempdir().expect("tempdir");
diff --git a/services/orchestrator/src/guest_client.rs b/services/orchestrator/src/guest_client.rs
index 5a96c89fc..eb658f526 100644
--- a/services/orchestrator/src/guest_client.rs
+++ b/services/orchestrator/src/guest_client.rs
@@ -12,7 +12,9 @@ use crate::model::{
ClaudeSetupStartRequest, CodexExecPollRequest, CodexExecPollResponse, CodexExecStartRequest,
ExecRequest, ExecResponse, FileResponse, PublicationExportRequest, PublicationExportResponse,
Result, RuntimeError, SessionRestoreBeginRequest, SessionRestoreChunkRequest,
- SessionRestoreFinalizeResponse, SupersetCreateEntryRequest, SupersetDeleteEntryRequest,
+ SessionRestoreFinalizeResponse, SupersetAgentInputRequest, SupersetAgentPollRequest,
+ SupersetAgentPollResponse, SupersetAgentRecoveryResponse, SupersetAgentStartRequest,
+ SupersetAgentStartResponse, SupersetCreateEntryRequest, SupersetDeleteEntryRequest,
SupersetMoveEntryRequest, TerminalInputRequest, TerminalPollRequest, TerminalPollResponse,
TerminalResizeRequest, TerminalStartRequest, WorktreeCheckpointRequest,
WorktreeCheckpointResponse, WorktreeCreateRequest, WorktreeMergeRequest, WorktreeMergeResponse,
@@ -262,6 +264,66 @@ impl GuestClient {
.map(|_| ())
}
+ pub async fn start_superset_agent(
+ &self,
+ request: &SupersetAgentStartRequest,
+ ) -> Result {
+ self.request("POST", "/v1/superset-agents", Some(request))
+ .await
+ }
+
+ pub async fn input_superset_agent(
+ &self,
+ agent_id: &str,
+ request: &SupersetAgentInputRequest,
+ ) -> Result<()> {
+ self.request::<_, serde_json::Value>(
+ "POST",
+ &format!("/v1/superset-agents/{agent_id}/input"),
+ Some(request),
+ )
+ .await
+ .map(|_| ())
+ }
+
+ pub async fn poll_superset_agent(
+ &self,
+ agent_id: &str,
+ request: &SupersetAgentPollRequest,
+ ) -> Result {
+ // Mirrors poll_codex_exec's headroom above the guest's own capped
+ // long-poll wait.
+ self.request_with_timeout(
+ "POST",
+ &format!("/v1/superset-agents/{agent_id}/poll"),
+ Some(request),
+ Duration::from_secs(40),
+ )
+ .await
+ }
+
+ pub async fn close_superset_agent(&self, agent_id: &str) -> Result<()> {
+ self.request::<(), serde_json::Value>(
+ "DELETE",
+ &format!("/v1/superset-agents/{agent_id}"),
+ None,
+ )
+ .await
+ .map(|_| ())
+ }
+
+ pub async fn recover_superset_agent(
+ &self,
+ agent_id: &str,
+ ) -> Result {
+ self.request::<(), _>(
+ "GET",
+ &format!("/v1/superset-agents/{agent_id}/recovery"),
+ None,
+ )
+ .await
+ }
+
pub async fn start_claude_setup(
&self,
request: &ClaudeSetupStartRequest,
diff --git a/services/orchestrator/src/http_api.rs b/services/orchestrator/src/http_api.rs
index 8616f2ecd..6ff93f228 100644
--- a/services/orchestrator/src/http_api.rs
+++ b/services/orchestrator/src/http_api.rs
@@ -25,7 +25,8 @@ use crate::{
IDE_EXEC_MAX_ARGUMENTS, IDE_EXEC_MAX_TIMEOUT_SECONDS, IdeExecRequest, IdePrepareRequest,
IdeStartRequest, IdeWriteFileRequest, MAX_IDE_FILE_BYTES, PublicationExportRequest, Result,
RuntimeError, SESSION_RESTORE_CHUNK_BYTES, SessionRestoreBeginRequest,
- SessionRestoreChunkRequest, SupersetCreateEntryRequest, SupersetDeleteEntryRequest,
+ SessionRestoreChunkRequest, SupersetAgentInputRequest, SupersetAgentPollRequest,
+ SupersetAgentStartRequest, SupersetCreateEntryRequest, SupersetDeleteEntryRequest,
SupersetMoveEntryRequest, TerminalInputRequest, TerminalPollRequest, TerminalResizeRequest,
TerminalStartRequest, WorktreeCheckpointRequest, WorktreeCreateRequest,
WorktreeMergeRequest, WorktreeRebaseRequest, WriteFileRequest,
@@ -195,6 +196,26 @@ pub fn router(backend: SharedBackend, ide: IdeBackend) -> Router {
"/v1/sandboxes/{workspace_id}/codex-execs/{session_id}",
delete(close_codex_exec),
)
+ .route(
+ "/v1/sandboxes/{workspace_id}/superset-agents",
+ post(start_superset_agent),
+ )
+ .route(
+ "/v1/sandboxes/{workspace_id}/superset-agents/{agent_id}/input",
+ post(input_superset_agent),
+ )
+ .route(
+ "/v1/sandboxes/{workspace_id}/superset-agents/{agent_id}/poll",
+ post(poll_superset_agent),
+ )
+ .route(
+ "/v1/sandboxes/{workspace_id}/superset-agents/{agent_id}",
+ delete(close_superset_agent),
+ )
+ .route(
+ "/v1/sandboxes/{workspace_id}/superset-agents/{agent_id}/recovery",
+ get(recover_superset_agent),
+ )
.route(
"/v1/sandboxes/{workspace_id}/claude-auth-login",
post(start_claude_setup),
@@ -943,6 +964,80 @@ async fn close_codex_exec(
Ok(StatusCode::NO_CONTENT)
}
+async fn start_superset_agent(
+ State(backend): State,
+ Path(workspace_id): Path,
+ Json(request): Json,
+) -> Result {
+ validate_workspace_id(&workspace_id)?;
+ validate_worktree_id(&request.worktree_id)?;
+ if request.command.is_empty() || request.command.len() > 32 {
+ return Err(RuntimeError::BadRequest(
+ "command must contain between 1 and 32 arguments".into(),
+ ));
+ }
+ if request.idempotency_key.is_empty() || request.idempotency_key.len() > 128 {
+ return Err(RuntimeError::BadRequest(
+ "invalid Superset agent idempotency key".into(),
+ ));
+ }
+ let response = backend.start_superset_agent(&workspace_id, request).await?;
+ Ok((StatusCode::CREATED, Json(response)))
+}
+
+async fn input_superset_agent(
+ State(backend): State,
+ Path((workspace_id, agent_id)): Path<(String, String)>,
+ Json(request): Json,
+) -> Result {
+ validate_workspace_id(&workspace_id)?;
+ validate_superset_agent_id(&agent_id)?;
+ // Guest-side start_superset_agent/input_superset_agent enforce the byte
+ // limit, matching input_terminal's layering: this level only validates
+ // IDs and structure.
+ backend
+ .input_superset_agent(&workspace_id, &agent_id, request)
+ .await?;
+ Ok(StatusCode::NO_CONTENT)
+}
+
+async fn poll_superset_agent(
+ State(backend): State,
+ Path((workspace_id, agent_id)): Path<(String, String)>,
+ Json(request): Json,
+) -> Result> {
+ validate_workspace_id(&workspace_id)?;
+ validate_superset_agent_id(&agent_id)?;
+ let result = backend
+ .poll_superset_agent(&workspace_id, &agent_id, request)
+ .await?;
+ Ok(Json(serde_json::json!({ "result": result })))
+}
+
+async fn close_superset_agent(
+ State(backend): State,
+ Path((workspace_id, agent_id)): Path<(String, String)>,
+) -> Result {
+ validate_workspace_id(&workspace_id)?;
+ validate_superset_agent_id(&agent_id)?;
+ backend
+ .close_superset_agent(&workspace_id, &agent_id)
+ .await?;
+ Ok(StatusCode::NO_CONTENT)
+}
+
+async fn recover_superset_agent(
+ State(backend): State,
+ Path((workspace_id, agent_id)): Path<(String, String)>,
+) -> Result> {
+ validate_workspace_id(&workspace_id)?;
+ validate_superset_agent_id(&agent_id)?;
+ let result = backend
+ .recover_superset_agent(&workspace_id, &agent_id)
+ .await?;
+ Ok(Json(serde_json::json!({ "result": result })))
+}
+
async fn start_claude_setup(
State(backend): State,
Path(workspace_id): Path,
@@ -1308,6 +1403,14 @@ fn validate_codex_exec_id(session_id: &str) -> Result<()> {
}
}
+fn validate_superset_agent_id(agent_id: &str) -> Result<()> {
+ if superset_agent_id_pattern().is_match(agent_id) {
+ Ok(())
+ } else {
+ Err(RuntimeError::BadRequest("invalid Superset agent ID".into()))
+ }
+}
+
fn validate_claude_setup_id(session_id: &str) -> Result<()> {
if claude_setup_id_pattern().is_match(session_id) {
Ok(())
@@ -1372,6 +1475,14 @@ fn codex_exec_id_pattern() -> &'static Regex {
PATTERN.get_or_init(|| Regex::new(r"^codex-[0-9]+-[0-9]+$").expect("codex exec regex"))
}
+fn superset_agent_id_pattern() -> &'static Regex {
+ static PATTERN: OnceLock = OnceLock::new();
+ // Superset mints this ID, not this orchestrator, so it is not pinned to
+ // the guest's own "prefix-digits-digits" session ID convention (compare
+ // codex_exec_id_pattern) -- just a safe, bounded token shape.
+ PATTERN.get_or_init(|| Regex::new(r"^[A-Za-z0-9_-]{1,128}$").expect("superset agent regex"))
+}
+
fn claude_setup_id_pattern() -> &'static Regex {
static PATTERN: OnceLock = OnceLock::new();
PATTERN.get_or_init(|| Regex::new(r"^claude-[0-9]+-[0-9]+$").expect("claude setup regex"))
@@ -1708,4 +1819,143 @@ mod tests {
.expect("response");
assert_eq!(invalid_worktree.status(), StatusCode::BAD_REQUEST);
}
+
+ #[tokio::test]
+ async fn superset_agent_route_validation_and_lifecycle() {
+ let app = router(Arc::new(Backend::fake()), IdeBackend::Disabled);
+ let workspace_id = "e010bd2c-a3c1-438f-acef-166287a3b1cb";
+ let create = app
+ .clone()
+ .oneshot(
+ Request::builder()
+ .method("POST")
+ .uri("/v1/sandboxes")
+ .header("content-type", "application/json")
+ .body(Body::from(
+ serde_json::json!({
+ "workspaceId": workspace_id,
+ "repositoryUrl": "https://github.com/yousef20920/CoDev.git",
+ "baseSha": "fc1ba2947ffdaf8c1961e5342387e1079afface6",
+ "expiresAt": (Utc::now() + Duration::hours(1)).to_rfc3339(),
+ "lifecycle": {
+ "timeoutMs": 14400000,
+ "lifecycle": { "onTimeout": "pause", "autoResume": true }
+ }
+ })
+ .to_string(),
+ ))
+ .expect("request"),
+ )
+ .await
+ .expect("response");
+ assert_eq!(create.status(), StatusCode::CREATED);
+
+ let invalid_worktree = app
+ .clone()
+ .oneshot(
+ Request::builder()
+ .method("POST")
+ .uri(format!("/v1/sandboxes/{workspace_id}/superset-agents"))
+ .header("content-type", "application/json")
+ .body(Body::from(
+ serde_json::json!({
+ "worktreeId": "../escape",
+ "provider": "openai",
+ "command": ["codex", "exec"],
+ "idempotencyKey": "key-1"
+ })
+ .to_string(),
+ ))
+ .expect("request"),
+ )
+ .await
+ .expect("response");
+ assert_eq!(invalid_worktree.status(), StatusCode::BAD_REQUEST);
+
+ let start = app
+ .clone()
+ .oneshot(
+ Request::builder()
+ .method("POST")
+ .uri(format!("/v1/sandboxes/{workspace_id}/superset-agents"))
+ .header("content-type", "application/json")
+ .body(Body::from(
+ serde_json::json!({
+ "worktreeId": "main",
+ "provider": "openai",
+ "command": ["codex", "exec"],
+ "idempotencyKey": "key-1"
+ })
+ .to_string(),
+ ))
+ .expect("request"),
+ )
+ .await
+ .expect("response");
+ assert_eq!(start.status(), StatusCode::CREATED);
+ let start_body = to_bytes(start.into_body(), 1 << 20).await.expect("body");
+ let start_json: serde_json::Value =
+ serde_json::from_slice(&start_body).expect("start json");
+ assert_eq!(start_json["hostAgentSessionId"], "fake-agent-1");
+
+ let invalid_agent_id = app
+ .clone()
+ .oneshot(
+ Request::builder()
+ .method("DELETE")
+ .uri(format!(
+ "/v1/sandboxes/{workspace_id}/superset-agents/not%20a%20safe%20id"
+ ))
+ .body(Body::empty())
+ .expect("request"),
+ )
+ .await
+ .expect("response");
+ assert_eq!(invalid_agent_id.status(), StatusCode::BAD_REQUEST);
+
+ let poll = app
+ .clone()
+ .oneshot(
+ Request::builder()
+ .method("POST")
+ .uri(format!(
+ "/v1/sandboxes/{workspace_id}/superset-agents/fake-agent-1/poll"
+ ))
+ .header("content-type", "application/json")
+ .body(Body::from(serde_json::json!({ "after": 0 }).to_string()))
+ .expect("request"),
+ )
+ .await
+ .expect("response");
+ assert_eq!(poll.status(), StatusCode::OK);
+
+ let recovery = app
+ .clone()
+ .oneshot(
+ Request::builder()
+ .uri(format!(
+ "/v1/sandboxes/{workspace_id}/superset-agents/fake-agent-1/recovery"
+ ))
+ .body(Body::empty())
+ .expect("request"),
+ )
+ .await
+ .expect("response");
+ assert_eq!(recovery.status(), StatusCode::OK);
+
+ let close = app
+ .clone()
+ .oneshot(
+ Request::builder()
+ .method("DELETE")
+ .uri(format!(
+ "/v1/sandboxes/{workspace_id}/superset-agents/fake-agent-1"
+ ))
+ .body(Body::empty())
+ .expect("request"),
+ )
+ .await
+ .expect("response");
+ assert_eq!(close.status(), StatusCode::NO_CONTENT);
+ }
}
diff --git a/services/orchestrator/src/lib.rs b/services/orchestrator/src/lib.rs
index 680c15a69..e61b55d75 100644
--- a/services/orchestrator/src/lib.rs
+++ b/services/orchestrator/src/lib.rs
@@ -1,5 +1,6 @@
-pub mod backend;
-pub mod guest;
-pub mod guest_client;
-pub mod http_api;
-pub mod model;
+pub mod backend;
+pub mod guest;
+pub mod guest_client;
+pub mod http_api;
+pub mod model;
+pub mod provider_profile;
diff --git a/services/orchestrator/src/model.rs b/services/orchestrator/src/model.rs
index 6b0848d28..9a075e300 100644
--- a/services/orchestrator/src/model.rs
+++ b/services/orchestrator/src/model.rs
@@ -394,6 +394,39 @@ pub struct TerminalPollResponse {
pub exit_code: Option,
}
+/// One file a launched agent process needs inside its private credential
+/// profile. `path` is relative to the profile directory and may not escape
+/// it; the guest writes the file 0600 inside a 0700 directory it owns.
+#[derive(Clone, Debug, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct LaunchProfileFile {
+ pub path: String,
+ pub contents: String,
+}
+
+/// What a launched agent process needs in order to authenticate as the
+/// member, in a form that names no provider.
+///
+/// The exec route used to take `codexAuthCacheJson` by name, so every new
+/// provider meant a new field here, in the guest, and in the host request
+/// that carries it -- the Gen 1 IDE start request already carries six such
+/// fields. A profile is files plus environment instead, which is the whole
+/// of what a CLI needs: Codex reads an `auth.json`, Claude reads
+/// `CLAUDE_CODE_OAUTH_TOKEN`, and the guest has to know neither.
+///
+/// Environment values may contain `{{profileDir}}`, which the guest expands
+/// to the absolute path of the profile directory it created. That single
+/// substitution is what lets the caller say `CODEX_HOME` without knowing
+/// where the guest puts the profile.
+#[derive(Clone, Debug, Default, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct LaunchProfile {
+ #[serde(default)]
+ pub files: Vec,
+ #[serde(default)]
+ pub env: std::collections::BTreeMap,
+}
+
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CodexExecStartRequest {
@@ -406,8 +439,13 @@ pub struct CodexExecStartRequest {
pub rows: u16,
#[serde(default)]
pub columns: u16,
+ /// Superseded by `launch_profile`; kept so a control plane that has not
+ /// been redeployed yet keeps working. The guest converts it into a
+ /// profile at the edge, so there is only one code path below.
#[serde(default)]
pub codex_auth_cache_json: String,
+ #[serde(default)]
+ pub launch_profile: Option,
/// The caller's Vercel Workflow DevKit step id. A retried "start" step
/// reuses the same id, letting the guest reattach to the still-running
/// session instead of spawning a second Codex process.
@@ -447,6 +485,71 @@ pub struct CodexExecPollResponse {
pub codex_auth_cache_json: Option,
}
+/// A terminal-agent session launched through Superset rather than executed
+/// directly by the guest, per docs/SUPERSET_AGENT_SESSION_PLAN.md Phase 3.
+/// `codev-guestd` validates and forwards this to Superset's host-service
+/// bridge rather than running the provider process itself -- see
+/// `GuestService::start_superset_agent` in guest.rs.
+#[derive(Clone, Debug, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct SupersetAgentStartRequest {
+ pub worktree_id: String,
+ pub provider: String,
+ /// Superseded by `launch_profile`; see `CodexExecStartRequest`.
+ #[serde(default)]
+ pub codex_auth_cache_json: Option,
+ #[serde(default)]
+ pub launch_profile: Option,
+ pub command: Vec,
+ /// A retried "start" call with the same key reattaches to the run
+ /// Superset already has in flight, matching `CodexExecStartRequest`'s
+ /// idempotency contract.
+ pub idempotency_key: String,
+}
+
+#[derive(Clone, Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct SupersetAgentStartResponse {
+ pub host_workspace_id: String,
+ pub host_terminal_id: String,
+ pub host_agent_session_id: String,
+}
+
+#[derive(Clone, Debug, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct SupersetAgentInputRequest {
+ pub data: String,
+}
+
+#[derive(Clone, Debug, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct SupersetAgentPollRequest {
+ /// Exclusive cursor: the response includes chunks at this sequence and later.
+ #[serde(default)]
+ pub after: u64,
+ #[serde(default)]
+ pub wait_milliseconds: u64,
+}
+
+#[derive(Clone, Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct SupersetAgentPollResponse {
+ pub chunks: Vec,
+ /// Pass as `after` in the next poll; a chunk at this value may arrive later.
+ pub next_sequence: u64,
+ pub exited: bool,
+ pub exit_code: Option,
+ /// Set once the launched process has exited and a refresh capture is safe.
+ #[serde(default)]
+ pub refresh_ready: bool,
+}
+
+#[derive(Clone, Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct SupersetAgentRecoveryResponse {
+ pub adoptable: bool,
+}
+
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ClaudeSetupStartRequest {
diff --git a/services/orchestrator/src/provider_profile.rs b/services/orchestrator/src/provider_profile.rs
new file mode 100644
index 000000000..c4036804e
--- /dev/null
+++ b/services/orchestrator/src/provider_profile.rs
@@ -0,0 +1,646 @@
+//! Per-launch provider credential profiles for Superset-launched agent
+//! sessions, per `docs/SUPERSET_AGENT_SESSION_PLAN.md` Phase 2.
+//!
+//! `codev-guestd` runs under `ProtectSystem=strict` + `PrivateTmp=true`
+//! (see `infra/runtime/scripts/bootstrap-host.sh`), so its own `/tmp` is a
+//! private mount namespace no other guest service can see -- including
+//! Superset's host-service, which has its own separate, explicitly
+//! declared `/var/lib/codev-superset` (`SUPERSET_HOME_DIR`) and no
+//! visibility into guestd's `/tmp`. A profile materialized under
+//! `std::env::temp_dir()` here is therefore already outside `/workspace`
+//! and outside Superset's shared home without inventing a new writable
+//! path (which `ProtectSystem=strict` would otherwise block until the
+//! guestd systemd unit's `ReadWritePaths` was extended). This generalizes
+//! the existing `TemporaryCodexHome` pattern in `guest.rs` -- same
+//! directory root, same 0700/0600 permissions, same `Drop`-based cleanup --
+//! into a provider-agnostic profile a caller can hold by handle across a
+//! launch, rather than only across one `exec` call's stack frame.
+//!
+//! This module is not yet wired into `GuestService`: Phase 3 adds the
+//! Superset launch endpoint that will actually create a profile from a
+//! resolved connection, hand Superset its handle, and resolve that handle
+//! back into a launch environment. Until then this is reviewable and
+//! testable on its own.
+
+use std::{
+ collections::HashMap,
+ fs, io,
+ os::unix::fs::PermissionsExt,
+ path::{Component, Path, PathBuf},
+ sync::{
+ Arc, Mutex,
+ atomic::{AtomicU64, Ordering},
+ },
+ time::{Duration, Instant},
+};
+
+/// The guest's fixed, unprivileged `PATH` -- mirrors `GUEST_PATH` in
+/// `guest.rs`. Duplicated rather than imported so this module has no
+/// compile-time dependency on that file's private items.
+const PROFILE_PATH: &str = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
+
+/// Which provider a launch recipe targets. Only Codex's official
+/// auth-cache format is implemented, per the plan's "Start with the
+/// existing Codex official auth-cache format." Add a variant here, and a
+/// constructor alongside `ProviderLaunchRecipe::codex`, for the next
+/// provider.
+#[derive(Clone, Copy, Debug, Eq, PartialEq)]
+pub enum ProviderKind {
+ Codex,
+ Claude,
+}
+
+impl ProviderKind {
+ fn label(self) -> &'static str {
+ match self {
+ ProviderKind::Codex => "codex",
+ ProviderKind::Claude => "claude",
+ }
+ }
+}
+
+/// Where, inside a profile, the launched process's provider credential
+/// lives, and where to read it back from once the process has exited (or
+/// at a defined safe checkpoint) so CoDev can persist a refreshed token.
+/// Phase 5 owns the actual persistence; this only names the file.
+#[derive(Clone, Debug)]
+pub struct RefreshCollector {
+ /// Path relative to the profile directory.
+ pub relative_path: String,
+}
+
+impl RefreshCollector {
+ fn codex() -> Self {
+ Self {
+ relative_path: "auth.json".to_string(),
+ }
+ }
+
+ /// Claude authenticates from `CLAUDE_CODE_OAUTH_TOKEN`, a long-lived
+ /// token the CLI never rewrites, so there is no refreshed credential to
+ /// collect. The empty path says "nothing to read back".
+ fn claude() -> Self {
+ Self {
+ relative_path: String::new(),
+ }
+ }
+}
+
+/// An opaque reference to a live `ProviderProfile`, unique within this
+/// guestd process's lifetime -- a profile never outlives the process that
+/// materialized it, so a handle never needs to survive a restart. This,
+/// not a raw path or credential payload, is what a caller passes on in a
+/// Superset launch request; see `docs/SUPERSET_AGENT_SESSION_PLAN.md`
+/// Phase 3's "guest should pass Superset a profile handle ... not a raw
+/// credential payload in a general host request."
+#[derive(Clone, Debug, Eq, PartialEq, Hash)]
+pub struct ProfileHandle(String);
+
+impl ProfileHandle {
+ fn new(kind: ProviderKind, seed: u64) -> Self {
+ Self(format!(
+ "profile-{}-{}-{seed:x}",
+ kind.label(),
+ std::process::id()
+ ))
+ }
+
+ pub fn as_str(&self) -> &str {
+ &self.0
+ }
+}
+
+/// A materialized, run-scoped, filesystem-backed credential profile: a
+/// fresh 0700 directory containing only the files one launched process
+/// needs, removed on drop.
+pub struct ProviderProfile {
+ dir: PathBuf,
+ #[allow(dead_code)]
+ kind: ProviderKind,
+}
+
+impl ProviderProfile {
+ fn create(kind: ProviderKind, seed: u64) -> io::Result {
+ let dir = std::env::temp_dir().join(format!(
+ "codev-profile-{}-{}-{seed:x}",
+ kind.label(),
+ std::process::id()
+ ));
+ fs::create_dir(&dir)?;
+ fs::set_permissions(&dir, fs::Permissions::from_mode(0o700))?;
+ Ok(Self { dir, kind })
+ }
+
+ pub fn dir(&self) -> &Path {
+ &self.dir
+ }
+
+ /// Writes one credential file into the profile at 0600, matching the
+ /// existing Codex auth-cache handling in `guest.rs`.
+ pub fn write_credential(&self, relative_path: &str, contents: &[u8]) -> io::Result<()> {
+ let path = self.credential_path(relative_path)?;
+ fs::write(&path, contents)?;
+ fs::set_permissions(&path, fs::Permissions::from_mode(0o600))
+ }
+
+ /// Reads a credential file back out, for the refresh capture Phase 5
+ /// describes. `Ok(None)` means the launched process never wrote one --
+ /// not every provider run refreshes its credential.
+ pub fn read_credential(&self, relative_path: &str) -> io::Result>> {
+ let path = self.credential_path(relative_path)?;
+ match fs::read(&path) {
+ Ok(contents) => Ok(Some(contents)),
+ Err(error) if error.kind() == io::ErrorKind::NotFound => Ok(None),
+ Err(error) => Err(error),
+ }
+ }
+
+ /// Rejects an absolute path or one with a `..`/root component that
+ /// could escape the profile directory -- the same defense-in-depth
+ /// guard the workspace file routes apply elsewhere in this crate.
+ fn credential_path(&self, relative_path: &str) -> io::Result {
+ let candidate = Path::new(relative_path);
+ let escapes = candidate
+ .components()
+ .any(|component| !matches!(component, Component::Normal(part) if !part.is_empty()));
+ if candidate.as_os_str().is_empty() || escapes {
+ return Err(io::Error::new(
+ io::ErrorKind::InvalidInput,
+ "credential path must be a single relative path within the profile",
+ ));
+ }
+ Ok(self.dir.join(candidate))
+ }
+}
+
+impl Drop for ProviderProfile {
+ fn drop(&mut self) {
+ let _ = fs::remove_dir_all(&self.dir);
+ }
+}
+
+/// The provider kind, executable, arguments, environment, profile, and
+/// refresh instructions a Superset launch request needs, per
+/// `docs/SUPERSET_AGENT_SESSION_PLAN.md` Phase 2's "internal provider
+/// launch recipe interface." No secret lives on this type: `env` holds
+/// only the fixed, provider-specific variable names this recipe allows
+/// through -- never the launched process's full inherited environment, per
+/// the plan's "Disable Superset default accounts and all host-wide
+/// provider environment for these sessions" -- and every value is derived
+/// from the profile directory at build time, not carried as an opaque
+/// string a caller could echo back into CoDev's durable run mapping or the
+/// browser.
+pub struct ProviderLaunchRecipe {
+ pub kind: ProviderKind,
+ pub executable: String,
+ pub args: Vec,
+ pub profile: ProfileHandle,
+ pub refresh: RefreshCollector,
+ env: HashMap,
+}
+
+impl ProviderLaunchRecipe {
+ /// The only implemented recipe today: `codex exec`, authenticated from
+ /// the profile's `auth.json` via `CODEX_HOME`, matching the
+ /// materialization already used in `guest.rs`'s `TemporaryCodexHome`
+ /// path.
+ pub fn codex(profile: &ProviderProfile, handle: ProfileHandle, args: Vec) -> Self {
+ let mut env = HashMap::new();
+ env.insert(
+ "CODEX_HOME".to_string(),
+ profile.dir().display().to_string(),
+ );
+ env.insert("PATH".to_string(), PROFILE_PATH.to_string());
+ Self {
+ kind: ProviderKind::Codex,
+ executable: "codex".to_string(),
+ args,
+ profile: handle,
+ refresh: RefreshCollector::codex(),
+ env,
+ }
+ }
+
+ /// `claude -p ...`, authenticated from `CLAUDE_CODE_OAUTH_TOKEN` — the
+ /// setup-token a member uploads with `codev claude-auth`. Unlike Codex
+ /// there is no on-disk auth cache, which is exactly why the launch
+ /// contract needs an environment channel and not just files.
+ pub fn claude(handle: ProfileHandle, token: String, args: Vec) -> Self {
+ let mut env = HashMap::new();
+ env.insert("CLAUDE_CODE_OAUTH_TOKEN".to_string(), token);
+ env.insert("PATH".to_string(), PROFILE_PATH.to_string());
+ Self {
+ kind: ProviderKind::Claude,
+ executable: "claude".to_string(),
+ args,
+ profile: handle,
+ refresh: RefreshCollector::claude(),
+ env,
+ }
+ }
+
+ /// The fixed set of environment variable names this recipe allows
+ /// through to the launched process.
+ pub fn env_names(&self) -> impl Iterator- {
+ self.env.keys().map(String::as_str)
+ }
+
+ /// The full launch environment: exactly `env_names()`, each mapped to
+ /// its resolved value. Internal to the guest/host launch path -- never
+ /// serialized into a browser response or CoDev's durable run mapping.
+ pub fn env(&self) -> &HashMap
{
+ &self.env
+ }
+}
+
+/// Caps on a caller-supplied launch profile. Small on purpose: a profile
+/// carries credentials, not a payload, and anything larger is a mistake or
+/// an attempt to use the exec route as a file-transfer channel.
+pub const MAX_PROFILE_FILES: usize = 8;
+pub const MAX_PROFILE_FILE_BYTES: usize = 128 << 10;
+pub const MAX_PROFILE_ENV_VARS: usize = 16;
+pub const MAX_PROFILE_ENV_VALUE_BYTES: usize = 32 << 10;
+
+/// The token an environment value may use to refer to the profile
+/// directory the guest created. See `LaunchProfile` in `model.rs`.
+pub const PROFILE_DIR_TOKEN: &str = "{{profileDir}}";
+
+fn valid_env_character(character: char) -> bool {
+ character.is_ascii_uppercase() || character.is_ascii_digit() || character == '_'
+}
+
+fn valid_env_name(name: &str) -> bool {
+ let mut characters = name.chars();
+ let Some(first) = characters.next() else {
+ return false;
+ };
+ if first.is_ascii_digit() {
+ return false;
+ }
+ name.chars().all(valid_env_character)
+}
+
+/// Checks a caller-supplied profile before anything is written.
+///
+/// Error strings name the offending *key* or path but never a value: a
+/// profile holds credentials, and a rejection message is the one place
+/// they could otherwise leak into a log or an HTTP response.
+pub fn validate_launch_profile<'a>(
+ files: impl IntoIterator- ,
+ env: impl IntoIterator
- ,
+) -> Result<(), String> {
+ let mut seen = std::collections::HashSet::new();
+ let mut count = 0usize;
+ for (path, contents) in files {
+ count += 1;
+ if count > MAX_PROFILE_FILES {
+ return Err(format!(
+ "launch profile may contain at most {MAX_PROFILE_FILES} files"
+ ));
+ }
+ let candidate = Path::new(path);
+ let escapes = candidate
+ .components()
+ .any(|component| !matches!(component, Component::Normal(part) if !part.is_empty()));
+ if candidate.as_os_str().is_empty() || escapes {
+ return Err("launch profile file paths must be relative to the profile".to_string());
+ }
+ if !seen.insert(path.to_string()) {
+ return Err("launch profile contains a duplicate file path".to_string());
+ }
+ if contents.len() > MAX_PROFILE_FILE_BYTES {
+ return Err(format!("launch profile file {path} is too large"));
+ }
+ }
+
+ let mut env_count = 0usize;
+ for (name, value) in env {
+ env_count += 1;
+ if env_count > MAX_PROFILE_ENV_VARS {
+ return Err(format!(
+ "launch profile may set at most {MAX_PROFILE_ENV_VARS} environment variables"
+ ));
+ }
+ if !valid_env_name(name) {
+ return Err("launch profile environment names must be A-Z, 0-9 and _".to_string());
+ }
+ if value.len() > MAX_PROFILE_ENV_VALUE_BYTES {
+ return Err(format!("launch profile value for {name} is too large"));
+ }
+ }
+ Ok(())
+}
+
+/// Writes a validated profile's files into `dir` (0600 each, creating any
+/// parent directories 0700) and returns the environment to launch with,
+/// every `{{profileDir}}` expanded to `dir`.
+///
+/// `dir` must already exist and be 0700; the caller owns its lifetime,
+/// which is what lets the existing exec path keep its `TemporaryCodexHome`
+/// cleanup semantics unchanged.
+pub fn materialize_launch_profile<'a>(
+ dir: &Path,
+ files: impl IntoIterator
- ,
+ env: impl IntoIterator
- ,
+) -> io::Result
> {
+ for (path, contents) in files {
+ let target = dir.join(path);
+ if let Some(parent) = target.parent().filter(|parent| *parent != dir) {
+ fs::create_dir_all(parent)?;
+ fs::set_permissions(parent, fs::Permissions::from_mode(0o700))?;
+ }
+ fs::write(&target, contents)?;
+ fs::set_permissions(&target, fs::Permissions::from_mode(0o600))?;
+ }
+ let directory = dir.display().to_string();
+ let mut resolved = Vec::new();
+ for (name, value) in env {
+ let expanded = value.replace(PROFILE_DIR_TOKEN, &directory);
+ resolved.push((name.to_string(), expanded));
+ }
+ Ok(resolved)
+}
+
+/// Registry of this guestd process's live profiles, keyed by handle.
+#[derive(Default)]
+pub struct ProviderProfileRegistry {
+ profiles: Mutex)>>,
+ sequence: AtomicU64,
+}
+
+impl ProviderProfileRegistry {
+ pub fn new() -> Self {
+ Self::default()
+ }
+
+ /// Materializes a fresh profile holding one credential file and
+ /// returns its handle. The profile itself stays in this registry, not
+ /// returned, so only the handle -- never a raw path -- needs to cross
+ /// into a Superset launch request.
+ pub fn materialize(
+ &self,
+ kind: ProviderKind,
+ relative_path: &str,
+ credential: &[u8],
+ ) -> io::Result {
+ let seed = self.sequence.fetch_add(1, Ordering::Relaxed);
+ let profile = ProviderProfile::create(kind, seed)?;
+ profile.write_credential(relative_path, credential)?;
+ let handle = ProfileHandle::new(kind, seed);
+ self.profiles
+ .lock()
+ .expect("profile registry lock")
+ .insert(handle.clone(), (Instant::now(), Arc::new(profile)));
+ Ok(handle)
+ }
+
+ /// Looks up a live profile by handle. `None` for an unknown or
+ /// already-removed handle -- a stale handle from a retried or
+ /// duplicate request must fail closed, not resolve to nothing and
+ /// silently skip the credential.
+ pub fn get(&self, handle: &ProfileHandle) -> Option> {
+ self.profiles
+ .lock()
+ .expect("profile registry lock")
+ .get(handle)
+ .map(|(_, profile)| profile.clone())
+ }
+
+ /// Removes and drops a profile, deleting its directory. Call after
+ /// final credential capture, on cancellation, on a failed launch, or
+ /// from `reap_older_than` for anything a VM restart left behind.
+ pub fn remove(&self, handle: &ProfileHandle) {
+ self.profiles
+ .lock()
+ .expect("profile registry lock")
+ .remove(handle);
+ }
+
+ /// Removes every profile materialized more than `max_age` ago --
+ /// backstop cleanup for "VM cleanup, or expired recovery window" in
+ /// the plan, independent of any caller ever explicitly removing a
+ /// handle.
+ pub fn reap_older_than(&self, max_age: Duration) {
+ let now = Instant::now();
+ self.profiles
+ .lock()
+ .expect("profile registry lock")
+ .retain(|_, (created_at, _)| now.duration_since(*created_at) < max_age);
+ }
+
+ pub fn is_empty(&self) -> bool {
+ self.profiles
+ .lock()
+ .expect("profile registry lock")
+ .is_empty()
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn materializes_a_private_run_scoped_profile() {
+ let registry = ProviderProfileRegistry::new();
+ let handle = registry
+ .materialize(ProviderKind::Codex, "auth.json", br#"{"tokens":{}}"#)
+ .expect("materialize");
+ let profile = registry.get(&handle).expect("profile present");
+
+ let mode = fs::metadata(profile.dir())
+ .expect("dir metadata")
+ .permissions()
+ .mode()
+ & 0o777;
+ assert_eq!(mode, 0o700);
+ let file_mode = fs::metadata(profile.dir().join("auth.json"))
+ .expect("file metadata")
+ .permissions()
+ .mode()
+ & 0o777;
+ assert_eq!(file_mode, 0o600);
+ assert_eq!(
+ fs::read(profile.dir().join("auth.json")).expect("read"),
+ br#"{"tokens":{}}"#
+ );
+ }
+
+ #[test]
+ fn an_unknown_handle_resolves_to_nothing_rather_than_a_default() {
+ let registry = ProviderProfileRegistry::new();
+ let bogus = ProfileHandle::new(ProviderKind::Codex, 999);
+ assert!(registry.get(&bogus).is_none());
+ }
+
+ #[test]
+ fn removing_a_profile_deletes_its_directory() {
+ let registry = ProviderProfileRegistry::new();
+ let handle = registry
+ .materialize(ProviderKind::Codex, "auth.json", b"{}")
+ .expect("materialize");
+ let dir = registry.get(&handle).expect("profile").dir().to_path_buf();
+ assert!(dir.exists());
+
+ registry.remove(&handle);
+ assert!(registry.get(&handle).is_none());
+ assert!(registry.is_empty());
+ assert!(!dir.exists());
+ }
+
+ #[test]
+ fn a_recipe_carries_only_the_credential_path_never_its_contents_as_an_opaque_string() {
+ let registry = ProviderProfileRegistry::new();
+ let handle = registry
+ .materialize(ProviderKind::Codex, "auth.json", br#"{"tokens":{"a":1}}"#)
+ .expect("materialize");
+ let profile = registry.get(&handle).expect("profile");
+ let recipe = ProviderLaunchRecipe::codex(&profile, handle, vec!["exec".into()]);
+
+ assert_eq!(
+ recipe.env()["CODEX_HOME"],
+ profile.dir().display().to_string()
+ );
+ assert!(recipe.env_names().collect::>().contains(&"PATH"));
+ // The recipe's environment is a directory reference, not the
+ // credential itself.
+ for value in recipe.env().values() {
+ assert!(!value.contains("tokens"));
+ }
+ }
+
+ #[test]
+ fn rejects_a_credential_path_that_would_escape_the_profile() {
+ let registry = ProviderProfileRegistry::new();
+ let handle = registry
+ .materialize(ProviderKind::Codex, "auth.json", b"{}")
+ .expect("materialize");
+ let profile = registry.get(&handle).expect("profile");
+
+ assert!(profile.write_credential("../escape.json", b"{}").is_err());
+ assert!(profile.write_credential("/etc/passwd", b"{}").is_err());
+ assert!(profile.read_credential("../../etc/shadow").is_err());
+ }
+
+ #[test]
+ fn reap_older_than_removes_only_stale_profiles() {
+ let registry = ProviderProfileRegistry::new();
+ let handle = registry
+ .materialize(ProviderKind::Codex, "auth.json", b"{}")
+ .expect("materialize");
+ let dir = registry.get(&handle).expect("profile").dir().to_path_buf();
+
+ // Not yet stale relative to a generous max age.
+ registry.reap_older_than(Duration::from_secs(3600));
+ assert!(registry.get(&handle).is_some());
+
+ // Stale relative to a zero max age.
+ registry.reap_older_than(Duration::from_secs(0));
+ assert!(registry.get(&handle).is_none());
+ assert!(!dir.exists());
+ }
+
+ #[test]
+ fn a_run_never_reads_back_a_credential_that_was_not_written() {
+ let registry = ProviderProfileRegistry::new();
+ let handle = registry
+ .materialize(ProviderKind::Codex, "auth.json", b"{}")
+ .expect("materialize");
+ let profile = registry.get(&handle).expect("profile");
+ assert_eq!(
+ profile.read_credential("refreshed.json").expect("read"),
+ None
+ );
+ }
+ #[test]
+ fn a_launch_profile_writes_private_files_and_expands_the_profile_dir() {
+ let registry = ProviderProfileRegistry::new();
+ let handle = registry
+ .materialize(ProviderKind::Codex, "placeholder", b"")
+ .expect("materialize");
+ let profile = registry.get(&handle).expect("profile present");
+
+ let env = materialize_launch_profile(
+ profile.dir(),
+ [(".codex/auth.json", r#"{"auth_mode":"chatgpt"}"#)],
+ [("CODEX_HOME", "{{profileDir}}/.codex")],
+ )
+ .expect("materialize profile");
+
+ let written = profile.dir().join(".codex/auth.json");
+ assert_eq!(
+ fs::read_to_string(&written).expect("read"),
+ r#"{"auth_mode":"chatgpt"}"#
+ );
+ // The credential is readable only by the process that owns it, and
+ // the directory the guest created for it stays 0700.
+ let file_mode = fs::metadata(&written).expect("meta").permissions().mode();
+ assert_eq!(file_mode & 0o777, 0o600);
+ let nested = fs::metadata(profile.dir().join(".codex")).expect("meta");
+ assert_eq!(nested.permissions().mode() & 0o777, 0o700);
+ let expected = format!("{}/.codex", profile.dir().display());
+ assert_eq!(env, vec![("CODEX_HOME".to_string(), expected)]);
+ }
+
+ #[test]
+ fn a_launch_profile_cannot_escape_its_directory() {
+ for path in ["../escape", "/etc/passwd", "a/../../b", ""] {
+ assert!(
+ validate_launch_profile([(path, "x")], []).is_err(),
+ "{path} should be rejected"
+ );
+ }
+ assert!(validate_launch_profile([(".codex/auth.json", "x")], []).is_ok());
+ }
+
+ #[test]
+ fn a_launch_profile_is_capped_and_its_names_checked() {
+ let names: Vec = (0..=MAX_PROFILE_FILES)
+ .map(|index| format!("file-{index}"))
+ .collect();
+ let too_many: Vec<(&str, &str)> = names.iter().map(|name| (name.as_str(), "")).collect();
+ assert!(validate_launch_profile(too_many, []).is_err());
+
+ let oversized = "x".repeat(MAX_PROFILE_FILE_BYTES + 1);
+ let files = [("auth.json", oversized.as_str())];
+ assert!(validate_launch_profile(files, []).is_err());
+
+ assert!(validate_launch_profile([], [("lower_case", "v")]).is_err());
+ assert!(validate_launch_profile([], [("WITH-DASH", "v")]).is_err());
+ assert!(validate_launch_profile([], [("0LEADING", "v")]).is_err());
+ assert!(validate_launch_profile([], [("CLAUDE_CODE_OAUTH_TOKEN", "v")]).is_ok());
+ }
+
+ #[test]
+ fn a_rejection_never_names_the_credential_value() {
+ let secret = "sk-ant-oat01-super-secret";
+ let error = validate_launch_profile([("../escape", secret)], [])
+ .expect_err("path should be rejected");
+ assert!(!error.contains(secret));
+
+ let oversized = "y".repeat(MAX_PROFILE_ENV_VALUE_BYTES + 1);
+ let env = [("TOKEN", oversized.as_str())];
+ let error = validate_launch_profile([], env).expect_err("value should be rejected");
+ assert!(!error.contains(&oversized));
+ assert!(error.contains("TOKEN"));
+ }
+
+ #[test]
+ fn claude_launches_from_an_environment_variable_not_a_file() {
+ let registry = ProviderProfileRegistry::new();
+ let handle = registry
+ .materialize(ProviderKind::Claude, "placeholder", b"")
+ .expect("materialize");
+ let recipe = ProviderLaunchRecipe::claude(
+ handle,
+ "sk-ant-oat01-token".to_string(),
+ vec!["-p".to_string()],
+ );
+ assert_eq!(recipe.executable, "claude");
+ let token = recipe.env().get("CLAUDE_CODE_OAUTH_TOKEN");
+ assert_eq!(token.map(String::as_str), Some("sk-ant-oat01-token"));
+ // Nothing to read back: the setup-token is long lived and the CLI
+ // never rewrites it.
+ assert!(recipe.refresh.relative_path.is_empty());
+ }
+}
diff --git a/vendor/superset/packages/host-service/src/app.ts b/vendor/superset/packages/host-service/src/app.ts
index 3d1946ec2..6ee44c0e1 100644
--- a/vendor/superset/packages/host-service/src/app.ts
+++ b/vendor/superset/packages/host-service/src/app.ts
@@ -14,6 +14,7 @@ import { Hono } from "hono";
import { cors } from "hono/cors";
import { createApiClient } from "./api";
import { createChatV3Mount, registerChatV3Routes } from "./chat-v3";
+import { registerCoDevAgentBridge } from "./codev/agents";
import { registerCoDevFileBridge } from "./codev/files";
import { registerCoDevRuntimeBridge } from "./codev/runtime";
import { createDb, type HostDb } from "./db";
@@ -407,6 +408,14 @@ export function createApp(options: CreateAppOptions): CreateAppResult {
workspaceRoot: codevWorkspaceRoot,
bridgeSecret: codevBridgeSecret,
});
+ registerCoDevAgentBridge({
+ app,
+ db,
+ eventBus,
+ git,
+ workspaceRoot: codevWorkspaceRoot,
+ bridgeSecret: codevBridgeSecret,
+ });
}
app.use(
diff --git a/vendor/superset/packages/host-service/src/codev/agents.ts b/vendor/superset/packages/host-service/src/codev/agents.ts
new file mode 100644
index 000000000..106487adb
--- /dev/null
+++ b/vendor/superset/packages/host-service/src/codev/agents.ts
@@ -0,0 +1,366 @@
+import { mkdir, rm, writeFile } from "node:fs/promises";
+import { randomUUID, timingSafeEqual } from "node:crypto";
+import { join } from "node:path";
+import { eq } from "drizzle-orm";
+import type { Hono } from "hono";
+import { z } from "zod";
+import type { HostDb } from "../db";
+import { terminalSessions, workspaces } from "../db/schema";
+import type { EventBus } from "../events";
+import {
+ createTerminalSessionInternal,
+ disposeSessionAndWait,
+ snapshotSession,
+ writeFramedInputToSession,
+} from "../terminal/terminal";
+import { resolveCoDevWorktreeRoot } from "./files";
+
+const worktreeIdSchema = z
+ .string()
+ .min(1)
+ .max(64)
+ .regex(/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/);
+
+const agentStartSchema = z.object({
+ worktreeId: worktreeIdSchema,
+ provider: z.string().min(1).max(32),
+ codexAuthCacheJson: z
+ .string()
+ .max(128 * 1024)
+ .optional(),
+ command: z.array(z.string().min(1)).min(1).max(32),
+ idempotencyKey: z.string().min(1).max(128),
+});
+const agentInputSchema = z.object({ data: z.string().max(64 * 1024) });
+const agentPollSchema = z.object({ after: z.number().int().nonnegative() });
+
+type GitClient = { raw: (args: string[]) => Promise };
+type GitFactory = (worktreePath: string) => Promise;
+
+export type CoDevAgentBridgeOptions = {
+ app: Hono;
+ db: HostDb;
+ eventBus: EventBus;
+ git: GitFactory;
+ workspaceRoot: string;
+ bridgeSecret: string;
+};
+
+type AgentPollState = { sequence: number; text: string };
+const agentPollStates = new Map();
+/** The private credential profile directory, if one was materialized, keyed by agent ID. */
+const agentProfileDirs = new Map();
+/** idempotencyKey -> agentId, so a retried start reattaches instead of relaunching. */
+const agentIdempotency = new Map();
+let agentSequence = 0;
+
+function secretMatches(actual: string | undefined, expected: string) {
+ if (!actual) return false;
+ const received = Buffer.from(actual);
+ const configured = Buffer.from(expected);
+ return received.length === configured.length && timingSafeEqual(received, configured);
+}
+
+function hostWorkspaceId(worktreeId: string) {
+ return `codev-${worktreeId}`;
+}
+
+async function branchAt(git: GitFactory, root: string) {
+ const branch = (await (await git(root)).raw(["branch", "--show-current"])).trim();
+ return branch || "HEAD";
+}
+
+async function ensureAgentWorkspace({
+ db,
+ git,
+ workspaceRoot,
+ worktreeId,
+}: Pick & {
+ worktreeId: string;
+}) {
+ const worktreePath = await resolveCoDevWorktreeRoot(workspaceRoot, worktreeId);
+ const id = hostWorkspaceId(worktreeId);
+ const existing = db.query.workspaces.findFirst({ where: eq(workspaces.id, id) }).sync();
+ if (existing) {
+ if (existing.worktreePath !== worktreePath) {
+ throw new Error("CoDev worktree identity points at a different checkout.");
+ }
+ return { id, worktreePath };
+ }
+ const now = Date.now();
+ db.insert(workspaces)
+ .values({
+ id,
+ projectId: null,
+ worktreePath,
+ branch: await branchAt(git, worktreePath),
+ name: `CoDev agent ${worktreeId}`,
+ type: "worktree",
+ createdAt: now,
+ updatedAt: now,
+ })
+ .run();
+ return { id, worktreePath };
+}
+
+function terminalError(error: unknown) {
+ return error && typeof error === "object" && "error" in error
+ ? String(error.error)
+ : "Superset agent operation failed.";
+}
+
+/**
+ * Quotes one argument for a POSIX shell command line: wrap in single quotes,
+ * and turn each embedded `'` into `'\''` (close the quote, an escaped
+ * literal quote, reopen the quote). Required because `initialCommand` is
+ * typed into a live shell -- an agent's command carries a member's prompt
+ * text verbatim (see apps/web's buildGen2CodexCommand), so an unescaped
+ * `$()`, backtick, or quote in that text would otherwise run as shell code.
+ */
+function posixShellQuote(value: string): string {
+ return `'${value.replaceAll("'", `'\\''`)}'`;
+}
+
+async function removeProfileDir(profileDir: string | undefined) {
+ if (!profileDir) return;
+ await rm(profileDir, { recursive: true, force: true }).catch(() => undefined);
+}
+
+/**
+ * Fixed, bridge-secret-protected operations that launch and drive a
+ * terminal-agent session for CoDev's Superset Agent Session Plan Phase 3.
+ * `codev-guestd` forwards a validated request here rather than executing the
+ * provider process itself -- see start_superset_agent in guest.rs.
+ *
+ * There is no headless "run this process" primitive to reuse here: a
+ * Superset terminal-agent is an agent CLI running inside a tracked terminal
+ * (see terminal-agents/types.ts's TerminalAgentBinding doc comment), so this
+ * reuses the same terminal primitives registerCoDevRuntimeBridge's
+ * /codev/terminal routes already use -- createTerminalSessionInternal,
+ * writeFramedInputToSession, snapshotSession, disposeSessionAndWait -- with
+ * the agent's command delivered via `initialCommand` instead of the
+ * interactive shell the browser-facing routes start empty.
+ *
+ * This intentionally does not use terminal-agents/store.ts's
+ * TerminalAgentBinding/resume-candidate machinery: that is populated by
+ * hook events an agent CLI's own hook configuration reports as it runs, not
+ * something this bridge can construct directly. "Recovery" here is instead
+ * a liveness check against the terminal session itself (see the /recovery
+ * route below) -- real hook-based resume tracking is future work, not part
+ * of this phase.
+ */
+export function registerCoDevAgentBridge({
+ app,
+ db,
+ eventBus,
+ git,
+ workspaceRoot,
+ bridgeSecret,
+}: CoDevAgentBridgeOptions) {
+ const requireBridge = (request: Request) =>
+ secretMatches(request.headers.get("x-codev-bridge-secret") ?? undefined, bridgeSecret);
+
+ app.post("/codev/agents", async (context) => {
+ if (!requireBridge(context.req.raw)) return context.json({ error: "Unauthorized" }, 401);
+ const parsed = agentStartSchema.safeParse(await context.req.json().catch(() => undefined));
+ if (!parsed.success) return context.json({ error: "Invalid Superset agent start request." }, 400);
+ const { worktreeId, codexAuthCacheJson, command, idempotencyKey } = parsed.data;
+
+ const existingAgentId = agentIdempotency.get(idempotencyKey);
+ if (existingAgentId) {
+ const existing = db.query.terminalSessions
+ .findFirst({ where: eq(terminalSessions.id, existingAgentId) })
+ .sync();
+ if (existing && !existing.endedAt) {
+ return context.json(
+ {
+ hostWorkspaceId: existing.originWorkspaceId ?? hostWorkspaceId(worktreeId),
+ hostTerminalId: existingAgentId,
+ hostAgentSessionId: existingAgentId,
+ },
+ 201,
+ );
+ }
+ agentIdempotency.delete(idempotencyKey);
+ }
+
+ let profileDir: string | undefined;
+ try {
+ const workspace = await ensureAgentWorkspace({ db, git, workspaceRoot, worktreeId });
+ let launchCommand = command.map(posixShellQuote).join(" ");
+ if (codexAuthCacheJson) {
+ const homeRoot = process.env.SUPERSET_HOME_DIR;
+ if (!homeRoot) {
+ return context.json(
+ { error: "Superset host has no private home directory configured." },
+ 503,
+ );
+ }
+ profileDir = join(homeRoot, "codev-agent-profiles", randomUUID());
+ await mkdir(profileDir, { recursive: true, mode: 0o700 });
+ await writeFile(join(profileDir, "auth.json"), codexAuthCacheJson, {
+ mode: 0o600,
+ });
+ launchCommand = `CODEX_HOME=${posixShellQuote(profileDir)} ${launchCommand}`;
+ }
+ // A one-shot exec must not leave an idle shell behind once the
+ // provider process finishes -- exiting lets the terminal
+ // subsystem's own PTY-exit handling mark endedAt, which is what
+ // /codev/agents/:id/poll and /recovery read.
+ launchCommand = `${launchCommand}; exit $?`;
+
+ const agentId = `agent-${Date.now()}-${++agentSequence}`;
+ const created = await createTerminalSessionInternal({
+ terminalId: agentId,
+ workspaceId: workspace.id,
+ db,
+ eventBus,
+ rows: 1_000,
+ cols: 4_096,
+ includeDefaultAccountEnv: false,
+ // Matches /codev/terminal: the image reserves uid/gid 2000 for
+ // codev-shell, and setpriv drops directly to it with no PAM
+ // session.
+ shell: "/usr/bin/setpriv",
+ shellArgs: [
+ "--reuid=2000",
+ "--regid=2000",
+ "--clear-groups",
+ "--",
+ "/bin/sh",
+ "-l",
+ ],
+ initialCommand: launchCommand,
+ });
+ if ("error" in created) {
+ await removeProfileDir(profileDir);
+ return context.json({ error: terminalError(created) }, 400);
+ }
+ if (profileDir) agentProfileDirs.set(agentId, profileDir);
+ agentIdempotency.set(idempotencyKey, agentId);
+ agentPollStates.set(agentId, { sequence: 0, text: "" });
+ return context.json(
+ {
+ hostWorkspaceId: workspace.id,
+ hostTerminalId: agentId,
+ hostAgentSessionId: agentId,
+ },
+ 201,
+ );
+ } catch (error) {
+ await removeProfileDir(profileDir);
+ return context.json(
+ { error: error instanceof Error ? error.message : "Could not start Superset agent." },
+ 400,
+ );
+ }
+ });
+
+ app.post("/codev/agents/:agentId/input", async (context) => {
+ if (!requireBridge(context.req.raw)) return context.json({ error: "Unauthorized" }, 401);
+ const parsed = agentInputSchema.safeParse(await context.req.json().catch(() => undefined));
+ if (!parsed.success) return context.json({ error: "Invalid Superset agent input request." }, 400);
+ const agentId = context.req.param("agentId");
+ try {
+ const session = db.query.terminalSessions.findFirst({ where: eq(terminalSessions.id, agentId) }).sync();
+ if (!session) return context.json({ error: "Superset agent session not found." }, 400);
+ const result = await writeFramedInputToSession({
+ terminalId: agentId,
+ workspaceId: session.originWorkspaceId ?? "",
+ text: parsed.data.data,
+ submit: false,
+ db,
+ eventBus,
+ });
+ if ("error" in result) return context.json({ error: terminalError(result) }, 400);
+ return context.json({ ok: true });
+ } catch (error) {
+ return context.json(
+ { error: error instanceof Error ? error.message : "Could not write Superset agent input." },
+ 400,
+ );
+ }
+ });
+
+ app.post("/codev/agents/:agentId/poll", async (context) => {
+ if (!requireBridge(context.req.raw)) return context.json({ error: "Unauthorized" }, 401);
+ const parsed = agentPollSchema.safeParse(await context.req.json().catch(() => undefined));
+ if (!parsed.success) return context.json({ error: "Invalid Superset agent poll request." }, 400);
+ const agentId = context.req.param("agentId");
+ try {
+ const session = db.query.terminalSessions.findFirst({ where: eq(terminalSessions.id, agentId) }).sync();
+ if (!session) return context.json({ error: "Superset agent session not found." }, 400);
+ const snapshot = await snapshotSession({
+ terminalId: agentId,
+ workspaceId: session.originWorkspaceId ?? "",
+ maxLines: 1_000,
+ db,
+ eventBus,
+ });
+ if ("error" in snapshot) return context.json({ error: terminalError(snapshot) }, 400);
+ const state = agentPollStates.get(agentId) ?? { sequence: 0, text: "" };
+ if (snapshot.text !== state.text) {
+ state.sequence += 1;
+ state.text = snapshot.text;
+ agentPollStates.set(agentId, state);
+ }
+ // The bridge does not expose the underlying process's real exit
+ // code (only this package's own terminal.ts tracks it, in
+ // memory, on the session object) -- 0 is reported on any
+ // detected exit as a reasonable default until that is threaded
+ // through.
+ const exited = Boolean(session.endedAt);
+ return context.json({
+ chunks:
+ parsed.data.after < state.sequence
+ ? [{ sequence: state.sequence, data: `\u001b[2J\u001b[H${state.text}` }]
+ : [],
+ nextSequence: state.sequence,
+ exited,
+ exitCode: exited ? 0 : null,
+ refreshReady: exited,
+ });
+ } catch (error) {
+ return context.json(
+ { error: error instanceof Error ? error.message : "Could not poll Superset agent." },
+ 400,
+ );
+ }
+ });
+
+ app.delete("/codev/agents/:agentId", async (context) => {
+ if (!requireBridge(context.req.raw)) return context.json({ error: "Unauthorized" }, 401);
+ const agentId = context.req.param("agentId");
+ try {
+ await disposeSessionAndWait(agentId, db);
+ agentPollStates.delete(agentId);
+ await removeProfileDir(agentProfileDirs.get(agentId));
+ agentProfileDirs.delete(agentId);
+ return context.json({ ok: true });
+ } catch (error) {
+ return context.json(
+ { error: error instanceof Error ? error.message : "Could not close Superset agent." },
+ 400,
+ );
+ }
+ });
+
+ app.get("/codev/agents/:agentId/recovery", async (context) => {
+ if (!requireBridge(context.req.raw)) return context.json({ error: "Unauthorized" }, 401);
+ const agentId = context.req.param("agentId");
+ try {
+ const session = db.query.terminalSessions.findFirst({ where: eq(terminalSessions.id, agentId) }).sync();
+ if (!session || session.endedAt) return context.json({ adoptable: false });
+ const snapshot = await snapshotSession({
+ terminalId: agentId,
+ workspaceId: session.originWorkspaceId ?? "",
+ maxLines: 1,
+ db,
+ eventBus,
+ });
+ return context.json({ adoptable: !("error" in snapshot) });
+ } catch {
+ return context.json({ adoptable: false });
+ }
+ });
+}