diff --git a/ee/apps/den-api/src/capability-sources/external-mcp-connections.ts b/ee/apps/den-api/src/capability-sources/external-mcp-connections.ts index 6be0b4f9c9..4253bcdd17 100644 --- a/ee/apps/den-api/src/capability-sources/external-mcp-connections.ts +++ b/ee/apps/den-api/src/capability-sources/external-mcp-connections.ts @@ -3,6 +3,7 @@ import { ConnectedAccountTable, ExternalMcpConnectionAccessGrantTable, ExternalMcpConnectionTable, + ExternalMcpToolManifestTable, OrgOAuthClientTable, } from "@openwork-ee/den-db/schema" import { createDenTypeId, type DenTypeId } from "@openwork-ee/utils/typeid" @@ -211,6 +212,9 @@ export async function deleteExternalMcpConnection(input: { eq(OrgOAuthClientTable.organizationId, input.organizationId), eq(OrgOAuthClientTable.providerId, existing.id), )) + await tx.delete(ExternalMcpToolManifestTable).where( + eq(ExternalMcpToolManifestTable.externalMcpConnectionId, existing.id), + ) await tx.delete(ExternalMcpConnectionTable).where(eq(ExternalMcpConnectionTable.id, existing.id)) return true }) @@ -243,6 +247,10 @@ export async function clearExternalMcpTokens(input: { connectedAt: null, }) .where(eq(ExternalMcpConnectionTable.id, existing.id)) + await db.delete(ExternalMcpToolManifestTable).where(and( + eq(ExternalMcpToolManifestTable.externalMcpConnectionId, existing.id), + eq(ExternalMcpToolManifestTable.principal, "shared"), + )) return true } diff --git a/ee/apps/den-api/src/capability-sources/external-mcp-manifests.ts b/ee/apps/den-api/src/capability-sources/external-mcp-manifests.ts new file mode 100644 index 0000000000..b3edd33caa --- /dev/null +++ b/ee/apps/den-api/src/capability-sources/external-mcp-manifests.ts @@ -0,0 +1,471 @@ +import { createHash } from "node:crypto" +import { and, eq, inArray, isNull, lte, or, sql } from "@openwork-ee/den-db/drizzle" +import { + ExternalMcpToolManifestTable, + type CachedExternalMcpTool, +} from "@openwork-ee/den-db/schema" +import { createDenTypeId, type DenTypeId } from "@openwork-ee/utils/typeid" +import { db } from "../db.js" +import { env } from "../env.js" +import type { ExternalMcpConnectionRow } from "./external-mcp-connections.js" +import { + createExternalMcpLifecycleDeadline, + type ExternalMcpMemberContext, +} from "./external-mcp-client.js" +import { listExternalMcpTools } from "./external-mcp-client-runtime.js" + +export type ManifestPrincipal = "shared" | DenTypeId<"member"> +export type ExternalMcpToolManifestRow = typeof ExternalMcpToolManifestTable.$inferSelect + +export type ManifestPair = { + connection: ExternalMcpConnectionRow + principal: ManifestPrincipal +} + +export type ManifestClassification = + | { state: "fresh"; row: ExternalMcpToolManifestRow } + | { state: "stale"; row: ExternalMcpToolManifestRow } + | { state: "miss"; row: ExternalMcpToolManifestRow | null } + +export type ManifestRevalidationResult = "failed" | "lease_held" | "refreshed" + +type SaveListingInput = { + connection: ExternalMcpConnectionRow + principal: ManifestPrincipal + tools: readonly CachedExternalMcpTool[] + durationMs: number +} + +type SaveFailureInput = { + connection: ExternalMcpConnectionRow + principal: ManifestPrincipal + error: unknown + durationMs: number +} + +type RevalidationInput = { + connection: ExternalMcpConnectionRow + principal: ManifestPrincipal + redirectUri: string + member?: ExternalMcpMemberContext +} + +const inFlightRevalidations = new Map>() +const MAX_REVALIDATION_BACKLOG = 20 + +type QueuedManifestRevalidation = { + reject: (error: unknown) => void + resolve: () => void + run: () => Promise +} + +export function createBoundedManifestRevalidationQueue(input: { + concurrency: number + maxBacklog: number +}) { + const concurrency = Math.max(1, Math.floor(input.concurrency)) + const maxBacklog = Math.max(0, Math.floor(input.maxBacklog)) + const queue: QueuedManifestRevalidation[] = [] + let active = 0 + + const drain = () => { + while (active < concurrency) { + const item = queue.shift() + if (!item) return + active += 1 + void item.run() + .then(item.resolve, item.reject) + .finally(() => { + active -= 1 + drain() + }) + } + } + + return { + enqueue(run: () => Promise): Promise | null { + if (queue.length >= maxBacklog && active >= concurrency) return null + const task = new Promise((resolve, reject) => { + queue.push({ reject, resolve, run }) + }) + drain() + return task + }, + stats() { + return { active, queued: queue.length } + }, + } +} + +const manifestRevalidationQueue = createBoundedManifestRevalidationQueue({ + concurrency: env.mcpManifestRevalidateConcurrency, + maxBacklog: MAX_REVALIDATION_BACKLOG, +}) + +export function manifestPrincipalFor( + connection: ExternalMcpConnectionRow, + member?: ExternalMcpMemberContext, +): ManifestPrincipal { + if (connection.credentialMode === "per_member") { + if (!member) { + throw new Error(`Connection "${connection.id}" uses per-member manifests but no member context was provided.`) + } + return member.orgMembershipId + } + return "shared" +} + +export function computeManifestConfigHash(connection: ExternalMcpConnectionRow): string { + return createHash("sha256") + .update(`${connection.url}\n${connection.authType}\n${connection.credentialMode}`) + .digest("hex") +} + +function rowKey(connectionId: string, principal: string) { + return `${connectionId}\0${principal}` +} + +function shortErrorMessage(error: unknown): string { + const message = error instanceof Error ? error.message : String(error) + return message.length > 1024 ? `${message.slice(0, 1021)}...` : message +} + +function normalizeTools(tools: readonly CachedExternalMcpTool[]): { + tools: CachedExternalMcpTool[] + toolCount: number + toolsHash: string + toolsTruncated: boolean +} { + const normalized = tools.map((tool) => ({ + name: tool.name, + ...(tool.title ? { title: tool.title } : {}), + ...(tool.description ? { description: tool.description } : {}), + })) + let candidate = normalized + let toolsTruncated = false + + if (Buffer.byteLength(JSON.stringify(candidate), "utf8") > env.mcpManifestMaxBytes) { + candidate = candidate.map((tool) => ({ + ...tool, + ...(tool.description ? { description: tool.description.slice(0, 500) } : {}), + })) + toolsTruncated = true + } + + while (candidate.length > 0 && Buffer.byteLength(JSON.stringify(candidate), "utf8") > env.mcpManifestMaxBytes) { + candidate = candidate.slice(0, -1) + toolsTruncated = true + } + + return { + tools: candidate, + toolCount: candidate.length, + toolsHash: createHash("sha256").update(JSON.stringify(candidate)).digest("hex"), + toolsTruncated, + } +} + +export function classifyManifest( + row: ExternalMcpToolManifestRow | null, + connection: ExternalMcpConnectionRow, + now = new Date(), +): ManifestClassification { + if (!row) return { state: "miss", row: null } + if (row.configHash !== computeManifestConfigHash(connection)) return { state: "miss", row } + if (row.tools.length === 0 || !row.listedAt) return { state: "miss", row } + + const ageMs = now.getTime() - row.listedAt.getTime() + if (ageMs >= env.mcpManifestMaxAgeMs) return { state: "miss", row } + if (row.staleAt && row.staleAt <= now) return { state: "stale", row } + if (row.status === "ok" && ageMs < env.mcpManifestFreshTtlMs) return { state: "fresh", row } + return { state: "stale", row } +} + +export async function getManifests(input: { + pairs: readonly ManifestPair[] +}): Promise> { + if (input.pairs.length === 0) return new Map() + const connectionIds = [...new Set(input.pairs.map((pair) => pair.connection.id))] + const principals = [...new Set(input.pairs.map((pair) => pair.principal))] + const rows = await db + .select() + .from(ExternalMcpToolManifestTable) + .where(and( + inArray(ExternalMcpToolManifestTable.externalMcpConnectionId, connectionIds), + inArray(ExternalMcpToolManifestTable.principal, principals), + )) + return new Map(rows.map((row) => [rowKey(row.externalMcpConnectionId, row.principal), row])) +} + +export function manifestMapKey(connectionId: string, principal: ManifestPrincipal): string { + return rowKey(connectionId, principal) +} + +export async function saveManifestListing(input: SaveListingInput): Promise { + const prepared = normalizeTools(input.tools) + const values = { + id: createDenTypeId("externalMcpToolManifest"), + organizationId: input.connection.organizationId, + externalMcpConnectionId: input.connection.id, + principal: input.principal, + configHash: computeManifestConfigHash(input.connection), + status: "ok" as const, + tools: prepared.tools, + toolCount: prepared.toolCount, + toolsHash: prepared.toolsHash, + toolsTruncated: prepared.toolsTruncated, + lastError: null, + durationMs: input.durationMs, + listedAt: new Date(), + staleAt: null, + refreshStartedAt: null, + } + await db + .insert(ExternalMcpToolManifestTable) + .values(values) + .onDuplicateKeyUpdate({ + set: { + configHash: values.configHash, + status: values.status, + tools: values.tools, + toolCount: values.toolCount, + toolsHash: values.toolsHash, + toolsTruncated: values.toolsTruncated, + lastError: values.lastError, + durationMs: values.durationMs, + listedAt: values.listedAt, + staleAt: values.staleAt, + refreshStartedAt: values.refreshStartedAt, + }, + }) + + const rows = await db + .select() + .from(ExternalMcpToolManifestTable) + .where(and( + eq(ExternalMcpToolManifestTable.externalMcpConnectionId, input.connection.id), + eq(ExternalMcpToolManifestTable.principal, input.principal), + )) + .limit(1) + const row = rows[0] + if (!row) throw new Error("Failed to save external MCP tool manifest.") + return row +} + +export async function saveManifestFailure(input: SaveFailureInput): Promise { + const existingRows = await db + .select() + .from(ExternalMcpToolManifestTable) + .where(and( + eq(ExternalMcpToolManifestTable.externalMcpConnectionId, input.connection.id), + eq(ExternalMcpToolManifestTable.principal, input.principal), + )) + .limit(1) + const existing = existingRows[0] + const currentHash = computeManifestConfigHash(input.connection) + const keepExistingTools = Boolean(existing && existing.configHash === currentHash) + const values = { + id: existing?.id ?? createDenTypeId("externalMcpToolManifest"), + organizationId: input.connection.organizationId, + externalMcpConnectionId: input.connection.id, + principal: input.principal, + configHash: existing?.configHash ?? currentHash, + status: "error" as const, + tools: keepExistingTools ? existing?.tools ?? [] : [], + toolCount: keepExistingTools ? existing?.toolCount ?? 0 : 0, + toolsHash: keepExistingTools ? existing?.toolsHash ?? null : null, + toolsTruncated: keepExistingTools ? existing?.toolsTruncated ?? false : false, + lastError: shortErrorMessage(input.error), + durationMs: input.durationMs, + listedAt: keepExistingTools ? existing?.listedAt ?? null : null, + staleAt: keepExistingTools ? existing?.staleAt ?? null : null, + refreshStartedAt: null, + } + + await db + .insert(ExternalMcpToolManifestTable) + .values(values) + .onDuplicateKeyUpdate({ + set: { + configHash: values.configHash, + status: values.status, + tools: values.tools, + toolCount: values.toolCount, + toolsHash: values.toolsHash, + toolsTruncated: values.toolsTruncated, + lastError: values.lastError, + durationMs: values.durationMs, + listedAt: values.listedAt, + staleAt: values.staleAt, + refreshStartedAt: values.refreshStartedAt, + }, + }) +} + +export async function markManifestsStale(input: { + connectionId: DenTypeId<"externalMcpConnection"> + principal?: ManifestPrincipal +}): Promise { + const where = input.principal + ? and( + eq(ExternalMcpToolManifestTable.externalMcpConnectionId, input.connectionId), + eq(ExternalMcpToolManifestTable.principal, input.principal), + ) + : eq(ExternalMcpToolManifestTable.externalMcpConnectionId, input.connectionId) + await db + .update(ExternalMcpToolManifestTable) + .set({ staleAt: new Date() }) + .where(where) +} + +export async function deleteManifests(input: { + connectionId: DenTypeId<"externalMcpConnection"> + principal?: ManifestPrincipal +}): Promise { + const where = input.principal + ? and( + eq(ExternalMcpToolManifestTable.externalMcpConnectionId, input.connectionId), + eq(ExternalMcpToolManifestTable.principal, input.principal), + ) + : eq(ExternalMcpToolManifestTable.externalMcpConnectionId, input.connectionId) + await db.delete(ExternalMcpToolManifestTable).where(where) +} + +export async function claimManifestRefresh(input: { + rowId: DenTypeId<"externalMcpToolManifest"> + leaseMs?: number +}): Promise { + const leaseMs = input.leaseMs ?? env.mcpManifestRefreshLeaseMs + const leaseMicros = leaseMs * 1000 + const result = await db + .update(ExternalMcpToolManifestTable) + .set({ refreshStartedAt: sql`NOW(3)` }) + .where(and( + eq(ExternalMcpToolManifestTable.id, input.rowId), + or( + isNull(ExternalMcpToolManifestTable.refreshStartedAt), + lte(ExternalMcpToolManifestTable.refreshStartedAt, sql`DATE_SUB(NOW(3), INTERVAL ${leaseMicros} MICROSECOND)`), + ), + )) + return rowsAffected(result) === 1 +} + +export async function createRefreshLeaseForPair(input: { + connection: ExternalMcpConnectionRow + principal: ManifestPrincipal +}): Promise { + const values = { + id: createDenTypeId("externalMcpToolManifest"), + organizationId: input.connection.organizationId, + externalMcpConnectionId: input.connection.id, + principal: input.principal, + configHash: computeManifestConfigHash(input.connection), + status: "error" as const, + tools: [], + toolCount: 0, + toolsHash: null, + toolsTruncated: false, + lastError: null, + durationMs: null, + listedAt: null, + staleAt: new Date(), + refreshStartedAt: null, + } + await db + .insert(ExternalMcpToolManifestTable) + .values(values) + .onDuplicateKeyUpdate({ + set: { + staleAt: values.staleAt, + }, + }) + const rows = await db + .select() + .from(ExternalMcpToolManifestTable) + .where(and( + eq(ExternalMcpToolManifestTable.externalMcpConnectionId, input.connection.id), + eq(ExternalMcpToolManifestTable.principal, input.principal), + )) + .limit(1) + const row = rows[0] + if (!row) throw new Error("Failed to create external MCP manifest refresh lease.") + return row +} + +export function scheduleManifestRevalidation(input: RevalidationInput): void { + const key = rowKey(input.connection.id, input.principal) + if (inFlightRevalidations.has(key)) return + const task = manifestRevalidationQueue.enqueue(async () => { + const result = await revalidateManifest(input) + if (result === "failed") { + console.warn(`[mcp-manifest][revalidate_failed] connectionId=${input.connection.id} principal=${input.principal}`) + } + }) + if (!task) { + console.warn(`[mcp-manifest][revalidate_dropped] connectionId=${input.connection.id} principal=${input.principal} reason=queue_full`) + return + } + task.catch((error) => { + console.warn(`[mcp-manifest][revalidate_failed] connectionId=${input.connection.id} principal=${input.principal} reason=${shortErrorMessage(error)}`) + }).finally(() => { + inFlightRevalidations.delete(key) + }) + inFlightRevalidations.set(key, task) +} + +export async function revalidateManifestWithClaim(input: RevalidationInput & { + claimRefresh: (rowId: DenTypeId<"externalMcpToolManifest">) => Promise + row: ExternalMcpToolManifestRow +}): Promise { + const claimed = await input.claimRefresh(input.row.id) + if (!claimed) return "lease_held" + const startedAt = Date.now() + try { + const tools = await listExternalMcpTools( + input.connection, + input.redirectUri, + input.member, + undefined, + createExternalMcpLifecycleDeadline(env.mcpListToolsTimeoutMs), + ) + await saveManifestListing({ + connection: input.connection, + principal: input.principal, + tools, + durationMs: Date.now() - startedAt, + }) + return "refreshed" + } catch (error) { + await saveManifestFailure({ + connection: input.connection, + principal: input.principal, + error, + durationMs: Date.now() - startedAt, + }) + return "failed" + } +} + +export async function revalidateManifest(input: RevalidationInput): Promise { + const row = await createRefreshLeaseForPair({ connection: input.connection, principal: input.principal }) + return revalidateManifestWithClaim({ + ...input, + row, + claimRefresh: (rowId) => claimManifestRefresh({ rowId }), + }) +} + +function rowsAffected(result: unknown): number { + if (Array.isArray(result)) { + const first = result[0] + if (typeof first === "object" && first !== null && "affectedRows" in first) { + const affectedRows = first.affectedRows + return typeof affectedRows === "number" ? affectedRows : 0 + } + } + if (typeof result === "object" && result !== null && "rowsAffected" in result) { + const rowsAffectedValue = result.rowsAffected + return typeof rowsAffectedValue === "number" ? rowsAffectedValue : 0 + } + return 0 +} diff --git a/ee/apps/den-api/src/capability-sources/oauth-credentials.ts b/ee/apps/den-api/src/capability-sources/oauth-credentials.ts index 5305d0c174..84fadee645 100644 --- a/ee/apps/den-api/src/capability-sources/oauth-credentials.ts +++ b/ee/apps/den-api/src/capability-sources/oauth-credentials.ts @@ -1,10 +1,11 @@ -import { and, eq, isNull } from "@openwork-ee/den-db/drizzle" +import { and, eq, inArray, isNull } from "@openwork-ee/den-db/drizzle" import { ConnectedAccountTable, + ExternalMcpToolManifestTable, MemberTable, OrgOAuthClientTable, } from "@openwork-ee/den-db/schema" -import { createDenTypeId, type DenTypeId } from "@openwork-ee/utils/typeid" +import { createDenTypeId, isDenTypeId, type DenTypeId } from "@openwork-ee/utils/typeid" import { db } from "../db.js" /** @@ -145,6 +146,24 @@ export async function getConnectedAccount(input: { return rows[0] ? normalizeConnectedAccountRow(rows[0]) : null } +export async function getConnectedAccounts(input: { + organizationId: OrganizationId + orgMembershipId: OrgMembershipId + providerIds: string[] +}): Promise> { + const providerIds = [...new Set(input.providerIds)] + if (providerIds.length === 0) return new Map() + const rows = await db + .select() + .from(ConnectedAccountTable) + .where(and( + eq(ConnectedAccountTable.organizationId, input.organizationId), + eq(ConnectedAccountTable.orgMembershipId, input.orgMembershipId), + inArray(ConnectedAccountTable.providerId, providerIds), + )) + return new Map(rows.map((row) => [row.providerId, normalizeConnectedAccountRow(row)])) +} + /** Upsert used both to stash a pending PKCE verifier before redirect, and to save real tokens after exchange. */ export async function upsertConnectedAccount(input: ConnectedAccountUpsertInput): Promise { const existing = await getConnectedAccount(input) @@ -269,6 +288,12 @@ export async function disconnectAccount(input: { const existing = await getConnectedAccount(input) if (!existing) return false await db.delete(ConnectedAccountTable).where(eq(ConnectedAccountTable.id, existing.id)) + if (isDenTypeId("externalMcpConnection", input.providerId)) { + await db.delete(ExternalMcpToolManifestTable).where(and( + eq(ExternalMcpToolManifestTable.externalMcpConnectionId, input.providerId), + eq(ExternalMcpToolManifestTable.principal, input.orgMembershipId), + )) + } return true } diff --git a/ee/apps/den-api/src/env.ts b/ee/apps/den-api/src/env.ts index b933447228..aa00d25475 100644 --- a/ee/apps/den-api/src/env.ts +++ b/ee/apps/den-api/src/env.ts @@ -98,6 +98,15 @@ const EnvSchema = z.object({ DEN_PLAN_GATING_ENABLED: z.string().optional(), DEN_INSTALL_LINKS_GATING_ENABLED: z.string().optional(), DEN_MCP_CONNECTIONS_GATING_ENABLED: z.string().optional(), + DEN_MCP_LIST_TOOLS_TIMEOUT_MS: z.string().optional(), + DEN_MCP_MANIFEST_CACHE_ENABLED: z.string().optional(), + DEN_MCP_MANIFEST_FRESH_TTL_MS: z.string().optional(), + DEN_MCP_MANIFEST_MAX_AGE_MS: z.string().optional(), + DEN_MCP_MANIFEST_MAX_BYTES: z.string().optional(), + DEN_MCP_MANIFEST_REFRESH_INTERVAL_MS: z.string().optional(), + DEN_MCP_MANIFEST_REFRESH_BATCH_SIZE: z.string().optional(), + DEN_MCP_MANIFEST_REFRESH_LEASE_MS: z.string().optional(), + DEN_MCP_MANIFEST_REVALIDATE_CONCURRENCY: z.string().optional(), SCIM_MAINTENANCE_INTERVAL_MS: z.string().optional(), POLAR_FEATURE_GATE_ENABLED: z.string().optional(), POLAR_API_BASE: z.string().optional(), @@ -370,6 +379,15 @@ export const env = { planGatingEnabled, installLinksGatingEnabled, mcpConnectionsGatingEnabled, + mcpListToolsTimeoutMs: Number(parsed.DEN_MCP_LIST_TOOLS_TIMEOUT_MS ?? "3500"), + mcpManifestCacheEnabled: (parsed.DEN_MCP_MANIFEST_CACHE_ENABLED ?? "true").toLowerCase() !== "false", + mcpManifestFreshTtlMs: Number(parsed.DEN_MCP_MANIFEST_FRESH_TTL_MS ?? "900000"), + mcpManifestMaxAgeMs: Number(parsed.DEN_MCP_MANIFEST_MAX_AGE_MS ?? "86400000"), + mcpManifestMaxBytes: Number(parsed.DEN_MCP_MANIFEST_MAX_BYTES ?? "262144"), + mcpManifestRefreshIntervalMs: Number(parsed.DEN_MCP_MANIFEST_REFRESH_INTERVAL_MS ?? "300000"), + mcpManifestRefreshBatchSize: Number(parsed.DEN_MCP_MANIFEST_REFRESH_BATCH_SIZE ?? "20"), + mcpManifestRefreshLeaseMs: Number(parsed.DEN_MCP_MANIFEST_REFRESH_LEASE_MS ?? "60000"), + mcpManifestRevalidateConcurrency: Number(parsed.DEN_MCP_MANIFEST_REVALIDATE_CONCURRENCY ?? "3"), scimMaintenanceIntervalMs: Number(parsed.SCIM_MAINTENANCE_INTERVAL_MS ?? "300000"), requireEmailVerification, passwordBreachScreeningEnabled, diff --git a/ee/apps/den-api/src/mcp-manifest-maintenance.ts b/ee/apps/den-api/src/mcp-manifest-maintenance.ts new file mode 100644 index 0000000000..b8a5daea9c --- /dev/null +++ b/ee/apps/den-api/src/mcp-manifest-maintenance.ts @@ -0,0 +1,198 @@ +import { and, eq, isNotNull, isNull, lt, lte, or, sql } from "@openwork-ee/den-db/drizzle" +import { + ConnectedAccountTable, + ExternalMcpConnectionTable, + ExternalMcpToolManifestTable, +} from "@openwork-ee/den-db/schema" +import { normalizeDenTypeId, isDenTypeId } from "@openwork-ee/utils/typeid" +import { db } from "./db.js" +import { env } from "./env.js" +import { listTeamsForMember } from "./orgs.js" +import { + deleteManifests, + revalidateManifest, + type ManifestPrincipal, +} from "./capability-sources/external-mcp-manifests.js" +import { + memberCanUseExternalMcpConnection, + type ExternalMcpConnectionRow, +} from "./capability-sources/external-mcp-connections.js" + +let manifestMaintenanceRunning = false +let warnedMissingPublicUrl = false + +function redirectUriForRefresh(connectionId: string) { + if (!env.apiPublicUrl) return null + return `${env.apiPublicUrl.replace(/\/+$/, "")}/v1/mcp-connections/${encodeURIComponent(connectionId)}/connect/callback` +} + +function isSharedRefreshable(connection: ExternalMcpConnectionRow) { + if (connection.credentialMode !== "shared") return false + if (connection.authType === "oauth") return Boolean(connection.accessToken) + if (connection.authType === "apikey") return Boolean(connection.apiKey) + return true +} + +async function refreshManifestRow(row: typeof ExternalMcpToolManifestTable.$inferSelect) { + const connectionRows = await db + .select() + .from(ExternalMcpConnectionTable) + .where(eq(ExternalMcpConnectionTable.id, row.externalMcpConnectionId)) + .limit(1) + const connection = connectionRows[0] + if (!connection) { + await deleteManifests({ connectionId: row.externalMcpConnectionId, principal: row.principal as ManifestPrincipal }) + return "deleted" as const + } + + const redirectUri = redirectUriForRefresh(connection.id) + if (!redirectUri) return "skipped" as const + + if (row.principal === "shared") { + if (!isSharedRefreshable(connection)) { + await deleteManifests({ connectionId: connection.id, principal: "shared" }) + return "deleted" as const + } + return revalidateManifest({ connection, principal: "shared", redirectUri }) + } + + if (!isDenTypeId("member", row.principal)) { + await deleteManifests({ connectionId: connection.id, principal: row.principal as ManifestPrincipal }) + return "deleted" as const + } + const orgMembershipId = normalizeDenTypeId("member", row.principal) + const accountRows = await db + .select({ id: ConnectedAccountTable.id, accessToken: ConnectedAccountTable.accessToken }) + .from(ConnectedAccountTable) + .where(and( + eq(ConnectedAccountTable.organizationId, connection.organizationId), + eq(ConnectedAccountTable.orgMembershipId, orgMembershipId), + eq(ConnectedAccountTable.providerId, connection.id), + )) + .limit(1) + const account = accountRows[0] + if (!account?.accessToken) { + await deleteManifests({ connectionId: connection.id, principal: orgMembershipId }) + return "deleted" as const + } + const teams = await listTeamsForMember({ organizationId: connection.organizationId, memberId: orgMembershipId }) + const canUse = await memberCanUseExternalMcpConnection({ + connectionId: connection.id, + orgMembershipId, + teamIds: teams.map((team) => team.id), + }) + if (!canUse) { + await deleteManifests({ connectionId: connection.id, principal: orgMembershipId }) + return "deleted" as const + } + return revalidateManifest({ + connection, + principal: orgMembershipId, + redirectUri, + member: { orgMembershipId }, + }) +} + +async function seedSharedConnectionRows(limit: number) { + if (limit <= 0) return 0 + const rows = await db + .select({ connection: ExternalMcpConnectionTable }) + .from(ExternalMcpConnectionTable) + .leftJoin( + ExternalMcpToolManifestTable, + and( + eq(ExternalMcpToolManifestTable.externalMcpConnectionId, ExternalMcpConnectionTable.id), + eq(ExternalMcpToolManifestTable.principal, "shared"), + ), + ) + .where(and( + eq(ExternalMcpConnectionTable.credentialMode, "shared"), + isNull(ExternalMcpToolManifestTable.id), + or( + eq(ExternalMcpConnectionTable.authType, "none"), + and(eq(ExternalMcpConnectionTable.authType, "oauth"), isNotNull(ExternalMcpConnectionTable.accessToken)), + and(eq(ExternalMcpConnectionTable.authType, "apikey"), isNotNull(ExternalMcpConnectionTable.apiKey)), + ), + )) + .orderBy(ExternalMcpConnectionTable.createdAt) + .limit(limit) + let seeded = 0 + for (const { connection } of rows) { + if (!isSharedRefreshable(connection)) continue + const redirectUri = redirectUriForRefresh(connection.id) + if (!redirectUri) continue + const result = await revalidateManifest({ connection, principal: "shared", redirectUri }) + if (result === "refreshed") seeded += 1 + } + return seeded +} + +export async function runMcpManifestMaintenanceOnce() { + if (!env.apiPublicUrl) { + if (!warnedMissingPublicUrl) { + console.warn("[mcp-manifest][refresh_disabled] reason=missing_api_public_url") + warnedMissingPublicUrl = true + } + return { scanned: 0, refreshed: 0, failures: 0, deleted: 0, seeded: 0 } + } + + const staleCutoff = new Date(Date.now() - Math.floor(env.mcpManifestFreshTtlMs * 0.8)) + const errorCutoff = new Date(Date.now() - env.mcpManifestFreshTtlMs) + const rows = await db + .select() + .from(ExternalMcpToolManifestTable) + .where(or( + and(lte(ExternalMcpToolManifestTable.staleAt, new Date())), + lt(ExternalMcpToolManifestTable.listedAt, staleCutoff), + and( + eq(ExternalMcpToolManifestTable.status, "error"), + lt(ExternalMcpToolManifestTable.updatedAt, errorCutoff), + ), + isNull(ExternalMcpToolManifestTable.listedAt), + )) + .orderBy(sql`${ExternalMcpToolManifestTable.listedAt} ASC`) + .limit(env.mcpManifestRefreshBatchSize) + + let refreshed = 0 + let failures = 0 + let deleted = 0 + for (const row of rows) { + try { + const result = await refreshManifestRow(row) + if (result === "refreshed") refreshed += 1 + if (result === "failed") failures += 1 + if (result === "deleted") deleted += 1 + } catch (error) { + failures += 1 + const message = error instanceof Error ? error.message : String(error) + console.warn(`[mcp-manifest][refresh] connectionId=${row.externalMcpConnectionId} principal=${row.principal} status=error reason=${message}`) + } + } + const seeded = await seedSharedConnectionRows(Math.max(0, env.mcpManifestRefreshBatchSize - rows.length)) + console.info(`[mcp-manifest][refresh_summary] scanned=${rows.length} refreshed=${refreshed} failures=${failures} deleted=${deleted} seeded=${seeded}`) + return { scanned: rows.length, refreshed, failures, deleted, seeded } +} + +export function startMcpManifestMaintenanceLoop(intervalMs = env.mcpManifestRefreshIntervalMs) { + if (!env.mcpManifestCacheEnabled || !Number.isFinite(intervalMs) || intervalMs <= 0) { + return () => undefined + } + + const run = () => { + if (manifestMaintenanceRunning) return + manifestMaintenanceRunning = true + void runMcpManifestMaintenanceOnce() + .catch((error) => { + const message = error instanceof Error ? error.message : String(error) + console.error(`[mcp-manifest][maintenance_failed] reason=${message}`) + }) + .finally(() => { + manifestMaintenanceRunning = false + }) + } + + const timer = setInterval(run, intervalMs) + timer.unref() + run() + return () => clearInterval(timer) +} diff --git a/ee/apps/den-api/src/mcp/agent.ts b/ee/apps/den-api/src/mcp/agent.ts index f26e293bf6..c82d4d2ca1 100644 --- a/ee/apps/den-api/src/mcp/agent.ts +++ b/ee/apps/den-api/src/mcp/agent.ts @@ -330,8 +330,9 @@ export function registerAgentMcpRoutes> + const listStartedAt = Date.now() try { tools = await listExternalMcpTools( connection, - redirectUriFor(input.redirectUriBase, connection.id), + redirectUri, member, undefined, input.deadline, ) + if (env.mcpManifestCacheEnabled) { + await saveManifestListing({ + connection, + principal, + tools, + durationMs: Date.now() - listStartedAt, + }).catch((error) => { + input.counters.writesFailed += 1 + console.warn("external_mcp_manifest_write_failed", { + connectionId: connection.id, + reason: error instanceof Error ? error.message : String(error), + }) + }) + } } catch (error) { + if (env.mcpManifestCacheEnabled) { + await saveManifestFailure({ + connection, + principal, + error, + durationMs: Date.now() - listStartedAt, + }).catch((manifestError) => { + input.counters.writesFailed += 1 + console.warn("external_mcp_manifest_write_failed", { + connectionId: connection.id, + reason: manifestError instanceof Error ? manifestError.message : String(manifestError), + }) + }) + } const message = upstreamErrorMessage(error) const diagnostic = error instanceof ExternalMcpDiagnosticError ? error.diagnostic : undefined const nameTokens = tokenize(connection.name) @@ -595,23 +718,13 @@ async function probeExternalMcpConnection(input: { return matches } - for (const tool of tools) { - const summary = tool.description ?? tool.title ?? tool.name - const nameTokens = tokenize(`${connection.name} ${tool.name}`) - const summaryTokens = tokenize(summary) - const score = scoreText(nameTokens, summaryTokens, input.queryTokens) - if (score <= 0) continue - add({ - name: buildExternalCapabilityName(connection.id, tool.name), - method: "MCP", - path: connection.url, - score, - summary: `[${connection.name}] ${summary}`, - pathParams: [], - queryParams: [], - hasBody: true, - }) - } + addToolMatches({ + connection, + limit: input.limit, + matches, + queryTokens: input.queryTokens, + tools, + }) return matches } @@ -630,6 +743,8 @@ export async function searchExternalCapabilities(input: { reportCoverage?: (coverage: ExternalMcpSearchCoverage) => void }): Promise { if (!input.member) return [] + const member = input.member + const startedAt = Date.now() const queryTokens = tokenize(input.query) if (queryTokens.length === 0) return [] const requestedLimit = input.limit ?? 5 @@ -638,8 +753,8 @@ export async function searchExternalCapabilities(input: { const deadline = createExternalMcpLifecycleDeadline() const connections = await listUsableExternalMcpConnections({ organizationId: normalizeDenTypeId("organization", input.organizationId), - orgMembershipId: input.member.orgMembershipId, - teamIds: input.member.teamIds, + orgMembershipId: member.orgMembershipId, + teamIds: member.teamIds, }) const selectedConnections = selectExternalMcpSearchConnections(connections, queryTokens) input.reportCoverage?.({ @@ -647,19 +762,68 @@ export async function searchExternalCapabilities(input: { probedConnections: selectedConnections.length, truncated: selectedConnections.length < connections.length, }) - return await collectBoundedExternalMcpSearchMatches({ + const accounts = await getConnectedAccounts({ + organizationId: normalizeDenTypeId("organization", input.organizationId), + orgMembershipId: member.orgMembershipId, + providerIds: selectedConnections.flatMap((connection) => + connection.credentialMode === "per_member" ? [connection.id] : []), + }) + const manifestPairs = selectedConnections + .filter((connection) => connection.credentialMode === "shared" + ? hasSharedCredential(connection) + : Boolean(accounts.get(connection.id)?.accessToken)) + .map((connection) => ({ + connection, + principal: manifestPrincipalFor( + connection, + connection.credentialMode === "per_member" + ? { orgMembershipId: member.orgMembershipId } + : undefined, + ), + })) + const manifests = env.mcpManifestCacheEnabled + ? await getManifests({ pairs: manifestPairs }).catch((error) => { + console.warn("external_mcp_manifest_read_failed", { + reason: error instanceof Error ? error.message : String(error), + }) + return new Map() + }) + : new Map() + const counters: ExternalSearchCacheCounters = { + cacheHits: 0, + staleServed: 0, + misses: 0, + writesFailed: 0, + } + const matches = await collectBoundedExternalMcpSearchMatches({ connections: selectedConnections, deadline, limit, probe: (connection, sharedDeadline) => probeExternalMcpConnection({ connection, - member: input.member!, + account: connection.credentialMode === "per_member" ? accounts.get(connection.id) ?? null : null, + counters, + manifest: manifests.get(manifestMapKey( + connection.id, + connection.credentialMode === "per_member" ? member.orgMembershipId : "shared", + )), + member, queryTokens, redirectUriBase: input.redirectUriBase, limit, deadline: sharedDeadline, }), }) + console.info("external_mcp_capability_search_cache", { + cacheHits: counters.cacheHits, + durationMs: Date.now() - startedAt, + eligibleConnections: connections.length, + misses: counters.misses, + probedConnections: selectedConnections.length, + staleServed: counters.staleServed, + writesFailed: counters.writesFailed, + }) + return matches } export type ExternalCapabilityExecuteResult = @@ -756,6 +920,15 @@ export async function executeExternalCapability(input: { }) return { ok: true, result } } catch (error) { + if (shouldInvalidateManifest(error)) { + const principal = manifestPrincipalFor(connection, member) + void markManifestsStale({ connectionId: connection.id, principal }).catch((manifestError) => { + console.warn("external_mcp_manifest_invalidation_failed", { + connectionId: connection.id, + reason: manifestError instanceof Error ? manifestError.message : String(manifestError), + }) + }) + } if (error instanceof ExternalMcpDiagnosticError) { console.error("external_mcp_capability_execute_failed", { connectionId: connection.id, diff --git a/ee/apps/den-api/src/routes/org/mcp-connections.ts b/ee/apps/den-api/src/routes/org/mcp-connections.ts index 75af896364..5159cfbf21 100644 --- a/ee/apps/den-api/src/routes/org/mcp-connections.ts +++ b/ee/apps/den-api/src/routes/org/mcp-connections.ts @@ -21,6 +21,15 @@ import { connectExternalMcp, completeExternalMcpAuth, } from "../../capability-sources/external-mcp-client-runtime.js" +import { + deleteManifests, + getManifests, + manifestMapKey, + manifestPrincipalFor, + revalidateManifest, + type ExternalMcpToolManifestRow, + type ManifestPrincipal, +} from "../../capability-sources/external-mcp-manifests.js" import { createExternalMcpConnection, deleteExternalMcpConnection, @@ -36,7 +45,12 @@ import { import { memberFacingMcpConnectionsEnabled } from "../../capability-sources/external-mcp-rollout.js" import { listNativeProviderUsableEntries } from "../../capability-sources/native-provider-connections.js" import { connectCallbackPage } from "../../capability-sources/oauth-callback-page.js" -import { getConnectedAccount, upsertOrgOAuthClient } from "../../capability-sources/oauth-credentials.js" +import { + getConnectedAccount, + getConnectedAccounts, + upsertOrgOAuthClient, + type ConnectedAccountRow, +} from "../../capability-sources/oauth-credentials.js" import { assertPublicUrl } from "../../capability-sources/url-guard.js" import type { MemberTeamSummary } from "../../orgs.js" import { EXTERNAL_MCP_PRESETS } from "../../capability-sources/external-mcp-presets.js" @@ -147,6 +161,14 @@ const connectionResponseSchema = z.object({ tenantId: z.string().nullable().optional(), /** Present only for scope=manageable (admin) listings. */ access: accessSummarySchema.nullable(), + /** Cached search catalog health for this caller's shared or per-member principal. */ + tools: z.object({ + count: z.number().int().nonnegative(), + listedAt: z.string().nullable(), + status: z.enum(["ok", "error"]), + truncated: z.boolean(), + lastError: z.string().nullable(), + }).nullable().optional(), }).meta({ ref: "ExternalMcpConnectionResponse" }) const connectionListResponseSchema = z.object({ @@ -237,6 +259,13 @@ const connectionValidationFailedSchema = z.object({ diagnostic: externalMcpDiagnosticSchema, }).meta({ ref: "ExternalMcpConnectionValidationFailedError" }) +const refreshToolsResponseSchema = z.object({ + status: z.enum(["ok", "error", "in_progress"]), + toolCount: z.number().int().nonnegative(), + listedAt: z.string().nullable(), + message: z.string().optional(), +}).meta({ ref: "ExternalMcpRefreshToolsResponse" }) + function isConnectionConnected(row: ExternalMcpConnectionRow): boolean { if (row.credentialMode === "per_member") { // A per_member connection is "published" once created; individual @@ -246,23 +275,41 @@ function isConnectionConnected(row: ExternalMcpConnectionRow): boolean { return Boolean(row.accessToken || row.apiKey || (row.authType === "none" && row.connectedAt)) } +function responseManifestPrincipal( + row: ExternalMcpConnectionRow, + callerOrgMembershipId: DenTypeId<"member">, +): ManifestPrincipal { + return row.credentialMode === "per_member" ? callerOrgMembershipId : "shared" +} + async function toConnectionResponse( row: ExternalMcpConnectionRow, options: { callerOrgMembershipId: DenTypeId<"member"> + connectedAccount?: ConnectedAccountRow | null includeAccess: boolean + manifest?: ExternalMcpToolManifestRow | null }, ) { let connectedForMe = isConnectionConnected(row) && row.credentialMode === "shared" if (row.credentialMode === "per_member") { - const account = await getConnectedAccount({ - organizationId: row.organizationId, - orgMembershipId: options.callerOrgMembershipId, - providerId: row.id, - }) + const account = options.connectedAccount === undefined + ? await getConnectedAccount({ + organizationId: row.organizationId, + orgMembershipId: options.callerOrgMembershipId, + providerId: row.id, + }) + : options.connectedAccount connectedForMe = Boolean(account?.accessToken) } + let manifest = options.manifest + if (manifest === undefined) { + const principal = responseManifestPrincipal(row, options.callerOrgMembershipId) + const manifests = await getManifests({ pairs: [{ connection: row, principal }] }) + manifest = manifests.get(manifestMapKey(row.id, principal)) ?? null + } + let access: { orgWide: boolean; memberIds: string[]; teamIds: string[] } | null = null if (options.includeAccess) { const grants = await listExternalMcpConnectionAccess(row.id) @@ -283,9 +330,47 @@ async function toConnectionResponse( connectedAt: row.connectedAt ? row.connectedAt.toISOString() : null, connectedForMe, access, + tools: manifest + ? { + count: manifest.toolCount, + listedAt: manifest.listedAt ? manifest.listedAt.toISOString() : null, + status: manifest.status, + truncated: manifest.toolsTruncated, + lastError: manifest.lastError, + } + : null, } } +async function toConnectionResponses(input: { + callerOrgMembershipId: DenTypeId<"member"> + includeAccess: boolean + organizationId: DenTypeId<"organization"> + rows: ExternalMcpConnectionRow[] +}) { + const manifestPairs = input.rows.map((row) => ({ + connection: row, + principal: responseManifestPrincipal(row, input.callerOrgMembershipId), + })) + const [manifests, connectedAccounts] = await Promise.all([ + getManifests({ pairs: manifestPairs }), + getConnectedAccounts({ + organizationId: input.organizationId, + orgMembershipId: input.callerOrgMembershipId, + providerIds: input.rows.flatMap((row) => row.credentialMode === "per_member" ? [row.id] : []), + }), + ]) + return Promise.all(input.rows.map((row) => { + const principal = responseManifestPrincipal(row, input.callerOrgMembershipId) + return toConnectionResponse(row, { + callerOrgMembershipId: input.callerOrgMembershipId, + connectedAccount: row.credentialMode === "per_member" ? connectedAccounts.get(row.id) ?? null : null, + includeAccess: input.includeAccess, + manifest: manifests.get(manifestMapKey(row.id, principal)) ?? null, + }) + })) +} + function callbackRedirectUri(request: Request, connectionId: string) { const origin = resolvePublicOrigin(request, env.apiPublicUrl) return `${origin}/v1/mcp-connections/${encodeURIComponent(connectionId)}/connect/callback` @@ -348,8 +433,12 @@ export function registerMcpConnectionRoutes - toConnectionResponse(row, { callerOrgMembershipId: payload.currentMember.id, includeAccess: true }))) + const connections = await toConnectionResponses({ + callerOrgMembershipId: payload.currentMember.id, + includeAccess: true, + organizationId: payload.organization.id, + rows, + }) return c.json({ connections }) } @@ -366,8 +455,12 @@ export function registerMcpConnectionRoutes team.id), }) - const connections = await Promise.all(rows.map((row) => - toConnectionResponse(row, { callerOrgMembershipId: payload.currentMember.id, includeAccess: false }))) + const connections = await toConnectionResponses({ + callerOrgMembershipId: payload.currentMember.id, + includeAccess: false, + organizationId: payload.organization.id, + rows, + }) // Native providers (e.g. google-workspace) join the same list once the // org saved an OAuth client for them — same card, same connect flow, // same rollout gate (this sits after the gate check on purpose). @@ -590,6 +683,78 @@ export function registerMcpConnectionRoutes { + const payload = c.get("organizationContext") + const { connectionId } = c.req.valid("param") + const externalMcpConnectionId = normalizeDenTypeId("externalMcpConnection", connectionId) + const connection = await getExternalMcpConnection({ + organizationId: payload.organization.id, + connectionId: externalMcpConnectionId, + }) + if (!connection) { + return c.json({ error: "connection_not_found", message: "Unknown connection." }, 404) + } + + const memberTeams: MemberTeamSummary[] = c.get("memberTeams") ?? [] + const isAdmin = verifyOrgRole({ roles: ["admin"], userContext: payload.currentMember }) + const canUse = await memberCanUseExternalMcpConnection({ + connectionId: externalMcpConnectionId, + orgMembershipId: payload.currentMember.id, + teamIds: memberTeams.map((team) => team.id), + }) + if (!isAdmin && !canUse) { + return c.json({ error: "forbidden", message: "You have not been granted access to this connection." }, 403) + } + if (connection.credentialMode === "shared" && !isAdmin) { + return c.json({ error: "forbidden", message: "Only workspace owners and admins can refresh a shared org-account connection." }, 403) + } + + const member = connection.credentialMode === "per_member" + ? { orgMembershipId: payload.currentMember.id } + : undefined + const principal = manifestPrincipalFor(connection, member) + const refreshResult = await revalidateManifest({ + connection, + principal, + redirectUri: callbackRedirectUri(c.req.raw, connection.id), + member, + }) + const manifests = await getManifests({ pairs: [{ connection, principal }] }) + const manifest = manifests.get(manifestMapKey(connection.id, principal)) + if (refreshResult === "lease_held") { + return c.json({ + status: "in_progress" as const, + toolCount: manifest?.toolCount ?? 0, + listedAt: manifest?.listedAt ? manifest.listedAt.toISOString() : null, + message: "A refresh for this connection is already in progress.", + }, 202) + } + return c.json({ + status: manifest?.status ?? "error", + toolCount: manifest?.toolCount ?? 0, + listedAt: manifest?.listedAt ? manifest.listedAt.toISOString() : null, + ...(manifest?.lastError ? { message: manifest.lastError } : {}), + }) + }, + ) + app.get( "/v1/mcp-connections/:connectionId/connect/start", describeRoute({ @@ -756,6 +921,10 @@ export function registerMcpConnectionRoutes number url: string stop: () => void } @@ -83,7 +84,9 @@ function textContent(text: string): { type: "text"; text: string }[] { function startFakeMcpServer(name: string, tools: FakeTool[], requiredBearer?: string): FakeMcpServer { const app = new Hono() + let requests = 0 app.all("/mcp", async (c) => { + requests += 1 if (requiredBearer && c.req.header("authorization") !== `Bearer ${requiredBearer}`) { return c.json({ error: "invalid_token" }, 401) } @@ -105,6 +108,7 @@ function startFakeMcpServer(name: string, tools: FakeTool[], requiredBearer?: st }) const server = Bun.serve({ port: 0, fetch: app.fetch }) return { + requestCount: () => requests, url: `http://127.0.0.1:${server.port}/mcp`, stop: () => server.stop(true), } @@ -112,7 +116,9 @@ function startFakeMcpServer(name: string, tools: FakeTool[], requiredBearer?: st function startErrorMcpServer(message: string): FakeMcpServer { const app = new Hono() + let requests = 0 app.all("/mcp", async (c) => { + requests += 1 const payload: unknown = await c.req.json() const requestId = typeof payload === "object" && payload !== null && "id" in payload && (typeof payload.id === "string" || typeof payload.id === "number") @@ -126,6 +132,7 @@ function startErrorMcpServer(message: string): FakeMcpServer { }) const server = Bun.serve({ port: 0, fetch: app.fetch }) return { + requestCount: () => requests, url: `http://127.0.0.1:${server.port}/mcp`, stop: () => server.stop(true), } @@ -133,7 +140,9 @@ function startErrorMcpServer(message: string): FakeMcpServer { function startProviderErrorMcpServer(): FakeMcpServer { const app = new Hono() + let requests = 0 app.all("/mcp", async (c) => { + requests += 1 const server = new McpServer({ name: "provider-error", version: "1.0.0" }) server.registerTool( "create_change", @@ -164,7 +173,7 @@ function startProviderErrorMcpServer(): FakeMcpServer { return response }) const server = Bun.serve({ port: 0, fetch: app.fetch }) - return { url: `http://127.0.0.1:${server.port}/mcp`, stop: () => server.stop(true) } + return { requestCount: () => requests, url: `http://127.0.0.1:${server.port}/mcp`, stop: () => server.stop(true) } } function standaloneConnection( @@ -276,6 +285,7 @@ beforeAll(async () => { // at call time, so flipping it on the live object keeps the SSRF guard from // blocking this file's 127.0.0.1 fake servers regardless of load order. envMod.env.allowPrivateMcpUrls = true + envMod.env.mcpManifestCacheEnabled = true db = dbMod.db schema = schemaMod listExternalMcpTools = clientMod.listExternalMcpTools @@ -336,6 +346,42 @@ test("control-healthy: Connections list and search_capabilities both see Slack t } }) +test("warm manifest search avoids a second remote MCP lifecycle and emits benchmark evidence", async () => { + const benchmarkServer = startFakeMcpServer("manifest-benchmark", slackTools) + try { + const seed = await seedOrganization("manifest-benchmark") + const connection = await createGrantedConnection(seed, { + name: "Slack Benchmark", + authType: "none", + credentialMode: "shared", + url: benchmarkServer.url, + }) + + const coldStartedAt = performance.now() + const coldMatches = await search(seed, "slack") + const coldMs = performance.now() - coldStartedAt + const requestsAfterCold = benchmarkServer.requestCount() + + const warmStartedAt = performance.now() + const warmMatches = await search(seed, "slack") + const warmMs = performance.now() - warmStartedAt + const requestsAfterWarm = benchmarkServer.requestCount() + + expect(toolNames(warmMatches)).toEqual(toolNames(coldMatches)) + expect(requestsAfterCold).toBeGreaterThan(0) + expect(requestsAfterWarm).toBe(requestsAfterCold) + console.log("MCP_MANIFEST_BENCHMARK", JSON.stringify({ + coldMs: Number(coldMs.toFixed(2)), + connectionId: connection.id, + coldRemoteRequests: requestsAfterCold, + warmMs: Number(warmMs.toFixed(2)), + warmRemoteRequests: requestsAfterWarm - requestsAfterCold, + })) + } finally { + benchmarkServer.stop() + } +}) + test("shared-oauth-never-connected: Connections list sees Slack and search returns needs_connection", async () => { if (!slackServer) throw new Error("Slack MCP server was not started") diff --git a/ee/apps/den-api/test/external-mcp-manifests.test.ts b/ee/apps/den-api/test/external-mcp-manifests.test.ts new file mode 100644 index 0000000000..c0e89a681b --- /dev/null +++ b/ee/apps/den-api/test/external-mcp-manifests.test.ts @@ -0,0 +1,156 @@ +import { beforeAll, describe, expect, test } from "bun:test" +import { createDenTypeId } from "@openwork-ee/utils/typeid" +import type { ExternalMcpConnectionRow } from "../src/capability-sources/external-mcp-connections.js" +import type { ExternalMcpToolManifestRow } from "../src/capability-sources/external-mcp-manifests.js" + +process.env.DATABASE_URL = process.env.DATABASE_URL ?? "mysql://root:password@127.0.0.1:3306/openwork_test_manifests" +process.env.DEN_DB_ENCRYPTION_KEY = process.env.DEN_DB_ENCRYPTION_KEY ?? "local-dev-db-encryption-key-please-change-1234567890" +process.env.BETTER_AUTH_SECRET = process.env.BETTER_AUTH_SECRET ?? "local-dev-secret-not-for-production-use!!" +process.env.BETTER_AUTH_URL = process.env.BETTER_AUTH_URL ?? "http://127.0.0.1:8790" +process.env.CORS_ORIGINS = process.env.CORS_ORIGINS ?? "http://127.0.0.1:8790" + +let classifyManifest: typeof import("../src/capability-sources/external-mcp-manifests.js").classifyManifest +let computeManifestConfigHash: typeof import("../src/capability-sources/external-mcp-manifests.js").computeManifestConfigHash +let createBoundedManifestRevalidationQueue: typeof import("../src/capability-sources/external-mcp-manifests.js").createBoundedManifestRevalidationQueue +let revalidateManifestWithClaim: typeof import("../src/capability-sources/external-mcp-manifests.js").revalidateManifestWithClaim + +beforeAll(async () => { + const manifests = await import("../src/capability-sources/external-mcp-manifests.js") + classifyManifest = manifests.classifyManifest + computeManifestConfigHash = manifests.computeManifestConfigHash + createBoundedManifestRevalidationQueue = manifests.createBoundedManifestRevalidationQueue + revalidateManifestWithClaim = manifests.revalidateManifestWithClaim +}) + +function connection(url: string): ExternalMcpConnectionRow { + const now = new Date("2026-01-01T00:00:00.000Z") + return { + id: createDenTypeId("externalMcpConnection"), + organizationId: createDenTypeId("organization"), + name: "Test MCP", + url, + authType: "none", + credentialMode: "shared", + apiKey: null, + accessToken: null, + refreshToken: null, + tokenType: null, + scope: null, + expiresAt: null, + pendingCodeVerifier: null, + connectedAt: now, + createdByOrgMembershipId: createDenTypeId("member"), + createdAt: now, + updatedAt: now, + } +} + +function manifestRow(input: { + configHash: string + connection: ExternalMcpConnectionRow + listedAt: Date | null + toolCount: number + tools: ExternalMcpToolManifestRow["tools"] +}): ExternalMcpToolManifestRow { + const now = new Date("2026-01-01T00:00:00.000Z") + return { + id: createDenTypeId("externalMcpToolManifest"), + organizationId: input.connection.organizationId, + externalMcpConnectionId: input.connection.id, + principal: "shared", + configHash: input.configHash, + status: "error", + tools: input.tools, + toolCount: input.toolCount, + toolsHash: input.tools.length > 0 ? "old-tools-hash" : null, + toolsTruncated: false, + lastError: "refresh failed", + durationMs: 7, + listedAt: input.listedAt, + staleAt: now, + refreshStartedAt: null, + createdAt: now, + updatedAt: now, + } +} + +describe("external MCP tool manifests", () => { + test("old-config failure rows classify as misses under the current config", () => { + const oldConnection = connection("https://old.example.com/mcp") + const currentConnection = connection("https://new.example.com/mcp") + const failureRow = manifestRow({ + configHash: computeManifestConfigHash(oldConnection), + connection: currentConnection, + listedAt: null, + toolCount: 0, + tools: [], + }) + + expect(classifyManifest(failureRow, currentConnection).state).toBe("miss") + }) + + test("lease refresh rows do not make old-config tools usable", () => { + const oldConnection = connection("https://old.example.com/mcp") + const currentConnection = connection("https://new.example.com/mcp") + const staleRow = manifestRow({ + configHash: computeManifestConfigHash(oldConnection), + connection: currentConnection, + listedAt: new Date("2026-01-01T00:00:00.000Z"), + toolCount: 1, + tools: [{ name: "old-tool", description: "Tool from the previous server." }], + }) + + expect(classifyManifest(staleRow, currentConnection).state).toBe("miss") + }) + + test("bounded revalidation queue caps in-flight work and drops overflow", async () => { + const queue = createBoundedManifestRevalidationQueue({ concurrency: 2, maxBacklog: 2 }) + let inFlight = 0 + let maxInFlight = 0 + let releaseBlocker = () => undefined + const blocker = new Promise((resolve) => { + releaseBlocker = resolve + }) + + const tasks = [0, 1, 2, 3, 4].map((value) => + queue.enqueue(async () => { + inFlight += 1 + maxInFlight = Math.max(maxInFlight, inFlight) + await blocker + inFlight -= 1 + expect(value).toBeGreaterThanOrEqual(0) + })) + const acceptedTasks = tasks.flatMap((task) => task ? [task] : []) + + expect(acceptedTasks.length).toBe(4) + expect(tasks.filter((task) => task === null).length).toBe(1) + await new Promise((resolve) => setTimeout(resolve, 10)) + expect(maxInFlight).toBeLessThanOrEqual(2) + expect(queue.stats()).toEqual({ active: 2, queued: 2 }) + + releaseBlocker() + await Promise.all(acceptedTasks) + expect(queue.stats()).toEqual({ active: 0, queued: 0 }) + }) + + test("revalidation reports lease_held when another worker owns the lease", async () => { + const currentConnection = connection("https://current.example.com/mcp") + const row = manifestRow({ + configHash: computeManifestConfigHash(currentConnection), + connection: currentConnection, + listedAt: null, + toolCount: 0, + tools: [], + }) + + const result = await revalidateManifestWithClaim({ + connection: currentConnection, + principal: "shared", + redirectUri: "https://den.example.com/v1/mcp-connections/callback", + row, + claimRefresh: async () => false, + }) + + expect(result).toBe("lease_held") + }) +}) diff --git a/ee/apps/den-api/test/mcp-agent-config-policy.test.ts b/ee/apps/den-api/test/mcp-agent-config-policy.test.ts index 1c9cdff0d6..e1f11d73a5 100644 --- a/ee/apps/den-api/test/mcp-agent-config-policy.test.ts +++ b/ee/apps/den-api/test/mcp-agent-config-policy.test.ts @@ -68,6 +68,7 @@ describe("agent-configurable org connections policy", () => { test("discovery surfaces the agent needs are readable", () => { expect(allowed("getV1McpConnections")).toBe(true) expect(allowed("getV1McpConnectionsPresets")).toBe(true) + expect(allowed("postV1McpConnectionsByConnectionIdRefreshTools")).toBe(true) }) test("agent catalog search discovers member list and admin create mcp-connection operations", () => { diff --git a/ee/packages/den-db/drizzle/0037_tranquil_big_bertha.sql b/ee/packages/den-db/drizzle/0037_tranquil_big_bertha.sql new file mode 100644 index 0000000000..72aaa252a5 --- /dev/null +++ b/ee/packages/den-db/drizzle/0037_tranquil_big_bertha.sql @@ -0,0 +1,25 @@ +CREATE TABLE `external_mcp_tool_manifest` ( + `id` varchar(64) NOT NULL, + `organization_id` varchar(64) NOT NULL, + `external_mcp_connection_id` varchar(64) NOT NULL, + `principal` varchar(64) NOT NULL, + `config_hash` varchar(64) NOT NULL, + `status` enum('ok','error') NOT NULL, + `tools` json NOT NULL, + `tool_count` int NOT NULL DEFAULT 0, + `tools_hash` varchar(64), + `tools_truncated` boolean NOT NULL DEFAULT false, + `last_error` text, + `duration_ms` int, + `listed_at` timestamp(3), + `stale_at` timestamp(3), + `refresh_started_at` timestamp(3), + `created_at` timestamp(3) NOT NULL DEFAULT (now()), + `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), + CONSTRAINT `external_mcp_tool_manifest_id` PRIMARY KEY(`id`), + CONSTRAINT `emtm_connection_principal` UNIQUE(`external_mcp_connection_id`,`principal`) +); +--> statement-breakpoint +CREATE INDEX `emtm_organization_id` ON `external_mcp_tool_manifest` (`organization_id`);--> statement-breakpoint +CREATE INDEX `emtm_listed_at` ON `external_mcp_tool_manifest` (`listed_at`);--> statement-breakpoint +CREATE INDEX `emtm_refresh_started_at` ON `external_mcp_tool_manifest` (`refresh_started_at`); \ No newline at end of file diff --git a/ee/packages/den-db/drizzle/meta/0037_snapshot.json b/ee/packages/den-db/drizzle/meta/0037_snapshot.json new file mode 100644 index 0000000000..3940c3bf3c --- /dev/null +++ b/ee/packages/den-db/drizzle/meta/0037_snapshot.json @@ -0,0 +1,9373 @@ +{ + "version": "5", + "dialect": "mysql", + "id": "3af7c061-95b3-4af7-badf-e6550be28502", + "prevId": "b418f1f4-242c-4a59-8ec0-bb5da1911c2d", + "tables": { + "account": { + "name": "account", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "account_user_id": { + "name": "account_user_id", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "account_id": { + "name": "account_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "apikey": { + "name": "apikey", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "config_id": { + "name": "config_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'default'" + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "start": { + "name": "start", + "type": "varchar(32)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "prefix": { + "name": "prefix", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reference_id": { + "name": "reference_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "refill_interval": { + "name": "refill_interval", + "type": "bigint", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refill_amount": { + "name": "refill_amount", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_refill_at": { + "name": "last_refill_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "rate_limit_enabled": { + "name": "rate_limit_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "rate_limit_time_window": { + "name": "rate_limit_time_window", + "type": "bigint", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "rate_limit_max": { + "name": "rate_limit_max", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "request_count": { + "name": "request_count", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": 0 + }, + "remaining": { + "name": "remaining", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_request": { + "name": "last_request", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "permissions": { + "name": "permissions", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "apikey_config_id": { + "name": "apikey_config_id", + "columns": [ + "config_id" + ], + "isUnique": false + }, + "apikey_reference_id": { + "name": "apikey_reference_id", + "columns": [ + "reference_id" + ], + "isUnique": false + }, + "apikey_key": { + "name": "apikey_key", + "columns": [ + "key" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "apikey_id": { + "name": "apikey_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "jwks": { + "name": "jwks", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_key": { + "name": "public_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "private_key": { + "name": "private_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "alg": { + "name": "alg", + "type": "varchar(32)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "crv": { + "name": "crv", + "type": "varchar(32)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "jwks_id": { + "name": "jwks_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "session": { + "name": "session", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "active_organization_id": { + "name": "active_organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "active_team_id": { + "name": "active_team_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "token": { + "name": "token", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "session_token": { + "name": "session_token", + "columns": [ + "token" + ], + "isUnique": true + }, + "session_user_id": { + "name": "session_user_id", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "session_id": { + "name": "session_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "user_email": { + "name": "user_email", + "columns": [ + "email" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "user_id": { + "name": "user_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "verification": { + "name": "verification", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "identifier": { + "name": "identifier", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "verification_identifier": { + "name": "verification_identifier", + "columns": [ + "identifier" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "verification_id": { + "name": "verification_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "external_identity": { + "name": "external_identity", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "scim_provider_id": { + "name": "scim_provider_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "sso_provider_id": { + "name": "sso_provider_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "remote_id": { + "name": "remote_id", + "type": "varchar(191)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "external_id": { + "name": "external_id", + "type": "varchar(191)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_name": { + "name": "user_name", + "type": "varchar(191)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(191)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "display_name": { + "name": "display_name", + "type": "varchar(191)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name_json": { + "name": "name_json", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "emails_json": { + "name": "emails_json", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "attributes_json": { + "name": "attributes_json", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "last_scim_sync_at": { + "name": "last_scim_sync_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_sso_login_at": { + "name": "last_sso_login_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "external_identity_org_user": { + "name": "external_identity_org_user", + "columns": [ + "organization_id", + "user_id" + ], + "isUnique": true + }, + "external_identity_org_sso_remote": { + "name": "external_identity_org_sso_remote", + "columns": [ + "organization_id", + "sso_provider_id", + "remote_id" + ], + "isUnique": true + }, + "external_identity_org_scim_external": { + "name": "external_identity_org_scim_external", + "columns": [ + "organization_id", + "scim_provider_id", + "external_id" + ], + "isUnique": true + }, + "external_identity_org_email": { + "name": "external_identity_org_email", + "columns": [ + "organization_id", + "email" + ], + "isUnique": false + }, + "external_identity_sso_provider": { + "name": "external_identity_sso_provider", + "columns": [ + "sso_provider_id" + ], + "isUnique": false + }, + "external_identity_scim_provider": { + "name": "external_identity_scim_provider", + "columns": [ + "scim_provider_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "external_identity_id": { + "name": "external_identity_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "oauthAccessToken": { + "name": "oauthAccessToken", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "reference_id": { + "name": "reference_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refresh_id": { + "name": "refresh_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "oauth_access_token_client_id": { + "name": "oauth_access_token_client_id", + "columns": [ + "client_id" + ], + "isUnique": false + }, + "oauth_access_token_session_id": { + "name": "oauth_access_token_session_id", + "columns": [ + "session_id" + ], + "isUnique": false + }, + "oauth_access_token_user_id": { + "name": "oauth_access_token_user_id", + "columns": [ + "user_id" + ], + "isUnique": false + }, + "oauth_access_token_reference_id": { + "name": "oauth_access_token_reference_id", + "columns": [ + "reference_id" + ], + "isUnique": false + }, + "oauth_access_token_refresh_id": { + "name": "oauth_access_token_refresh_id", + "columns": [ + "refresh_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "oauthAccessToken_id": { + "name": "oauthAccessToken_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "oauthClient": { + "name": "oauthClient", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_secret": { + "name": "client_secret", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "disabled": { + "name": "disabled", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": false + }, + "skip_consent": { + "name": "skip_consent", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "enable_end_session": { + "name": "enable_end_session", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "subject_type": { + "name": "subject_type", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "uri": { + "name": "uri", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "contacts": { + "name": "contacts", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tos": { + "name": "tos", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "policy": { + "name": "policy", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "software_id": { + "name": "software_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "software_version": { + "name": "software_version", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "software_statement": { + "name": "software_statement", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "redirect_uris": { + "name": "redirect_uris", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "post_logout_redirect_uris": { + "name": "post_logout_redirect_uris", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "token_endpoint_auth_method": { + "name": "token_endpoint_auth_method", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "grant_types": { + "name": "grant_types", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "response_types": { + "name": "response_types", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "public": { + "name": "public", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "require_pkce": { + "name": "require_pkce", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "reference_id": { + "name": "reference_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "oauth_client_client_id": { + "name": "oauth_client_client_id", + "columns": [ + "client_id" + ], + "isUnique": true + }, + "oauth_client_user_id": { + "name": "oauth_client_user_id", + "columns": [ + "user_id" + ], + "isUnique": false + }, + "oauth_client_reference_id": { + "name": "oauth_client_reference_id", + "columns": [ + "reference_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "oauthClient_id": { + "name": "oauthClient_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "oauthConsent": { + "name": "oauthConsent", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "reference_id": { + "name": "reference_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "oauth_consent_client_id": { + "name": "oauth_consent_client_id", + "columns": [ + "client_id" + ], + "isUnique": false + }, + "oauth_consent_user_id": { + "name": "oauth_consent_user_id", + "columns": [ + "user_id" + ], + "isUnique": false + }, + "oauth_consent_reference_id": { + "name": "oauth_consent_reference_id", + "columns": [ + "reference_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "oauthConsent_id": { + "name": "oauthConsent_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "oauthRefreshToken": { + "name": "oauthRefreshToken", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reference_id": { + "name": "reference_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "revoked": { + "name": "revoked", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "auth_time": { + "name": "auth_time", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "oauth_refresh_token_client_id": { + "name": "oauth_refresh_token_client_id", + "columns": [ + "client_id" + ], + "isUnique": false + }, + "oauth_refresh_token_session_id": { + "name": "oauth_refresh_token_session_id", + "columns": [ + "session_id" + ], + "isUnique": false + }, + "oauth_refresh_token_user_id": { + "name": "oauth_refresh_token_user_id", + "columns": [ + "user_id" + ], + "isUnique": false + }, + "oauth_refresh_token_reference_id": { + "name": "oauth_refresh_token_reference_id", + "columns": [ + "reference_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "oauthRefreshToken_id": { + "name": "oauthRefreshToken_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "scim_provider": { + "name": "scim_provider", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider_id": { + "name": "provider_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "scim_token": { + "name": "scim_token", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "scim_provider_provider_id": { + "name": "scim_provider_provider_id", + "columns": [ + "provider_id" + ], + "isUnique": true + }, + "scim_provider_organization_id": { + "name": "scim_provider_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "scim_provider_id": { + "name": "scim_provider_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "scim_sync_event": { + "name": "scim_sync_event", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider_id": { + "name": "provider_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "action": { + "name": "action", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "attempts": { + "name": "attempts", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payload_json": { + "name": "payload_json", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "next_retry_at": { + "name": "next_retry_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "resolved_at": { + "name": "resolved_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "scim_sync_event_org_status": { + "name": "scim_sync_event_org_status", + "columns": [ + "organization_id", + "status" + ], + "isUnique": false + }, + "scim_sync_event_provider_status": { + "name": "scim_sync_event_provider_status", + "columns": [ + "provider_id", + "status" + ], + "isUnique": false + }, + "scim_sync_event_next_retry": { + "name": "scim_sync_event_next_retry", + "columns": [ + "next_retry_at" + ], + "isUnique": false + }, + "scim_sync_event_user": { + "name": "scim_sync_event_user", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "scim_sync_event_id": { + "name": "scim_sync_event_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "sso_connection": { + "name": "sso_connection", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider_id": { + "name": "provider_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "issuer": { + "name": "issuer", + "type": "varchar(2048)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "domain": { + "name": "domain", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'enabled'" + }, + "sign_in_path": { + "name": "sign_in_path", + "type": "varchar(2048)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_tested_at": { + "name": "last_tested_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "sso_connection_organization_id": { + "name": "sso_connection_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": true + }, + "sso_connection_provider_id": { + "name": "sso_connection_provider_id", + "columns": [ + "provider_id" + ], + "isUnique": true + }, + "sso_connection_domain": { + "name": "sso_connection_domain", + "columns": [ + "domain" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "sso_connection_id": { + "name": "sso_connection_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "sso_provider": { + "name": "sso_provider", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "issuer": { + "name": "issuer", + "type": "varchar(2048)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "domain": { + "name": "domain", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "oidc_config": { + "name": "oidc_config", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "saml_config": { + "name": "saml_config", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider_id": { + "name": "provider_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "domain_verified": { + "name": "domain_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "sso_provider_provider_id": { + "name": "sso_provider_provider_id", + "columns": [ + "provider_id" + ], + "isUnique": true + }, + "sso_provider_domain": { + "name": "sso_provider_domain", + "columns": [ + "domain" + ], + "isUnique": false + }, + "sso_provider_organization_id": { + "name": "sso_provider_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "sso_provider_user_id": { + "name": "sso_provider_user_id", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "sso_provider_id": { + "name": "sso_provider_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "desktop_policy_member": { + "name": "desktop_policy_member", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "desktop_policy_id": { + "name": "desktop_policy_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_member_id": { + "name": "org_member_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "team_id": { + "name": "team_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "desktop_policy_member_organization_id": { + "name": "desktop_policy_member_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "desktop_policy_member_policy_id": { + "name": "desktop_policy_member_policy_id", + "columns": [ + "desktop_policy_id" + ], + "isUnique": false + }, + "desktop_policy_member_org_member_id": { + "name": "desktop_policy_member_org_member_id", + "columns": [ + "org_member_id" + ], + "isUnique": false + }, + "desktop_policy_member_team_id": { + "name": "desktop_policy_member_team_id", + "columns": [ + "team_id" + ], + "isUnique": false + }, + "desktop_policy_member_policy_org_member": { + "name": "desktop_policy_member_policy_org_member", + "columns": [ + "desktop_policy_id", + "org_member_id" + ], + "isUnique": true + }, + "desktop_policy_member_policy_team": { + "name": "desktop_policy_member_policy_team", + "columns": [ + "desktop_policy_id", + "team_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "desktop_policy_member_id": { + "name": "desktop_policy_member_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "desktop_policy": { + "name": "desktop_policy", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "policy_name": { + "name": "policy_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_enabled": { + "name": "is_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "priority": { + "name": "priority", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "policy": { + "name": "policy", + "type": "json", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(json_object())" + }, + "created_by_org_member_id": { + "name": "created_by_org_member_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "desktop_policy_organization_id": { + "name": "desktop_policy_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "desktop_policy_created_by_member_id": { + "name": "desktop_policy_created_by_member_id", + "columns": [ + "created_by_org_member_id" + ], + "isUnique": false + }, + "desktop_policy_is_enabled": { + "name": "desktop_policy_is_enabled", + "columns": [ + "is_enabled" + ], + "isUnique": false + }, + "desktop_policy_priority": { + "name": "desktop_policy_priority", + "columns": [ + "priority" + ], + "isUnique": false + }, + "desktop_policy_deleted_at": { + "name": "desktop_policy_deleted_at", + "columns": [ + "deleted_at" + ], + "isUnique": false + }, + "desktop_policy_org_default": { + "name": "desktop_policy_org_default", + "columns": [ + "organization_id", + "is_default" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "desktop_policy_id": { + "name": "desktop_policy_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "organization_diagnostic_credential": { + "name": "organization_diagnostic_credential", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "bearer_token": { + "name": "bearer_token", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "organization_diagnostic_credential_organization_id": { + "name": "organization_diagnostic_credential_organization_id", + "columns": [ + "organization_id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "inference_keys": { + "name": "inference_keys", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_membership_id": { + "name": "org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "key_hash": { + "name": "key_hash", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "key_prefix": { + "name": "key_prefix", + "type": "varchar(32)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "enum('active','revoked')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'active'" + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "inference_keys_key_hash": { + "name": "inference_keys_key_hash", + "columns": [ + "key_hash" + ], + "isUnique": true + }, + "inference_keys_organization_id": { + "name": "inference_keys_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "inference_keys_org_membership_id": { + "name": "inference_keys_org_membership_id", + "columns": [ + "org_membership_id" + ], + "isUnique": false + }, + "inference_keys_status": { + "name": "inference_keys_status", + "columns": [ + "status" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "inference_keys_id": { + "name": "inference_keys_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "inference_org_limit_policies": { + "name": "inference_org_limit_policies", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "window_type": { + "name": "window_type", + "type": "enum('five_hour','weekly','monthly')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reset_strategy": { + "name": "reset_strategy", + "type": "enum('anchored','activity_based')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "anchor_at": { + "name": "anchor_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "current_bucket_id": { + "name": "current_bucket_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "inference_org_limit_policies_organization_id": { + "name": "inference_org_limit_policies_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "inference_org_limit_policies_org_window_type": { + "name": "inference_org_limit_policies_org_window_type", + "columns": [ + "organization_id", + "window_type" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "inference_org_limit_policies_id": { + "name": "inference_org_limit_policies_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "inference_org_upstream_provider_keys": { + "name": "inference_org_upstream_provider_keys", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'openrouter'" + }, + "external_key_hash": { + "name": "external_key_hash", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "external_workspace_id": { + "name": "external_workspace_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "encrypted_api_key": { + "name": "encrypted_api_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "key_prefix": { + "name": "key_prefix", + "type": "varchar(32)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "enum('active','revoked')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'active'" + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "inference_org_upstream_provider_keys_organization_id": { + "name": "inference_org_upstream_provider_keys_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "inference_org_upstream_provider_keys_external_key_hash": { + "name": "inference_org_upstream_provider_keys_external_key_hash", + "columns": [ + "external_key_hash" + ], + "isUnique": false + }, + "inference_org_upstream_provider_keys_org_provider": { + "name": "inference_org_upstream_provider_keys_org_provider", + "columns": [ + "organization_id", + "provider" + ], + "isUnique": true + }, + "inference_org_upstream_provider_keys_status": { + "name": "inference_org_upstream_provider_keys_status", + "columns": [ + "status" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "inference_org_upstream_provider_keys_id": { + "name": "inference_org_upstream_provider_keys_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "inference_org_usage_buckets": { + "name": "inference_org_usage_buckets", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "policy_id": { + "name": "policy_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "window_start_at": { + "name": "window_start_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "window_end_at": { + "name": "window_end_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "limit_amount": { + "name": "limit_amount", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "used_amount": { + "name": "used_amount", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "inference_org_usage_buckets_org_window": { + "name": "inference_org_usage_buckets_org_window", + "columns": [ + "organization_id", + "window_start_at", + "window_end_at" + ], + "isUnique": false + }, + "inference_org_usage_buckets_policy_id": { + "name": "inference_org_usage_buckets_policy_id", + "columns": [ + "policy_id" + ], + "isUnique": false + }, + "inference_org_usage_buckets_policy_window": { + "name": "inference_org_usage_buckets_policy_window", + "columns": [ + "policy_id", + "window_start_at", + "window_end_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "inference_org_usage_buckets_id": { + "name": "inference_org_usage_buckets_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "inference_usage_ledger_bucket_charges": { + "name": "inference_usage_ledger_bucket_charges", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ledger_entry_id": { + "name": "ledger_entry_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "bucket_id": { + "name": "bucket_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "inference_usage_ledger_bucket_charges_bucket_id": { + "name": "inference_usage_ledger_bucket_charges_bucket_id", + "columns": [ + "bucket_id" + ], + "isUnique": false + }, + "inference_usage_ledger_bucket_charges_entry_bucket": { + "name": "inference_usage_ledger_bucket_charges_entry_bucket", + "columns": [ + "ledger_entry_id", + "bucket_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "inference_usage_ledger_bucket_charges_id": { + "name": "inference_usage_ledger_bucket_charges_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "inference_usage_ledger_entries": { + "name": "inference_usage_ledger_entries", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_membership_id": { + "name": "org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "inference_key_id": { + "name": "inference_key_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "external_job_id": { + "name": "external_job_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_event_id": { + "name": "external_event_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cost_amount": { + "name": "cost_amount", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "event_type": { + "name": "event_type", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "occurred_at": { + "name": "occurred_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "inference_usage_ledger_entries_organization_id": { + "name": "inference_usage_ledger_entries_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "inference_usage_ledger_entries_org_membership_id": { + "name": "inference_usage_ledger_entries_org_membership_id", + "columns": [ + "org_membership_id" + ], + "isUnique": false + }, + "inference_usage_ledger_entries_inference_key_id": { + "name": "inference_usage_ledger_entries_inference_key_id", + "columns": [ + "inference_key_id" + ], + "isUnique": false + }, + "inference_usage_ledger_entries_external_event_id": { + "name": "inference_usage_ledger_entries_external_event_id", + "columns": [ + "external_event_id" + ], + "isUnique": true + }, + "inference_usage_ledger_entries_job_event_type": { + "name": "inference_usage_ledger_entries_job_event_type", + "columns": [ + "external_job_id", + "event_type" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "inference_usage_ledger_entries_id": { + "name": "inference_usage_ledger_entries_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "memory_context": { + "name": "memory_context", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "memory_id": { + "name": "memory_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "citation": { + "name": "citation", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "snippet": { + "name": "snippet", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "origin": { + "name": "origin", + "type": "enum('active_conversation','searched_conversation')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "memory_context_memory_id": { + "name": "memory_context_memory_id", + "columns": [ + "memory_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "memory_context_id": { + "name": "memory_context_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "memory": { + "name": "memory", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_id": { + "name": "org_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "scope": { + "name": "scope", + "type": "enum('user','org')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'user'" + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tags": { + "name": "tags", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "memory_user_id": { + "name": "memory_user_id", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "memory_id": { + "name": "memory_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "desktop_handoff_grant": { + "name": "desktop_handoff_grant", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_token": { + "name": "session_token", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "consumed_at": { + "name": "consumed_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "desktop_handoff_grant_user_id": { + "name": "desktop_handoff_grant_user_id", + "columns": [ + "user_id" + ], + "isUnique": false + }, + "desktop_handoff_grant_expires_at": { + "name": "desktop_handoff_grant_expires_at", + "columns": [ + "expires_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "desktop_handoff_grant_id": { + "name": "desktop_handoff_grant_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "install_link": { + "name": "install_link", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_hash": { + "name": "token_hash", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "install_link_token_hash": { + "name": "install_link_token_hash", + "columns": [ + "token_hash" + ], + "isUnique": true + }, + "install_link_organization_id": { + "name": "install_link_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "install_link_created_by_user_id": { + "name": "install_link_created_by_user_id", + "columns": [ + "created_by_user_id" + ], + "isUnique": false + }, + "install_link_revoked_at": { + "name": "install_link_revoked_at", + "columns": [ + "revoked_at" + ], + "isUnique": false + }, + "install_link_expires_at": { + "name": "install_link_expires_at", + "columns": [ + "expires_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "install_link_id": { + "name": "install_link_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "invitation": { + "name": "invitation", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "team_id": { + "name": "team_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "inviter_id": { + "name": "inviter_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_member_id": { + "name": "org_member_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "invite_token": { + "name": "invite_token", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "invitation_organization_id": { + "name": "invitation_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "invitation_email": { + "name": "invitation_email", + "columns": [ + "email" + ], + "isUnique": false + }, + "invitation_status": { + "name": "invitation_status", + "columns": [ + "status" + ], + "isUnique": false + }, + "invitation_team_id": { + "name": "invitation_team_id", + "columns": [ + "team_id" + ], + "isUnique": false + }, + "invitation_org_member_id": { + "name": "invitation_org_member_id", + "columns": [ + "org_member_id" + ], + "isUnique": false + }, + "invitation_invite_token": { + "name": "invitation_invite_token", + "columns": [ + "invite_token" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "invitation_id": { + "name": "invitation_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "member": { + "name": "member", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "invite_id": { + "name": "invite_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "invited_by_org_member": { + "name": "invited_by_org_member", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'member'" + }, + "joined_at": { + "name": "joined_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": "(now())" + }, + "removed_at": { + "name": "removed_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "removed_by_org_member": { + "name": "removed_by_org_member", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "member_organization_id": { + "name": "member_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "member_user_id": { + "name": "member_user_id", + "columns": [ + "user_id" + ], + "isUnique": false + }, + "member_invite_id": { + "name": "member_invite_id", + "columns": [ + "invite_id" + ], + "isUnique": false + }, + "member_invited_by_org_member": { + "name": "member_invited_by_org_member", + "columns": [ + "invited_by_org_member" + ], + "isUnique": false + }, + "member_removed_at": { + "name": "member_removed_at", + "columns": [ + "removed_at" + ], + "isUnique": false + }, + "member_removed_by_org_member": { + "name": "member_removed_by_org_member", + "columns": [ + "removed_by_org_member" + ], + "isUnique": false + }, + "member_organization_user": { + "name": "member_organization_user", + "columns": [ + "organization_id", + "user_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "member_id": { + "name": "member_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "organization_brand_asset": { + "name": "organization_brand_asset", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "extension": { + "name": "extension", + "type": "varchar(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "bytes": { + "name": "bytes", + "type": "mediumblob", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "organization_brand_asset_organization_id": { + "name": "organization_brand_asset_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "organization_brand_asset_version": { + "name": "organization_brand_asset_version", + "columns": [ + "organization_id", + "kind", + "version", + "extension" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "organization_brand_asset_id": { + "name": "organization_brand_asset_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "organization_role": { + "name": "organization_role", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "permission": { + "name": "permission", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "organization_role_organization_id": { + "name": "organization_role_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "organization_role_name": { + "name": "organization_role_name", + "columns": [ + "organization_id", + "role" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "organization_role_id": { + "name": "organization_role_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "organization": { + "name": "organization", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "logo": { + "name": "logo", + "type": "varchar(2048)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "allowed_email_domains": { + "name": "allowed_email_domains", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "desktop_app_restrictions": { + "name": "desktop_app_restrictions", + "type": "json", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(json_object())" + }, + "metadata": { + "name": "metadata", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "organization_slug": { + "name": "organization_slug", + "columns": [ + "slug" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "organization_id": { + "name": "organization_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "workspace_bootstrap": { + "name": "workspace_bootstrap", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "setup_member_id": { + "name": "setup_member_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "device_public_key": { + "name": "device_public_key", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "device_key_fingerprint": { + "name": "device_key_fingerprint", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'provisional'" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "claimed_at": { + "name": "claimed_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "workspace_bootstrap_organization_id": { + "name": "workspace_bootstrap_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "workspace_bootstrap_status": { + "name": "workspace_bootstrap_status", + "columns": [ + "status" + ], + "isUnique": false + }, + "workspace_bootstrap_expires_at": { + "name": "workspace_bootstrap_expires_at", + "columns": [ + "expires_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_bootstrap_id": { + "name": "workspace_bootstrap_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "workspace_claim": { + "name": "workspace_claim", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "bootstrap_id": { + "name": "bootstrap_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_hash": { + "name": "token_hash", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "claimed_by_user_id": { + "name": "claimed_by_user_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "claimed_at": { + "name": "claimed_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "workspace_claim_token_hash": { + "name": "workspace_claim_token_hash", + "columns": [ + "token_hash" + ], + "isUnique": true + }, + "workspace_claim_bootstrap_id": { + "name": "workspace_claim_bootstrap_id", + "columns": [ + "bootstrap_id" + ], + "isUnique": false + }, + "workspace_claim_organization_id": { + "name": "workspace_claim_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "workspace_claim_status": { + "name": "workspace_claim_status", + "columns": [ + "status" + ], + "isUnique": false + }, + "workspace_claim_expires_at": { + "name": "workspace_claim_expires_at", + "columns": [ + "expires_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_claim_id": { + "name": "workspace_claim_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "connected_account": { + "name": "connected_account", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_membership_id": { + "name": "org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider_id": { + "name": "provider_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_account_id": { + "name": "external_account_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scopes": { + "name": "scopes", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "token_type": { + "name": "token_type", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pending_code_verifier": { + "name": "pending_code_verifier", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "connected_at": { + "name": "connected_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "connected_account_organization_id": { + "name": "connected_account_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "connected_account_org_membership_id": { + "name": "connected_account_org_membership_id", + "columns": [ + "org_membership_id" + ], + "isUnique": false + }, + "connected_account_member_provider": { + "name": "connected_account_member_provider", + "columns": [ + "org_membership_id", + "provider_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "connected_account_id": { + "name": "connected_account_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "external_mcp_connection_access_grant": { + "name": "external_mcp_connection_access_grant", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_mcp_connection_id": { + "name": "external_mcp_connection_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_membership_id": { + "name": "org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "team_id": { + "name": "team_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "org_wide": { + "name": "org_wide", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_by_org_membership_id": { + "name": "created_by_org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "emc_access_grant_organization_id": { + "name": "emc_access_grant_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "emc_access_grant_connection_id": { + "name": "emc_access_grant_connection_id", + "columns": [ + "external_mcp_connection_id" + ], + "isUnique": false + }, + "emc_access_grant_org_membership_id": { + "name": "emc_access_grant_org_membership_id", + "columns": [ + "org_membership_id" + ], + "isUnique": false + }, + "emc_access_grant_team_id": { + "name": "emc_access_grant_team_id", + "columns": [ + "team_id" + ], + "isUnique": false + }, + "emc_access_grant_connection_member": { + "name": "emc_access_grant_connection_member", + "columns": [ + "external_mcp_connection_id", + "org_membership_id" + ], + "isUnique": true + }, + "emc_access_grant_connection_team": { + "name": "emc_access_grant_connection_team", + "columns": [ + "external_mcp_connection_id", + "team_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "external_mcp_connection_access_grant_id": { + "name": "external_mcp_connection_access_grant_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "external_mcp_connection": { + "name": "external_mcp_connection", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "url": { + "name": "url", + "type": "varchar(2048)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "auth_type": { + "name": "auth_type", + "type": "enum('oauth','apikey','none')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_mode": { + "name": "credential_mode", + "type": "enum('shared','per_member')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'shared'" + }, + "api_key": { + "name": "api_key", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "token_type": { + "name": "token_type", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scope": { + "name": "scope", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pending_code_verifier": { + "name": "pending_code_verifier", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "connected_at": { + "name": "connected_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by_org_membership_id": { + "name": "created_by_org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "external_mcp_connection_organization_id": { + "name": "external_mcp_connection_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "external_mcp_connection_id": { + "name": "external_mcp_connection_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "org_oauth_client": { + "name": "org_oauth_client", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider_id": { + "name": "provider_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_secret": { + "name": "client_secret", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "extra": { + "name": "extra", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by_org_membership_id": { + "name": "created_by_org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "org_oauth_client_organization_id": { + "name": "org_oauth_client_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "org_oauth_client_org_provider": { + "name": "org_oauth_client_org_provider", + "columns": [ + "organization_id", + "provider_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "org_oauth_client_id": { + "name": "org_oauth_client_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "external_mcp_tool_manifest": { + "name": "external_mcp_tool_manifest", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_mcp_connection_id": { + "name": "external_mcp_connection_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "principal": { + "name": "principal", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "config_hash": { + "name": "config_hash", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "enum('ok','error')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tools": { + "name": "tools", + "type": "json", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tool_count": { + "name": "tool_count", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "tools_hash": { + "name": "tools_hash", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tools_truncated": { + "name": "tools_truncated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "duration_ms": { + "name": "duration_ms", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "listed_at": { + "name": "listed_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "stale_at": { + "name": "stale_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refresh_started_at": { + "name": "refresh_started_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "emtm_connection_principal": { + "name": "emtm_connection_principal", + "columns": [ + "external_mcp_connection_id", + "principal" + ], + "isUnique": true + }, + "emtm_organization_id": { + "name": "emtm_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "emtm_listed_at": { + "name": "emtm_listed_at", + "columns": [ + "listed_at" + ], + "isUnique": false + }, + "emtm_refresh_started_at": { + "name": "emtm_refresh_started_at", + "columns": [ + "refresh_started_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "external_mcp_tool_manifest_id": { + "name": "external_mcp_tool_manifest_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "llm_provider_access": { + "name": "llm_provider_access", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "llm_provider_id": { + "name": "llm_provider_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_membership_id": { + "name": "org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "team_id": { + "name": "team_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "llm_provider_access_llm_provider_id": { + "name": "llm_provider_access_llm_provider_id", + "columns": [ + "llm_provider_id" + ], + "isUnique": false + }, + "llm_provider_access_org_membership_id": { + "name": "llm_provider_access_org_membership_id", + "columns": [ + "org_membership_id" + ], + "isUnique": false + }, + "llm_provider_access_team_id": { + "name": "llm_provider_access_team_id", + "columns": [ + "team_id" + ], + "isUnique": false + }, + "llm_provider_access_provider_org_membership": { + "name": "llm_provider_access_provider_org_membership", + "columns": [ + "llm_provider_id", + "org_membership_id" + ], + "isUnique": true + }, + "llm_provider_access_provider_team": { + "name": "llm_provider_access_provider_team", + "columns": [ + "llm_provider_id", + "team_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "llm_provider_access_id": { + "name": "llm_provider_access_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "llm_provider_model": { + "name": "llm_provider_model", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "llm_provider_id": { + "name": "llm_provider_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "model_id": { + "name": "model_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "model_config": { + "name": "model_config", + "type": "json", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "llm_provider_model_llm_provider_id": { + "name": "llm_provider_model_llm_provider_id", + "columns": [ + "llm_provider_id" + ], + "isUnique": false + }, + "llm_provider_model_model_id": { + "name": "llm_provider_model_model_id", + "columns": [ + "model_id" + ], + "isUnique": false + }, + "llm_provider_model_provider_model": { + "name": "llm_provider_model_provider_model", + "columns": [ + "llm_provider_id", + "model_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "llm_provider_model_id": { + "name": "llm_provider_model_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "llm_provider": { + "name": "llm_provider", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by_org_membership_id": { + "name": "created_by_org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "enum('models_dev','custom','openwork')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider_id": { + "name": "provider_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider_config": { + "name": "provider_config", + "type": "json", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "api_key": { + "name": "api_key", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "llm_provider_organization_id": { + "name": "llm_provider_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "llm_provider_created_by_org_membership_id": { + "name": "llm_provider_created_by_org_membership_id", + "columns": [ + "created_by_org_membership_id" + ], + "isUnique": false + }, + "llm_provider_source": { + "name": "llm_provider_source", + "columns": [ + "source" + ], + "isUnique": false + }, + "llm_provider_provider_id": { + "name": "llm_provider_provider_id", + "columns": [ + "provider_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "llm_provider_id": { + "name": "llm_provider_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "config_object_access_grant": { + "name": "config_object_access_grant", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "config_object_id": { + "name": "config_object_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_membership_id": { + "name": "org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "team_id": { + "name": "team_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "org_wide": { + "name": "org_wide", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "role": { + "name": "role", + "type": "enum('viewer','editor','manager')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by_org_membership_id": { + "name": "created_by_org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "removed_at": { + "name": "removed_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "config_object_access_grant_organization_id": { + "name": "config_object_access_grant_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "config_object_access_grant_config_object_id": { + "name": "config_object_access_grant_config_object_id", + "columns": [ + "config_object_id" + ], + "isUnique": false + }, + "config_object_access_grant_org_membership_id": { + "name": "config_object_access_grant_org_membership_id", + "columns": [ + "org_membership_id" + ], + "isUnique": false + }, + "config_object_access_grant_team_id": { + "name": "config_object_access_grant_team_id", + "columns": [ + "team_id" + ], + "isUnique": false + }, + "config_object_access_grant_org_wide": { + "name": "config_object_access_grant_org_wide", + "columns": [ + "org_wide" + ], + "isUnique": false + }, + "config_object_access_grant_object_org_membership": { + "name": "config_object_access_grant_object_org_membership", + "columns": [ + "config_object_id", + "org_membership_id" + ], + "isUnique": true + }, + "config_object_access_grant_object_team": { + "name": "config_object_access_grant_object_team", + "columns": [ + "config_object_id", + "team_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "config_object_access_grant_id": { + "name": "config_object_access_grant_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "config_object": { + "name": "config_object", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "object_type": { + "name": "object_type", + "type": "enum('skill','agent','command','tool','mcp','hook','context','custom')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source_mode": { + "name": "source_mode", + "type": "enum('cloud','import','connector')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "search_text": { + "name": "search_text", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "current_file_name": { + "name": "current_file_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "current_file_extension": { + "name": "current_file_extension", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "current_relative_path": { + "name": "current_relative_path", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "enum('active','inactive','deleted','archived','ingestion_error')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'active'" + }, + "created_by_org_membership_id": { + "name": "created_by_org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "connector_instance_id": { + "name": "connector_instance_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "config_object_organization_id": { + "name": "config_object_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "config_object_type": { + "name": "config_object_type", + "columns": [ + "object_type" + ], + "isUnique": false + }, + "config_object_source_mode": { + "name": "config_object_source_mode", + "columns": [ + "source_mode" + ], + "isUnique": false + }, + "config_object_status": { + "name": "config_object_status", + "columns": [ + "status" + ], + "isUnique": false + }, + "config_object_created_by_org_membership_id": { + "name": "config_object_created_by_org_membership_id", + "columns": [ + "created_by_org_membership_id" + ], + "isUnique": false + }, + "config_object_connector_instance_id": { + "name": "config_object_connector_instance_id", + "columns": [ + "connector_instance_id" + ], + "isUnique": false + }, + "config_object_current_relative_path": { + "name": "config_object_current_relative_path", + "columns": [ + "current_relative_path" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "config_object_id": { + "name": "config_object_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "config_object_version": { + "name": "config_object_version", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "config_object_id": { + "name": "config_object_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "normalized_payload_json": { + "name": "normalized_payload_json", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "raw_source_text": { + "name": "raw_source_text", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "schema_version": { + "name": "schema_version", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_via": { + "name": "created_via", + "type": "enum('cloud','import','connector','system')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by_org_membership_id": { + "name": "created_by_org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "connector_sync_event_id": { + "name": "connector_sync_event_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source_revision_ref": { + "name": "source_revision_ref", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_deleted_version": { + "name": "is_deleted_version", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "config_object_version_organization_id": { + "name": "config_object_version_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "config_object_version_config_object_id": { + "name": "config_object_version_config_object_id", + "columns": [ + "config_object_id" + ], + "isUnique": false + }, + "config_object_version_created_by_org_membership_id": { + "name": "config_object_version_created_by_org_membership_id", + "columns": [ + "created_by_org_membership_id" + ], + "isUnique": false + }, + "config_object_version_connector_sync_event_id": { + "name": "config_object_version_connector_sync_event_id", + "columns": [ + "connector_sync_event_id" + ], + "isUnique": false + }, + "config_object_version_source_revision_ref": { + "name": "config_object_version_source_revision_ref", + "columns": [ + "source_revision_ref" + ], + "isUnique": false + }, + "config_object_version_lookup_latest": { + "name": "config_object_version_lookup_latest", + "columns": [ + "config_object_id", + "created_at", + "id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "config_object_version_id": { + "name": "config_object_version_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "connector_account": { + "name": "connector_account", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "connector_type": { + "name": "connector_type", + "type": "enum('github')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "remote_id": { + "name": "remote_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_account_ref": { + "name": "external_account_ref", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "display_name": { + "name": "display_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "enum('active','inactive','disconnected','error')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'active'" + }, + "created_by_org_membership_id": { + "name": "created_by_org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "metadata_json": { + "name": "metadata_json", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "connector_account_organization_id": { + "name": "connector_account_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "connector_account_created_by_org_membership_id": { + "name": "connector_account_created_by_org_membership_id", + "columns": [ + "created_by_org_membership_id" + ], + "isUnique": false + }, + "connector_account_connector_type": { + "name": "connector_account_connector_type", + "columns": [ + "connector_type" + ], + "isUnique": false + }, + "connector_account_status": { + "name": "connector_account_status", + "columns": [ + "status" + ], + "isUnique": false + }, + "connector_account_org_type_remote_id": { + "name": "connector_account_org_type_remote_id", + "columns": [ + "organization_id", + "connector_type", + "remote_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "connector_account_id": { + "name": "connector_account_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "connector_instance_access_grant": { + "name": "connector_instance_access_grant", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "connector_instance_id": { + "name": "connector_instance_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_membership_id": { + "name": "org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "team_id": { + "name": "team_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "org_wide": { + "name": "org_wide", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "role": { + "name": "role", + "type": "enum('viewer','editor','manager')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by_org_membership_id": { + "name": "created_by_org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "removed_at": { + "name": "removed_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "connector_instance_access_grant_organization_id": { + "name": "connector_instance_access_grant_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "connector_instance_access_grant_instance_id": { + "name": "connector_instance_access_grant_instance_id", + "columns": [ + "connector_instance_id" + ], + "isUnique": false + }, + "connector_instance_access_grant_org_membership_id": { + "name": "connector_instance_access_grant_org_membership_id", + "columns": [ + "org_membership_id" + ], + "isUnique": false + }, + "connector_instance_access_grant_team_id": { + "name": "connector_instance_access_grant_team_id", + "columns": [ + "team_id" + ], + "isUnique": false + }, + "connector_instance_access_grant_org_wide": { + "name": "connector_instance_access_grant_org_wide", + "columns": [ + "org_wide" + ], + "isUnique": false + }, + "connector_instance_access_grant_instance_org_membership": { + "name": "connector_instance_access_grant_instance_org_membership", + "columns": [ + "connector_instance_id", + "org_membership_id" + ], + "isUnique": true + }, + "connector_instance_access_grant_instance_team": { + "name": "connector_instance_access_grant_instance_team", + "columns": [ + "connector_instance_id", + "team_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "connector_instance_access_grant_id": { + "name": "connector_instance_access_grant_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "connector_instance": { + "name": "connector_instance", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "connector_account_id": { + "name": "connector_account_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "connector_type": { + "name": "connector_type", + "type": "enum('github')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "remote_id": { + "name": "remote_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "enum('active','disabled','archived','error')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'active'" + }, + "instance_config_json": { + "name": "instance_config_json", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_synced_at": { + "name": "last_synced_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_sync_status": { + "name": "last_sync_status", + "type": "enum('pending','queued','running','completed','failed','partial','ignored')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_sync_cursor": { + "name": "last_sync_cursor", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by_org_membership_id": { + "name": "created_by_org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "connector_instance_organization_id": { + "name": "connector_instance_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "connector_instance_connector_account_id": { + "name": "connector_instance_connector_account_id", + "columns": [ + "connector_account_id" + ], + "isUnique": false + }, + "connector_instance_created_by_org_membership_id": { + "name": "connector_instance_created_by_org_membership_id", + "columns": [ + "created_by_org_membership_id" + ], + "isUnique": false + }, + "connector_instance_connector_type": { + "name": "connector_instance_connector_type", + "columns": [ + "connector_type" + ], + "isUnique": false + }, + "connector_instance_status": { + "name": "connector_instance_status", + "columns": [ + "status" + ], + "isUnique": false + }, + "connector_instance_org_name": { + "name": "connector_instance_org_name", + "columns": [ + "organization_id", + "name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "connector_instance_id": { + "name": "connector_instance_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "connector_mapping": { + "name": "connector_mapping", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "connector_instance_id": { + "name": "connector_instance_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "connector_target_id": { + "name": "connector_target_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "connector_type": { + "name": "connector_type", + "type": "enum('github')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "remote_id": { + "name": "remote_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "mapping_kind": { + "name": "mapping_kind", + "type": "enum('path','api','custom')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "selector": { + "name": "selector", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "object_type": { + "name": "object_type", + "type": "enum('skill','agent','command','tool','mcp','hook','context','custom')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "plugin_id": { + "name": "plugin_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "auto_add_to_plugin": { + "name": "auto_add_to_plugin", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "mapping_config_json": { + "name": "mapping_config_json", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "connector_mapping_organization_id": { + "name": "connector_mapping_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "connector_mapping_connector_instance_id": { + "name": "connector_mapping_connector_instance_id", + "columns": [ + "connector_instance_id" + ], + "isUnique": false + }, + "connector_mapping_connector_target_id": { + "name": "connector_mapping_connector_target_id", + "columns": [ + "connector_target_id" + ], + "isUnique": false + }, + "connector_mapping_object_type": { + "name": "connector_mapping_object_type", + "columns": [ + "object_type" + ], + "isUnique": false + }, + "connector_mapping_plugin_id": { + "name": "connector_mapping_plugin_id", + "columns": [ + "plugin_id" + ], + "isUnique": false + }, + "connector_mapping_target_selector_object_type": { + "name": "connector_mapping_target_selector_object_type", + "columns": [ + "connector_target_id", + "selector", + "object_type" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "connector_mapping_id": { + "name": "connector_mapping_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "connector_source_binding": { + "name": "connector_source_binding", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "config_object_id": { + "name": "config_object_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "connector_instance_id": { + "name": "connector_instance_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "connector_target_id": { + "name": "connector_target_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "connector_mapping_id": { + "name": "connector_mapping_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "connector_type": { + "name": "connector_type", + "type": "enum('github')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "remote_id": { + "name": "remote_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "external_locator": { + "name": "external_locator", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_stable_ref": { + "name": "external_stable_ref", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_seen_source_revision_ref": { + "name": "last_seen_source_revision_ref", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "enum('active','inactive','deleted','archived','ingestion_error')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'active'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "connector_source_binding_organization_id": { + "name": "connector_source_binding_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "connector_source_binding_config_object_id": { + "name": "connector_source_binding_config_object_id", + "columns": [ + "config_object_id" + ], + "isUnique": false + }, + "connector_source_binding_connector_instance_id": { + "name": "connector_source_binding_connector_instance_id", + "columns": [ + "connector_instance_id" + ], + "isUnique": false + }, + "connector_source_binding_connector_target_id": { + "name": "connector_source_binding_connector_target_id", + "columns": [ + "connector_target_id" + ], + "isUnique": false + }, + "connector_source_binding_connector_mapping_id": { + "name": "connector_source_binding_connector_mapping_id", + "columns": [ + "connector_mapping_id" + ], + "isUnique": false + }, + "connector_source_binding_external_locator": { + "name": "connector_source_binding_external_locator", + "columns": [ + "external_locator" + ], + "isUnique": false + }, + "connector_source_binding_config_object": { + "name": "connector_source_binding_config_object", + "columns": [ + "config_object_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "connector_source_binding_id": { + "name": "connector_source_binding_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "connector_source_tombstone": { + "name": "connector_source_tombstone", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "connector_instance_id": { + "name": "connector_instance_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "connector_target_id": { + "name": "connector_target_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "connector_mapping_id": { + "name": "connector_mapping_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "connector_type": { + "name": "connector_type", + "type": "enum('github')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "remote_id": { + "name": "remote_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "external_locator": { + "name": "external_locator", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "former_config_object_id": { + "name": "former_config_object_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "deleted_in_sync_event_id": { + "name": "deleted_in_sync_event_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "deleted_source_revision_ref": { + "name": "deleted_source_revision_ref", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "connector_source_tombstone_organization_id": { + "name": "connector_source_tombstone_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "connector_source_tombstone_connector_instance_id": { + "name": "connector_source_tombstone_connector_instance_id", + "columns": [ + "connector_instance_id" + ], + "isUnique": false + }, + "connector_source_tombstone_connector_target_id": { + "name": "connector_source_tombstone_connector_target_id", + "columns": [ + "connector_target_id" + ], + "isUnique": false + }, + "connector_source_tombstone_connector_mapping_id": { + "name": "connector_source_tombstone_connector_mapping_id", + "columns": [ + "connector_mapping_id" + ], + "isUnique": false + }, + "connector_source_tombstone_external_locator": { + "name": "connector_source_tombstone_external_locator", + "columns": [ + "external_locator" + ], + "isUnique": false + }, + "connector_source_tombstone_former_config_object_id": { + "name": "connector_source_tombstone_former_config_object_id", + "columns": [ + "former_config_object_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "connector_source_tombstone_id": { + "name": "connector_source_tombstone_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "connector_sync_event": { + "name": "connector_sync_event", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "connector_instance_id": { + "name": "connector_instance_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "connector_target_id": { + "name": "connector_target_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "connector_type": { + "name": "connector_type", + "type": "enum('github')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "remote_id": { + "name": "remote_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "event_type": { + "name": "event_type", + "type": "enum('push','installation','installation_repositories','repository','manual_resync')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_event_ref": { + "name": "external_event_ref", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source_revision_ref": { + "name": "source_revision_ref", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "enum('pending','queued','running','completed','failed','partial','ignored')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "summary_json": { + "name": "summary_json", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "started_at": { + "name": "started_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "connector_sync_event_organization_id": { + "name": "connector_sync_event_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "connector_sync_event_connector_instance_id": { + "name": "connector_sync_event_connector_instance_id", + "columns": [ + "connector_instance_id" + ], + "isUnique": false + }, + "connector_sync_event_connector_target_id": { + "name": "connector_sync_event_connector_target_id", + "columns": [ + "connector_target_id" + ], + "isUnique": false + }, + "connector_sync_event_event_type": { + "name": "connector_sync_event_event_type", + "columns": [ + "event_type" + ], + "isUnique": false + }, + "connector_sync_event_status": { + "name": "connector_sync_event_status", + "columns": [ + "status" + ], + "isUnique": false + }, + "connector_sync_event_source_revision_ref": { + "name": "connector_sync_event_source_revision_ref", + "columns": [ + "source_revision_ref" + ], + "isUnique": false + }, + "connector_sync_event_external_event_ref": { + "name": "connector_sync_event_external_event_ref", + "columns": [ + "external_event_ref" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "connector_sync_event_id": { + "name": "connector_sync_event_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "connector_target": { + "name": "connector_target", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "connector_instance_id": { + "name": "connector_instance_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "connector_type": { + "name": "connector_type", + "type": "enum('github')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "remote_id": { + "name": "remote_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_kind": { + "name": "target_kind", + "type": "enum('repository_branch')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_target_ref": { + "name": "external_target_ref", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_config_json": { + "name": "target_config_json", + "type": "json", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "connector_target_organization_id": { + "name": "connector_target_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "connector_target_connector_instance_id": { + "name": "connector_target_connector_instance_id", + "columns": [ + "connector_instance_id" + ], + "isUnique": false + }, + "connector_target_connector_type": { + "name": "connector_target_connector_type", + "columns": [ + "connector_type" + ], + "isUnique": false + }, + "connector_target_target_kind": { + "name": "connector_target_target_kind", + "columns": [ + "target_kind" + ], + "isUnique": false + }, + "connector_target_instance_remote_id": { + "name": "connector_target_instance_remote_id", + "columns": [ + "connector_instance_id", + "remote_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "connector_target_id": { + "name": "connector_target_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "marketplace_access_grant": { + "name": "marketplace_access_grant", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "marketplace_id": { + "name": "marketplace_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_membership_id": { + "name": "org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "team_id": { + "name": "team_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "org_wide": { + "name": "org_wide", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "role": { + "name": "role", + "type": "enum('viewer','editor','manager')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by_org_membership_id": { + "name": "created_by_org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "removed_at": { + "name": "removed_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "marketplace_access_grant_organization_id": { + "name": "marketplace_access_grant_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "marketplace_access_grant_marketplace_id": { + "name": "marketplace_access_grant_marketplace_id", + "columns": [ + "marketplace_id" + ], + "isUnique": false + }, + "marketplace_access_grant_org_membership_id": { + "name": "marketplace_access_grant_org_membership_id", + "columns": [ + "org_membership_id" + ], + "isUnique": false + }, + "marketplace_access_grant_team_id": { + "name": "marketplace_access_grant_team_id", + "columns": [ + "team_id" + ], + "isUnique": false + }, + "marketplace_access_grant_org_wide": { + "name": "marketplace_access_grant_org_wide", + "columns": [ + "org_wide" + ], + "isUnique": false + }, + "marketplace_access_grant_marketplace_org_membership": { + "name": "marketplace_access_grant_marketplace_org_membership", + "columns": [ + "marketplace_id", + "org_membership_id" + ], + "isUnique": true + }, + "marketplace_access_grant_marketplace_team": { + "name": "marketplace_access_grant_marketplace_team", + "columns": [ + "marketplace_id", + "team_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "marketplace_access_grant_id": { + "name": "marketplace_access_grant_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "marketplace_plugin": { + "name": "marketplace_plugin", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "marketplace_id": { + "name": "marketplace_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "plugin_id": { + "name": "plugin_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "membership_source": { + "name": "membership_source", + "type": "enum('manual','connector','api','system')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'manual'" + }, + "created_by_org_membership_id": { + "name": "created_by_org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "removed_at": { + "name": "removed_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "marketplace_plugin_organization_id": { + "name": "marketplace_plugin_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "marketplace_plugin_marketplace_id": { + "name": "marketplace_plugin_marketplace_id", + "columns": [ + "marketplace_id" + ], + "isUnique": false + }, + "marketplace_plugin_plugin_id": { + "name": "marketplace_plugin_plugin_id", + "columns": [ + "plugin_id" + ], + "isUnique": false + }, + "marketplace_plugin_marketplace_plugin": { + "name": "marketplace_plugin_marketplace_plugin", + "columns": [ + "marketplace_id", + "plugin_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "marketplace_plugin_id": { + "name": "marketplace_plugin_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "marketplace": { + "name": "marketplace", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "logo_url": { + "name": "logo_url", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "enum('active','inactive','deleted','archived')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'active'" + }, + "created_by_org_membership_id": { + "name": "created_by_org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "marketplace_organization_id": { + "name": "marketplace_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "marketplace_created_by_org_membership_id": { + "name": "marketplace_created_by_org_membership_id", + "columns": [ + "created_by_org_membership_id" + ], + "isUnique": false + }, + "marketplace_status": { + "name": "marketplace_status", + "columns": [ + "status" + ], + "isUnique": false + }, + "marketplace_name": { + "name": "marketplace_name", + "columns": [ + "name" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "marketplace_id": { + "name": "marketplace_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "plugin_access_grant": { + "name": "plugin_access_grant", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "plugin_id": { + "name": "plugin_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_membership_id": { + "name": "org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "team_id": { + "name": "team_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "org_wide": { + "name": "org_wide", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "role": { + "name": "role", + "type": "enum('viewer','editor','manager')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by_org_membership_id": { + "name": "created_by_org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "removed_at": { + "name": "removed_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "plugin_access_grant_organization_id": { + "name": "plugin_access_grant_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "plugin_access_grant_plugin_id": { + "name": "plugin_access_grant_plugin_id", + "columns": [ + "plugin_id" + ], + "isUnique": false + }, + "plugin_access_grant_org_membership_id": { + "name": "plugin_access_grant_org_membership_id", + "columns": [ + "org_membership_id" + ], + "isUnique": false + }, + "plugin_access_grant_team_id": { + "name": "plugin_access_grant_team_id", + "columns": [ + "team_id" + ], + "isUnique": false + }, + "plugin_access_grant_org_wide": { + "name": "plugin_access_grant_org_wide", + "columns": [ + "org_wide" + ], + "isUnique": false + }, + "plugin_access_grant_plugin_org_membership": { + "name": "plugin_access_grant_plugin_org_membership", + "columns": [ + "plugin_id", + "org_membership_id" + ], + "isUnique": true + }, + "plugin_access_grant_plugin_team": { + "name": "plugin_access_grant_plugin_team", + "columns": [ + "plugin_id", + "team_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "plugin_access_grant_id": { + "name": "plugin_access_grant_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "plugin_config_object": { + "name": "plugin_config_object", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "plugin_id": { + "name": "plugin_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "config_object_id": { + "name": "config_object_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "membership_source": { + "name": "membership_source", + "type": "enum('manual','connector','api','system')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'manual'" + }, + "connector_mapping_id": { + "name": "connector_mapping_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by_org_membership_id": { + "name": "created_by_org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "removed_at": { + "name": "removed_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "plugin_config_object_organization_id": { + "name": "plugin_config_object_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "plugin_config_object_plugin_id": { + "name": "plugin_config_object_plugin_id", + "columns": [ + "plugin_id" + ], + "isUnique": false + }, + "plugin_config_object_config_object_id": { + "name": "plugin_config_object_config_object_id", + "columns": [ + "config_object_id" + ], + "isUnique": false + }, + "plugin_config_object_connector_mapping_id": { + "name": "plugin_config_object_connector_mapping_id", + "columns": [ + "connector_mapping_id" + ], + "isUnique": false + }, + "plugin_config_object_plugin_config_object": { + "name": "plugin_config_object_plugin_config_object", + "columns": [ + "plugin_id", + "config_object_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "plugin_config_object_id": { + "name": "plugin_config_object_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "plugin": { + "name": "plugin", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "enum('active','inactive','deleted','archived')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'active'" + }, + "created_by_org_membership_id": { + "name": "created_by_org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "plugin_organization_id": { + "name": "plugin_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "plugin_created_by_org_membership_id": { + "name": "plugin_created_by_org_membership_id", + "columns": [ + "created_by_org_membership_id" + ], + "isUnique": false + }, + "plugin_status": { + "name": "plugin_status", + "columns": [ + "status" + ], + "isUnique": false + }, + "plugin_name": { + "name": "plugin_name", + "columns": [ + "name" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "plugin_id": { + "name": "plugin_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "skill_hub_member": { + "name": "skill_hub_member", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "skill_hub_id": { + "name": "skill_hub_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_membership_id": { + "name": "org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "team_id": { + "name": "team_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "skill_hub_member_skill_hub_id": { + "name": "skill_hub_member_skill_hub_id", + "columns": [ + "skill_hub_id" + ], + "isUnique": false + }, + "skill_hub_member_org_membership_id": { + "name": "skill_hub_member_org_membership_id", + "columns": [ + "org_membership_id" + ], + "isUnique": false + }, + "skill_hub_member_team_id": { + "name": "skill_hub_member_team_id", + "columns": [ + "team_id" + ], + "isUnique": false + }, + "skill_hub_member_hub_org_membership": { + "name": "skill_hub_member_hub_org_membership", + "columns": [ + "skill_hub_id", + "org_membership_id" + ], + "isUnique": true + }, + "skill_hub_member_hub_team": { + "name": "skill_hub_member_hub_team", + "columns": [ + "skill_hub_id", + "team_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "skill_hub_member_id": { + "name": "skill_hub_member_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "skill_hub_skill": { + "name": "skill_hub_skill", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "skill_hub_id": { + "name": "skill_hub_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "skill_id": { + "name": "skill_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_membership_id": { + "name": "org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "skill_hub_skill_skill_hub_id": { + "name": "skill_hub_skill_skill_hub_id", + "columns": [ + "skill_hub_id" + ], + "isUnique": false + }, + "skill_hub_skill_skill_id": { + "name": "skill_hub_skill_skill_id", + "columns": [ + "skill_id" + ], + "isUnique": false + }, + "skill_hub_skill_hub_skill": { + "name": "skill_hub_skill_hub_skill", + "columns": [ + "skill_hub_id", + "skill_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "skill_hub_skill_id": { + "name": "skill_hub_skill_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "skill_hub": { + "name": "skill_hub", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by_org_membership_id": { + "name": "created_by_org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "skill_hub_organization_id": { + "name": "skill_hub_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "skill_hub_created_by_org_membership_id": { + "name": "skill_hub_created_by_org_membership_id", + "columns": [ + "created_by_org_membership_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "skill_hub_id": { + "name": "skill_hub_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "skill": { + "name": "skill", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by_org_membership_id": { + "name": "created_by_org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "skill_text": { + "name": "skill_text", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "shared": { + "name": "shared", + "type": "enum('org','public')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "skill_organization_id": { + "name": "skill_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "skill_created_by_org_membership_id": { + "name": "skill_created_by_org_membership_id", + "columns": [ + "created_by_org_membership_id" + ], + "isUnique": false + }, + "skill_shared": { + "name": "skill_shared", + "columns": [ + "shared" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "skill_id": { + "name": "skill_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "org_subscriptions": { + "name": "org_subscriptions", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by_org_membership_id": { + "name": "created_by_org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "enum('inference','seat')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "enum('incomplete','incomplete_expired','trialing','active','past_due','canceled','unpaid','paused','expired')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'incomplete'" + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "stripe_subscription_id": { + "name": "stripe_subscription_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "stripe_price_id": { + "name": "stripe_price_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "stripe_subscription_item_id": { + "name": "stripe_subscription_item_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "quantity": { + "name": "quantity", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "current_period_start": { + "name": "current_period_start", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "current_period_end": { + "name": "current_period_end", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cancel_at_period_end": { + "name": "cancel_at_period_end", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "canceled_at": { + "name": "canceled_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ended_at": { + "name": "ended_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_event_id": { + "name": "last_event_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "org_subscriptions_organization_id": { + "name": "org_subscriptions_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "org_subscriptions_customer_id": { + "name": "org_subscriptions_customer_id", + "columns": [ + "stripe_customer_id" + ], + "isUnique": false + }, + "org_subscriptions_subscription_id": { + "name": "org_subscriptions_subscription_id", + "columns": [ + "stripe_subscription_id" + ], + "isUnique": true + }, + "org_subscriptions_org_type": { + "name": "org_subscriptions_org_type", + "columns": [ + "organization_id", + "type" + ], + "isUnique": true + }, + "org_subscriptions_status": { + "name": "org_subscriptions_status", + "columns": [ + "status" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "org_subscriptions_id": { + "name": "org_subscriptions_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "team_member": { + "name": "team_member", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "team_id": { + "name": "team_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_membership_id": { + "name": "org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "team_member_team_id": { + "name": "team_member_team_id", + "columns": [ + "team_id" + ], + "isUnique": false + }, + "team_member_org_membership_id": { + "name": "team_member_org_membership_id", + "columns": [ + "org_membership_id" + ], + "isUnique": false + }, + "team_member_team_org_membership": { + "name": "team_member_team_org_membership", + "columns": [ + "team_id", + "org_membership_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "team_member_id": { + "name": "team_member_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "team": { + "name": "team", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "team_organization_id": { + "name": "team_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": false + }, + "team_organization_name": { + "name": "team_organization_name", + "columns": [ + "organization_id", + "name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "team_id": { + "name": "team_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "telegram_chat_binding": { + "name": "telegram_chat_binding", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "connection_id": { + "name": "connection_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "telegram_chat_id": { + "name": "telegram_chat_id", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "telegram_user_id": { + "name": "telegram_user_id", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "telegram_username": { + "name": "telegram_username", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "telegram_first_name": { + "name": "telegram_first_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "worker_workspace_id": { + "name": "worker_workspace_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "worker_session_id": { + "name": "worker_session_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "paired_at": { + "name": "paired_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "telegram_chat_binding_connection_id": { + "name": "telegram_chat_binding_connection_id", + "columns": [ + "connection_id" + ], + "isUnique": true + }, + "telegram_chat_binding_connection_chat": { + "name": "telegram_chat_binding_connection_chat", + "columns": [ + "connection_id", + "telegram_chat_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "telegram_chat_binding_id": { + "name": "telegram_chat_binding_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "telegram_connection": { + "name": "telegram_connection", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "worker_id": { + "name": "worker_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by_org_membership_id": { + "name": "created_by_org_membership_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "bot_token": { + "name": "bot_token", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "webhook_secret": { + "name": "webhook_secret", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "bot_id": { + "name": "bot_id", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "bot_username": { + "name": "bot_username", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "bot_display_name": { + "name": "bot_display_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "enum('active','error')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'active'" + }, + "webhook_registered": { + "name": "webhook_registered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "dispatch_token": { + "name": "dispatch_token", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "dispatch_started_at": { + "name": "dispatch_started_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_webhook_at": { + "name": "last_webhook_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "telegram_connection_organization_id": { + "name": "telegram_connection_organization_id", + "columns": [ + "organization_id" + ], + "isUnique": true + }, + "telegram_connection_bot_id": { + "name": "telegram_connection_bot_id", + "columns": [ + "bot_id" + ], + "isUnique": true + }, + "telegram_connection_worker_id": { + "name": "telegram_connection_worker_id", + "columns": [ + "worker_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "telegram_connection_id": { + "name": "telegram_connection_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "telegram_pairing": { + "name": "telegram_pairing", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "connection_id": { + "name": "connection_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_hash": { + "name": "token_hash", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "telegram_pairing_token_hash": { + "name": "telegram_pairing_token_hash", + "columns": [ + "token_hash" + ], + "isUnique": true + }, + "telegram_pairing_connection_id": { + "name": "telegram_pairing_connection_id", + "columns": [ + "connection_id" + ], + "isUnique": false + }, + "telegram_pairing_expires_at": { + "name": "telegram_pairing_expires_at", + "columns": [ + "expires_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "telegram_pairing_id": { + "name": "telegram_pairing_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "telegram_update": { + "name": "telegram_update", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "connection_id": { + "name": "connection_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "update_id": { + "name": "update_id", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "payload": { + "name": "payload", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "enum('accepted','processing','completed','ignored','failed')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'accepted'" + }, + "attempts": { + "name": "attempts", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "processing_token": { + "name": "processing_token", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "processing_started_at": { + "name": "processing_started_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "received_at": { + "name": "received_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "telegram_update_connection_update": { + "name": "telegram_update_connection_update", + "columns": [ + "connection_id", + "update_id" + ], + "isUnique": true + }, + "telegram_update_dispatch": { + "name": "telegram_update_dispatch", + "columns": [ + "status", + "processing_started_at", + "received_at" + ], + "isUnique": false + }, + "telegram_update_received_at": { + "name": "telegram_update_received_at", + "columns": [ + "received_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "telegram_update_id": { + "name": "telegram_update_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "audit_event": { + "name": "audit_event", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_id": { + "name": "org_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "worker_id": { + "name": "worker_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actor_user_id": { + "name": "actor_user_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "action": { + "name": "action", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "payload": { + "name": "payload", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "audit_event_org_id": { + "name": "audit_event_org_id", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "audit_event_worker_id": { + "name": "audit_event_worker_id", + "columns": [ + "worker_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "audit_event_id": { + "name": "audit_event_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "daytona_sandbox": { + "name": "daytona_sandbox", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "worker_id": { + "name": "worker_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sandbox_id": { + "name": "sandbox_id", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_volume_id": { + "name": "workspace_volume_id", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "data_volume_id": { + "name": "data_volume_id", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "signed_preview_url": { + "name": "signed_preview_url", + "type": "varchar(2048)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "signed_preview_url_expires_at": { + "name": "signed_preview_url_expires_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "region": { + "name": "region", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "daytona_sandbox_worker_id": { + "name": "daytona_sandbox_worker_id", + "columns": [ + "worker_id" + ], + "isUnique": true + }, + "daytona_sandbox_sandbox_id": { + "name": "daytona_sandbox_sandbox_id", + "columns": [ + "sandbox_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "daytona_sandbox_id": { + "name": "daytona_sandbox_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "worker_bundle": { + "name": "worker_bundle", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "worker_id": { + "name": "worker_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "storage_url": { + "name": "storage_url", + "type": "varchar(2048)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "worker_bundle_worker_id": { + "name": "worker_bundle_worker_id", + "columns": [ + "worker_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "worker_bundle_id": { + "name": "worker_bundle_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "worker_instance": { + "name": "worker_instance", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "worker_id": { + "name": "worker_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "region": { + "name": "region", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "url": { + "name": "url", + "type": "varchar(2048)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "enum('provisioning','healthy','failed','stopped')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "worker_instance_worker_id": { + "name": "worker_instance_worker_id", + "columns": [ + "worker_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "worker_instance_id": { + "name": "worker_instance_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "worker": { + "name": "worker", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_id": { + "name": "org_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "destination": { + "name": "destination", + "type": "enum('local','cloud')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "enum('provisioning','healthy','failed','stopped')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "image_version": { + "name": "image_version", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "workspace_path": { + "name": "workspace_path", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "sandbox_backend": { + "name": "sandbox_backend", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_heartbeat_at": { + "name": "last_heartbeat_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_active_at": { + "name": "last_active_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "worker_org_id": { + "name": "worker_org_id", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "worker_created_by_user_id": { + "name": "worker_created_by_user_id", + "columns": [ + "created_by_user_id" + ], + "isUnique": false + }, + "worker_status": { + "name": "worker_status", + "columns": [ + "status" + ], + "isUnique": false + }, + "worker_last_heartbeat_at": { + "name": "worker_last_heartbeat_at", + "columns": [ + "last_heartbeat_at" + ], + "isUnique": false + }, + "worker_last_active_at": { + "name": "worker_last_active_at", + "columns": [ + "last_active_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "worker_id": { + "name": "worker_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "worker_token": { + "name": "worker_token", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "worker_id": { + "name": "worker_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "scope": { + "name": "scope", + "type": "enum('client','host','activity')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token": { + "name": "token", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "worker_token_worker_id": { + "name": "worker_token_worker_id", + "columns": [ + "worker_id" + ], + "isUnique": false + }, + "worker_token_token": { + "name": "worker_token_token", + "columns": [ + "token" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "worker_token_id": { + "name": "worker_token_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "admin_allowlist": { + "name": "admin_allowlist", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "note": { + "name": "note", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + } + }, + "indexes": { + "admin_allowlist_email": { + "name": "admin_allowlist_email", + "columns": [ + "email" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "admin_allowlist_id": { + "name": "admin_allowlist_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "rate_limit": { + "name": "rate_limit", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "count": { + "name": "count", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "last_request": { + "name": "last_request", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "rate_limit_key": { + "name": "rate_limit_key", + "columns": [ + "key" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "rate_limit_id": { + "name": "rate_limit_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "telemetry_event": { + "name": "telemetry_event", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_id": { + "name": "org_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "member_id": { + "name": "member_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "event_type": { + "name": "event_type", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "event_timestamp": { + "name": "event_timestamp", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "varchar(32)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "duration_ms": { + "name": "duration_ms", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "success": { + "name": "success", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "telemetry_event_org_id_type_ts": { + "name": "telemetry_event_org_id_type_ts", + "columns": [ + "org_id", + "event_type", + "event_timestamp" + ], + "isUnique": false + }, + "telemetry_event_org_id_member_id": { + "name": "telemetry_event_org_id_member_id", + "columns": [ + "org_id", + "member_id" + ], + "isUnique": false + }, + "telemetry_event_org_session_ts": { + "name": "telemetry_event_org_session_ts", + "columns": [ + "org_id", + "session_id", + "event_timestamp" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "telemetry_event_id": { + "name": "telemetry_event_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "telemetry_session_dimension": { + "name": "telemetry_session_dimension", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_id": { + "name": "org_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "dimension_type": { + "name": "dimension_type", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "dimension_value": { + "name": "dimension_value", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "dimension_label": { + "name": "dimension_label", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "telemetry_session_dimension_org_source_session_type": { + "name": "telemetry_session_dimension_org_source_session_type", + "columns": [ + "org_id", + "source", + "session_id", + "dimension_type" + ], + "isUnique": true + }, + "telemetry_session_dimension_filter": { + "name": "telemetry_session_dimension_filter", + "columns": [ + "org_id", + "dimension_type", + "dimension_value", + "session_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "telemetry_session_dimension_id": { + "name": "telemetry_session_dimension_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + } + }, + "views": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "tables": {}, + "indexes": {} + } +} \ No newline at end of file diff --git a/ee/packages/den-db/drizzle/meta/_journal.json b/ee/packages/den-db/drizzle/meta/_journal.json index 8a400ed1a9..2f507d1ef0 100644 --- a/ee/packages/den-db/drizzle/meta/_journal.json +++ b/ee/packages/den-db/drizzle/meta/_journal.json @@ -253,6 +253,13 @@ "when": 1783966457549, "tag": "0036_petite_fallen_one", "breakpoints": true + }, + { + "idx": 37, + "version": "5", + "when": 1783968584397, + "tag": "0037_tranquil_big_bertha", + "breakpoints": true } ] } \ No newline at end of file diff --git a/ee/packages/den-db/src/schema/index.ts b/ee/packages/den-db/src/schema/index.ts index a180df0b11..46bbde0919 100644 --- a/ee/packages/den-db/src/schema/index.ts +++ b/ee/packages/den-db/src/schema/index.ts @@ -5,6 +5,7 @@ export * from "./inference" export * from "./memory" export * from "./org" export * from "./sharables/capability-credentials" +export * from "./sharables/external-mcp-manifests" export * from "./sharables/llm-providers" export * from "./sharables/plugin-arch" export * from "./sharables/skills" diff --git a/ee/packages/den-db/src/schema/sharables/external-mcp-manifests.ts b/ee/packages/den-db/src/schema/sharables/external-mcp-manifests.ts new file mode 100644 index 0000000000..e0f155c093 --- /dev/null +++ b/ee/packages/den-db/src/schema/sharables/external-mcp-manifests.ts @@ -0,0 +1,57 @@ +import { sql } from "drizzle-orm" +import { + boolean, + index, + int, + json, + mysqlEnum, + mysqlTable, + text, + timestamp, + uniqueIndex, + varchar, +} from "drizzle-orm/mysql-core" +import { denTypeIdColumn } from "../../columns" + +export type CachedExternalMcpTool = { + name: string + title?: string + description?: string +} + +export const externalMcpToolManifestStatusValues = ["ok", "error"] as const +export type ExternalMcpToolManifestStatus = (typeof externalMcpToolManifestStatusValues)[number] + +export const ExternalMcpToolManifestTable = mysqlTable( + "external_mcp_tool_manifest", + { + id: denTypeIdColumn("externalMcpToolManifest", "id").notNull().primaryKey(), + organizationId: denTypeIdColumn("organization", "organization_id").notNull(), + externalMcpConnectionId: denTypeIdColumn( + "externalMcpConnection", + "external_mcp_connection_id", + ).notNull(), + principal: varchar("principal", { length: 64 }).notNull(), + configHash: varchar("config_hash", { length: 64 }).notNull(), + status: mysqlEnum("status", externalMcpToolManifestStatusValues).notNull(), + tools: json("tools").$type().notNull(), + toolCount: int("tool_count").notNull().default(0), + toolsHash: varchar("tools_hash", { length: 64 }), + toolsTruncated: boolean("tools_truncated").notNull().default(false), + lastError: text("last_error"), + durationMs: int("duration_ms"), + listedAt: timestamp("listed_at", { fsp: 3 }), + staleAt: timestamp("stale_at", { fsp: 3 }), + refreshStartedAt: timestamp("refresh_started_at", { fsp: 3 }), + createdAt: timestamp("created_at", { fsp: 3 }).notNull().defaultNow(), + updatedAt: timestamp("updated_at", { fsp: 3 }) + .notNull() + .default(sql`CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)`), + }, + (table) => [ + uniqueIndex("emtm_connection_principal").on(table.externalMcpConnectionId, table.principal), + index("emtm_organization_id").on(table.organizationId), + index("emtm_listed_at").on(table.listedAt), + index("emtm_refresh_started_at").on(table.refreshStartedAt), + ], +) diff --git a/ee/packages/utils/src/typeid.ts b/ee/packages/utils/src/typeid.ts index 2707036eea..e3ae20a124 100644 --- a/ee/packages/utils/src/typeid.ts +++ b/ee/packages/utils/src/typeid.ts @@ -84,6 +84,7 @@ export const idTypesMapNameToPrefix = { connectedAccount: "cta", externalMcpConnection: "emc", externalMcpConnectionAccessGrant: "emg", + externalMcpToolManifest: "emtm", telegramConnection: "tgc", telegramPairing: "tgp", telegramChatBinding: "tgb",