diff --git a/apps/api/src/modules/runtime/infrastructure/driver-instance/rpc-command-controller.ts b/apps/api/src/modules/runtime/infrastructure/driver-instance/rpc-command-controller.ts index 474d7d10..38a72870 100644 --- a/apps/api/src/modules/runtime/infrastructure/driver-instance/rpc-command-controller.ts +++ b/apps/api/src/modules/runtime/infrastructure/driver-instance/rpc-command-controller.ts @@ -1,15 +1,24 @@ import type { DriverCommandUpdateInput, + DriverExternalToolEffectClaimInput, + DriverExternalToolEffectClaimOutput, + DriverExternalToolEffectCompleteInput, + DriverExternalToolEffectUnknownInput, DriverNextCommandInput, DriverNextCommandOutput, } from "@mosoo/agent-driver/orpc"; -import { RuntimeCommandResult } from "@mosoo/contracts/runtime-command"; +import { McpExecuteCommandResult, RuntimeCommandResult } from "@mosoo/contracts/runtime-command"; import type { RuntimeCommand } from "@mosoo/contracts/runtime-command"; import { parseSchemaValue } from "@mosoo/contracts/validation"; import { parsePlatformId } from "@mosoo/id"; import type { DriverCommandId } from "@mosoo/id"; import { createErrorLogContext, logError } from "../../../../platform/cloudflare/logger"; +import { + claimExternalToolEffect, + completeExternalToolEffect, + markExternalToolEffectUnknown, +} from "../session-runs/external-tool-effect-store.repository"; import { claimNextQueuedRuntimeCommandRecord, createRuntimeCommandRecord, @@ -110,6 +119,63 @@ export class DriverInstanceRpcCommandController { return { ok: true }; } + async handleClaimExternalToolEffect( + input: DriverExternalToolEffectClaimInput, + context: DriverInstanceRpcOperationContext, + ): Promise { + const { env, state } = this.#dependencies; + + if (input.driverInstanceId !== state.requireDriverInstanceId()) { + throw new Error("Driver instance id mismatch."); + } + context.assertActiveConnection(); + + return claimExternalToolEffect(env.DB, { + commandId: parsePlatformId(input.commandId, "driver command id"), + driverInstanceId: state.requireDriverInstanceId(), + }); + } + + async handleCompleteExternalToolEffect( + input: DriverExternalToolEffectCompleteInput, + context: DriverInstanceRpcOperationContext, + ): Promise<{ ok: true }> { + const { env, state } = this.#dependencies; + + if (input.driverInstanceId !== state.requireDriverInstanceId()) { + throw new Error("Driver instance id mismatch."); + } + context.assertActiveConnection(); + await completeExternalToolEffect(env.DB, { + commandId: parsePlatformId(input.commandId, "driver command id"), + driverInstanceId: state.requireDriverInstanceId(), + ...(input.providerReceiptJson === undefined + ? {} + : { providerReceiptJson: input.providerReceiptJson }), + result: parseSchemaValue(McpExecuteCommandResult, input.result), + }); + context.assertActiveConnection(); + return { ok: true }; + } + + async handleMarkExternalToolEffectUnknown( + input: DriverExternalToolEffectUnknownInput, + context: DriverInstanceRpcOperationContext, + ): Promise<{ ok: true }> { + const { env, state } = this.#dependencies; + + if (input.driverInstanceId !== state.requireDriverInstanceId()) { + throw new Error("Driver instance id mismatch."); + } + context.assertActiveConnection(); + await markExternalToolEffectUnknown(env.DB, { + commandId: parsePlatformId(input.commandId, "driver command id"), + driverInstanceId: state.requireDriverInstanceId(), + }); + context.assertActiveConnection(); + return { ok: true }; + } + async handleNextCommand( input: DriverNextCommandInput, context: DriverInstanceRpcOperationContext, diff --git a/apps/api/src/modules/runtime/infrastructure/driver-instance/rpc-controller.ts b/apps/api/src/modules/runtime/infrastructure/driver-instance/rpc-controller.ts index 7d1ab901..ab2db5af 100644 --- a/apps/api/src/modules/runtime/infrastructure/driver-instance/rpc-controller.ts +++ b/apps/api/src/modules/runtime/infrastructure/driver-instance/rpc-controller.ts @@ -3,6 +3,10 @@ import type { DriverCompletionInput, DriverEventBatchInput, DriverEventBatchOutput, + DriverExternalToolEffectClaimInput, + DriverExternalToolEffectClaimOutput, + DriverExternalToolEffectCompleteInput, + DriverExternalToolEffectUnknownInput, DriverFailureInput, DriverHeartbeatInput, DriverHelloInput, @@ -46,6 +50,20 @@ export class DriverInstanceRpcController implements DriverInstanceRpcHandler { return this.#commands.handleCommandUpdate(input, context); } + async handleClaimExternalToolEffect( + input: DriverExternalToolEffectClaimInput, + context: DriverInstanceRpcOperationContext, + ): Promise { + return this.#commands.handleClaimExternalToolEffect(input, context); + } + + async handleCompleteExternalToolEffect( + input: DriverExternalToolEffectCompleteInput, + context: DriverInstanceRpcOperationContext, + ): Promise<{ ok: true }> { + return this.#commands.handleCompleteExternalToolEffect(input, context); + } + async handleCompleteRun( input: DriverCompletionInput, context: DriverInstanceRpcOperationContext, @@ -101,6 +119,13 @@ export class DriverInstanceRpcController implements DriverInstanceRpcHandler { return this.#events.handlePushLogs(input, context); } + async handleMarkExternalToolEffectUnknown( + input: DriverExternalToolEffectUnknownInput, + context: DriverInstanceRpcOperationContext, + ): Promise<{ ok: true }> { + return this.#commands.handleMarkExternalToolEffectUnknown(input, context); + } + async handleReady( input: DriverReadyInput, context: DriverInstanceRpcOperationContext, diff --git a/apps/api/src/modules/runtime/infrastructure/driver-instance/rpc-wire.ts b/apps/api/src/modules/runtime/infrastructure/driver-instance/rpc-wire.ts index 5c1a1f71..afbde39b 100644 --- a/apps/api/src/modules/runtime/infrastructure/driver-instance/rpc-wire.ts +++ b/apps/api/src/modules/runtime/infrastructure/driver-instance/rpc-wire.ts @@ -4,6 +4,10 @@ import type { DriverCompletionInput, DriverEventBatchInput, DriverEventBatchOutput, + DriverExternalToolEffectClaimInput, + DriverExternalToolEffectClaimOutput, + DriverExternalToolEffectCompleteInput, + DriverExternalToolEffectUnknownInput, DriverFailureInput, DriverHeartbeatInput, DriverHeartbeatOutput, @@ -16,8 +20,10 @@ import type { DriverReadyInput, } from "@mosoo/agent-driver/orpc"; import { DriverCapability } from "@mosoo/contracts/driver-instance"; +import { ExternalToolEffectClaim } from "@mosoo/contracts/external-tool-effect"; import { RuntimeCommand, + McpExecuteCommandResult, RuntimeCommandResult, RuntimeCommandStatus, } from "@mosoo/contracts/runtime-command"; @@ -30,7 +36,7 @@ const DriverHelloInputWire = type({ capabilities: DriverCapability.array(), driverVersion: NonEmptyString, pid: "number", - protocolVersion: "1", + protocolVersion: "2", runtime: '"openai-runtime" | "claude-agent-sdk" | "acp-fallback"', startedAt: "string", }); @@ -131,6 +137,23 @@ const DriverCommandUpdateInputWire = type({ status: RuntimeCommandStatus, }); +const DriverExternalToolEffectClaimInputWire = type({ + commandId: NonEmptyString, + driverInstanceId: NonEmptyString, +}); + +const DriverExternalToolEffectCompleteInputWire = type({ + commandId: NonEmptyString, + driverInstanceId: NonEmptyString, + "providerReceiptJson?": "string | null | undefined", + result: McpExecuteCommandResult, +}); + +const DriverExternalToolEffectUnknownInputWire = type({ + commandId: NonEmptyString, + driverInstanceId: NonEmptyString, +}); + const DriverNextCommandInputWire = type({ driverInstanceId: NonEmptyString, }); @@ -154,6 +177,10 @@ type DriverNextCommandOutputWireValue = typeof DriverNextCommandOutputWire.infer export interface RuntimeOrpcContext { onCommandUpdate(input: DriverCommandUpdateInput): Promise<{ ok: true }>; + onClaimExternalToolEffect( + input: DriverExternalToolEffectClaimInput, + ): Promise; + onCompleteExternalToolEffect(input: DriverExternalToolEffectCompleteInput): Promise<{ ok: true }>; onCompleteRun(input: DriverCompletionInput): Promise<{ ok: true }>; onFailRun(input: DriverFailureInput): Promise<{ ok: true }>; onHeartbeat(input: DriverHeartbeatInput): Promise; @@ -161,6 +188,9 @@ export interface RuntimeOrpcContext { onNextCommand(input: DriverNextCommandInput): Promise; onPushEvents(input: DriverEventBatchInput): Promise; onPushLogs(input: DriverLogBatchInput): Promise; + onMarkExternalToolEffectUnknown( + input: DriverExternalToolEffectUnknownInput, + ): Promise<{ ok: true }>; onReady(input: DriverReadyInput): Promise<{ ok: true }>; onWatchCommands(): AsyncIteratorObject; } @@ -169,6 +199,24 @@ function parseDriverCommandUpdateInput(input: unknown): DriverCommandUpdateInput return parseSchemaValue(DriverCommandUpdateInputWire, input); } +function parseDriverExternalToolEffectClaimInput( + input: unknown, +): DriverExternalToolEffectClaimInput { + return parseSchemaValue(DriverExternalToolEffectClaimInputWire, input); +} + +function parseDriverExternalToolEffectCompleteInput( + input: unknown, +): DriverExternalToolEffectCompleteInput { + return parseSchemaValue(DriverExternalToolEffectCompleteInputWire, input); +} + +function parseDriverExternalToolEffectUnknownInput( + input: unknown, +): DriverExternalToolEffectUnknownInput { + return parseSchemaValue(DriverExternalToolEffectUnknownInputWire, input); +} + function parseDriverCompletionInput(input: unknown): DriverCompletionInput { return parseSchemaValue(DriverCompletionInputWire, input); } @@ -218,12 +266,24 @@ const base = os.$context(); export const runtimeOrpcRouter = { driver: { + claimExternalToolEffect: base + .input(DriverExternalToolEffectClaimInputWire) + .output(ExternalToolEffectClaim) + .handler(async ({ context, input }) => + context.onClaimExternalToolEffect(parseDriverExternalToolEffectClaimInput(input)), + ), commandUpdate: base .input(DriverCommandUpdateInputWire) .output(type({ ok: "true" })) .handler(async ({ context, input }) => context.onCommandUpdate(parseDriverCommandUpdateInput(input)), ), + completeExternalToolEffect: base + .input(DriverExternalToolEffectCompleteInputWire) + .output(type({ ok: "true" })) + .handler(async ({ context, input }) => + context.onCompleteExternalToolEffect(parseDriverExternalToolEffectCompleteInput(input)), + ), completeRun: base .input(DriverCompletionInputWire) .output(type({ ok: "true" })) @@ -256,6 +316,12 @@ export const runtimeOrpcRouter = { .input(DriverReadyInputWire) .output(type({ ok: "true" })) .handler(async ({ context, input }) => context.onReady(parseDriverReadyInput(input))), + markExternalToolEffectUnknown: base + .input(DriverExternalToolEffectUnknownInputWire) + .output(type({ ok: "true" })) + .handler(async ({ context, input }) => + context.onMarkExternalToolEffectUnknown(parseDriverExternalToolEffectUnknownInput(input)), + ), }, driverInstance: { nextCommand: base diff --git a/apps/api/src/modules/runtime/infrastructure/driver-instance/rpc.ts b/apps/api/src/modules/runtime/infrastructure/driver-instance/rpc.ts index be8ee445..268ec76b 100644 --- a/apps/api/src/modules/runtime/infrastructure/driver-instance/rpc.ts +++ b/apps/api/src/modules/runtime/infrastructure/driver-instance/rpc.ts @@ -3,6 +3,10 @@ import type { DriverCompletionInput, DriverEventBatchInput, DriverEventBatchOutput, + DriverExternalToolEffectClaimInput, + DriverExternalToolEffectClaimOutput, + DriverExternalToolEffectCompleteInput, + DriverExternalToolEffectUnknownInput, DriverFailureInput, DriverHeartbeatInput, DriverHelloInput, @@ -29,6 +33,14 @@ export interface DriverInstanceRpcHandler { input: DriverCommandUpdateInput, context: DriverInstanceRpcOperationContext, ): Promise<{ ok: true }>; + handleClaimExternalToolEffect( + input: DriverExternalToolEffectClaimInput, + context: DriverInstanceRpcOperationContext, + ): Promise; + handleCompleteExternalToolEffect( + input: DriverExternalToolEffectCompleteInput, + context: DriverInstanceRpcOperationContext, + ): Promise<{ ok: true }>; handleCompleteRun( input: DriverCompletionInput, context: DriverInstanceRpcOperationContext, @@ -57,6 +69,10 @@ export interface DriverInstanceRpcHandler { input: DriverLogBatchInput, context: DriverInstanceRpcOperationContext, ): Promise; + handleMarkExternalToolEffectUnknown( + input: DriverExternalToolEffectUnknownInput, + context: DriverInstanceRpcOperationContext, + ): Promise<{ ok: true }>; handleReady( input: DriverReadyInput, context: DriverInstanceRpcOperationContext, @@ -69,7 +85,11 @@ export function createDriverInstanceRpcContext( context: DriverInstanceRpcOperationContext, ): DriverInstanceRpcContext { return { + onClaimExternalToolEffect: async (input) => + handler.handleClaimExternalToolEffect(input, context), onCommandUpdate: async (input) => handler.handleCommandUpdate(input, context), + onCompleteExternalToolEffect: async (input) => + handler.handleCompleteExternalToolEffect(input, context), onCompleteRun: async (input) => handler.handleCompleteRun(input, context), onFailRun: async (input) => handler.handleFailRun(input, context), onHeartbeat: async (input) => handler.handleHeartbeat(input, context), @@ -77,6 +97,8 @@ export function createDriverInstanceRpcContext( onNextCommand: async (input) => handler.handleNextCommand(input, context), onPushEvents: async (input) => handler.handlePushEvents(input, context), onPushLogs: async (input) => handler.handlePushLogs(input, context), + onMarkExternalToolEffectUnknown: async (input) => + handler.handleMarkExternalToolEffectUnknown(input, context), onReady: async (input) => handler.handleReady(input, context), onWatchCommands: () => handler.watchCommands(context)[Symbol.asyncIterator]() as ReturnType< diff --git a/apps/api/src/modules/runtime/infrastructure/driver-instance/terminal-run-release.ts b/apps/api/src/modules/runtime/infrastructure/driver-instance/terminal-run-release.ts index a6a86c0d..903709dc 100644 --- a/apps/api/src/modules/runtime/infrastructure/driver-instance/terminal-run-release.ts +++ b/apps/api/src/modules/runtime/infrastructure/driver-instance/terminal-run-release.ts @@ -12,6 +12,7 @@ import { classifyReclaim, decideReclaimRecovery } from "../../domain/session-run import { isTerminalSessionRunStatus } from "../../domain/session-run-status"; import { createSessionRunTerminalFailureSourceId } from "../../domain/session-run-terminal-event-id"; import { recordRuntimeRunLeaseReleasedOutcome } from "../runtime-subject-lifecycle/runtime-run-lease-store"; +import { markExecutingExternalToolEffectsUnknownForDriver } from "../session-runs/external-tool-effect-store.repository"; import { failAcceptedRuntimeCommandsForTerminalDriver } from "../session-runs/runtime-command-store.repository"; import { setSessionRunStatus } from "../session-runs/session-run-store.repository"; import type { SessionRunTransitionOutcome } from "../session-runs/session-run-store.repository"; @@ -110,6 +111,7 @@ export async function repairFinalizedTerminalDriverRunState( status: "failed" | "stopped"; }, ): Promise { + await markExecutingExternalToolEffectsUnknownForDriver(bindings.DB, input.driverInstanceId); await failAcceptedRuntimeCommandsForTerminalDriver(bindings.DB, { driverInstanceId: input.driverInstanceId, }); diff --git a/apps/api/src/modules/runtime/infrastructure/session-runs/external-tool-effect-store.repository.ts b/apps/api/src/modules/runtime/infrastructure/session-runs/external-tool-effect-store.repository.ts new file mode 100644 index 00000000..17d66daa --- /dev/null +++ b/apps/api/src/modules/runtime/infrastructure/session-runs/external-tool-effect-store.repository.ts @@ -0,0 +1,402 @@ +import type { + ExternalToolEffectClaim, + ExternalToolEffectStatus, +} from "@mosoo/contracts/external-tool-effect"; +import { McpExecuteCommandResult } from "@mosoo/contracts/runtime-command"; +import { parseSchemaValue } from "@mosoo/contracts/validation"; +import { + externalToolEffectAttemptsTable, + externalToolEffectsTable, + sessionRunsTable, +} from "@mosoo/db"; +import { createPlatformId, parsePlatformId } from "@mosoo/id"; +import type { + DriverCommandId, + DriverInstanceId, + ExternalToolEffectId, + McpServerId, + SessionRunId, +} from "@mosoo/id"; +import { and, eq, inArray } from "drizzle-orm"; + +import { + getAppDatabase, + getD1ChangeCount, + runAppDatabaseBatch, +} from "../../../../platform/db/drizzle"; +import { currentTimestampMs } from "../../../../time"; +import { ACTIVE_SESSION_RUN_STATUSES } from "../../domain/session-run-lifecycle.machine"; + +interface ExternalToolEffectRow { + attemptCount: number; + id: ExternalToolEffectId; + idempotencyKey: string; + resultJson: string | null; + status: ExternalToolEffectStatus; +} + +function parseMcpResult(value: string): typeof McpExecuteCommandResult.infer { + return parseSchemaValue(McpExecuteCommandResult, JSON.parse(value)); +} + +async function getExternalToolEffect( + database: D1Database, + input: { + commandId: DriverCommandId; + driverInstanceId: DriverInstanceId; + }, +): Promise { + const effect = + (await getAppDatabase(database) + .select({ + attemptCount: externalToolEffectsTable.attemptCount, + id: externalToolEffectsTable.id, + idempotencyKey: externalToolEffectsTable.idempotencyKey, + resultJson: externalToolEffectsTable.resultJson, + status: externalToolEffectsTable.status, + }) + .from(externalToolEffectsTable) + .where( + and( + eq(externalToolEffectsTable.commandId, input.commandId), + eq(externalToolEffectsTable.driverInstanceId, input.driverInstanceId), + ), + ) + .limit(1) + .get()) ?? null; + + if (effect === null) { + throw new Error("External tool effect intent was not found for the runtime command."); + } + + return effect; +} + +/** + * Prepares the durable intent before a MCP command may reach a Driver. The + * caller commits it in the same D1 batch as the command record, so either both + * become visible to a Driver or neither does. + */ +export async function prepareExternalToolEffectIntent( + database: D1Database, + input: { + command: { + commandId: string; + serverId: string; + toolName: string; + }; + driverInstanceId: DriverInstanceId; + }, +): Promise { + const commandId = parsePlatformId(input.command.commandId, "driver command id"); + const serverId = parsePlatformId(input.command.serverId, "MCP server id"); + const activeRun = + (await getAppDatabase(database) + .select({ id: sessionRunsTable.id }) + .from(sessionRunsTable) + .where( + and( + eq(sessionRunsTable.driverInstanceId, input.driverInstanceId), + inArray(sessionRunsTable.status, ACTIVE_SESSION_RUN_STATUSES), + ), + ) + .limit(1) + .get()) ?? null; + + if (activeRun === null) { + throw new Error("MCP external tool effects require an active Session Run."); + } + + const effectId = createPlatformId(); + const nowMs = currentTimestampMs(); + + return { + attemptCount: 0, + commandId, + createdAt: nowMs, + driverInstanceId: input.driverInstanceId, + id: effectId, + idempotencyKey: effectId, + providerReceiptJson: null, + resultJson: null, + serverId, + sessionRunId: activeRun.id, + status: "intent" as const, + toolName: input.command.toolName, + updatedAt: nowMs, + }; +} + +/** + * Atomically fences the only permitted provider invocation. An interrupted + * execution becomes unknown instead of being replayed by a new Driver. + */ +export async function claimExternalToolEffect( + database: D1Database, + input: { + commandId: DriverCommandId; + driverInstanceId: DriverInstanceId; + }, +): Promise { + const effect = await getExternalToolEffect(database, input); + + if (effect.status === "succeeded") { + if (effect.resultJson === null) { + throw new Error("Succeeded external tool effect is missing its command result."); + } + + return { + effectId: effect.id, + kind: "completed", + result: parseMcpResult(effect.resultJson), + }; + } + + if (effect.status === "unknown") { + return { effectId: effect.id, kind: "unknown" }; + } + + if (effect.status === "executing") { + await markExternalToolEffectUnknown(database, input); + return { effectId: effect.id, kind: "unknown" }; + } + + const attempt = effect.attemptCount + 1; + const nowMs = currentTimestampMs(); + const [update] = await runAppDatabaseBatch(database, (appDatabase) => [ + appDatabase + .update(externalToolEffectsTable) + .set({ + attemptCount: attempt, + status: "executing", + updatedAt: nowMs, + }) + .where( + and( + eq(externalToolEffectsTable.id, effect.id), + eq(externalToolEffectsTable.attemptCount, effect.attemptCount), + eq(externalToolEffectsTable.status, "intent"), + ), + ), + appDatabase + .insert(externalToolEffectAttemptsTable) + .values({ + attempt, + completedAt: null, + createdAt: nowMs, + effectId: effect.id, + providerReceiptJson: null, + resultJson: null, + status: "executing", + }) + .onConflictDoNothing(), + ]); + + if (getD1ChangeCount(update) === 0) { + return claimExternalToolEffect(database, input); + } + + return { + attempt, + effectId: effect.id, + idempotencyKey: effect.idempotencyKey, + kind: "execute", + }; +} + +/** + * Stores the outcome before the Driver sends the command terminal receipt. + * The Driver preserves provider `_meta` as an opaque receipt when one exists. + * MCP does not standardize reconciliation, so absent receipts remain null and + * a later delivery uncertainty is fenced as unknown rather than replayed. + */ +export async function completeExternalToolEffect( + database: D1Database, + input: { + commandId: DriverCommandId; + driverInstanceId: DriverInstanceId; + providerReceiptJson?: string | null; + result: typeof McpExecuteCommandResult.infer; + }, +): Promise { + const effect = await getExternalToolEffect(database, input); + + if (effect.status === "succeeded") { + return; + } + if (effect.status !== "executing") { + throw new Error(`Cannot complete an external tool effect in ${effect.status} state.`); + } + + const nowMs = currentTimestampMs(); + const resultJson = JSON.stringify(input.result); + const [update] = await runAppDatabaseBatch(database, (appDatabase) => [ + appDatabase + .update(externalToolEffectsTable) + .set({ + providerReceiptJson: input.providerReceiptJson ?? null, + resultJson, + status: "succeeded", + updatedAt: nowMs, + }) + .where( + and( + eq(externalToolEffectsTable.id, effect.id), + eq(externalToolEffectsTable.status, "executing"), + ), + ), + appDatabase + .update(externalToolEffectAttemptsTable) + .set({ + completedAt: nowMs, + providerReceiptJson: input.providerReceiptJson ?? null, + resultJson, + status: "succeeded", + }) + .where( + and( + eq(externalToolEffectAttemptsTable.effectId, effect.id), + eq(externalToolEffectAttemptsTable.attempt, effect.attemptCount), + eq(externalToolEffectAttemptsTable.status, "executing"), + ), + ), + ]); + + if (getD1ChangeCount(update) === 0) { + throw new Error("External tool effect completion lost its execution claim."); + } +} + +/** + * No generic MCP provider reconciliation or compensation exists. This is a + * deliberate terminal fence: callers must resolve an unknown effect explicitly + * before they create another external action. + */ +export async function markExternalToolEffectUnknown( + database: D1Database, + input: { + commandId: DriverCommandId; + driverInstanceId: DriverInstanceId; + }, +): Promise { + const effect = await getExternalToolEffect(database, input); + + if (effect.status !== "executing") { + return; + } + + const nowMs = currentTimestampMs(); + const [update] = await runAppDatabaseBatch(database, (appDatabase) => [ + appDatabase + .update(externalToolEffectsTable) + .set({ + status: "unknown", + updatedAt: nowMs, + }) + .where( + and( + eq(externalToolEffectsTable.id, effect.id), + eq(externalToolEffectsTable.status, "executing"), + ), + ), + appDatabase + .update(externalToolEffectAttemptsTable) + .set({ + completedAt: nowMs, + status: "unknown", + }) + .where( + and( + eq(externalToolEffectAttemptsTable.effectId, effect.id), + eq(externalToolEffectAttemptsTable.attempt, effect.attemptCount), + eq(externalToolEffectAttemptsTable.status, "executing"), + ), + ), + ]); + + if (getD1ChangeCount(update) === 0) { + return; + } +} + +/** Marks all in-flight effects for a terminal Driver in two bounded writes. */ +export async function markExecutingExternalToolEffectsUnknownForDriver( + database: D1Database, + driverInstanceId: DriverInstanceId, +): Promise { + const effects = await getAppDatabase(database) + .select({ + attemptCount: externalToolEffectsTable.attemptCount, + id: externalToolEffectsTable.id, + }) + .from(externalToolEffectsTable) + .where( + and( + eq(externalToolEffectsTable.driverInstanceId, driverInstanceId), + eq(externalToolEffectsTable.status, "executing"), + ), + ) + .all(); + + if (effects.length === 0) { + return; + } + + const effectIds = effects.map((effect) => effect.id); + const nowMs = currentTimestampMs(); + await runAppDatabaseBatch(database, (appDatabase) => [ + appDatabase + .update(externalToolEffectsTable) + .set({ status: "unknown", updatedAt: nowMs }) + .where( + and( + eq(externalToolEffectsTable.driverInstanceId, driverInstanceId), + eq(externalToolEffectsTable.status, "executing"), + inArray(externalToolEffectsTable.id, effectIds), + ), + ), + appDatabase + .update(externalToolEffectAttemptsTable) + .set({ completedAt: nowMs, status: "unknown" }) + .where( + and( + inArray(externalToolEffectAttemptsTable.effectId, effectIds), + eq(externalToolEffectAttemptsTable.status, "executing"), + ), + ), + ]); +} + +export async function getExternalToolEffectForCommand( + database: D1Database, + input: { + commandId: DriverCommandId; + driverInstanceId: DriverInstanceId; + }, +): Promise<{ + attemptCount: number; + idempotencyKey: string; + providerReceiptJson: string | null; + sessionRunId: SessionRunId; + status: ExternalToolEffectStatus; +} | null> { + return ( + (await getAppDatabase(database) + .select({ + attemptCount: externalToolEffectsTable.attemptCount, + idempotencyKey: externalToolEffectsTable.idempotencyKey, + providerReceiptJson: externalToolEffectsTable.providerReceiptJson, + sessionRunId: externalToolEffectsTable.sessionRunId, + status: externalToolEffectsTable.status, + }) + .from(externalToolEffectsTable) + .where( + and( + eq(externalToolEffectsTable.commandId, input.commandId), + eq(externalToolEffectsTable.driverInstanceId, input.driverInstanceId), + ), + ) + .limit(1) + .get()) ?? null + ); +} diff --git a/apps/api/src/modules/runtime/infrastructure/session-runs/runtime-command-store.repository.ts b/apps/api/src/modules/runtime/infrastructure/session-runs/runtime-command-store.repository.ts index 519e943e..b190c407 100644 --- a/apps/api/src/modules/runtime/infrastructure/session-runs/runtime-command-store.repository.ts +++ b/apps/api/src/modules/runtime/infrastructure/session-runs/runtime-command-store.repository.ts @@ -6,14 +6,19 @@ import type { } from "@mosoo/contracts/runtime-command"; import type { RunError } from "@mosoo/contracts/session-run"; import { parseSchemaValue } from "@mosoo/contracts/validation"; -import { driverCommandsTable, driverInstancesTable } from "@mosoo/db"; +import { driverCommandsTable, driverInstancesTable, externalToolEffectsTable } from "@mosoo/db"; import { parsePlatformId } from "@mosoo/id"; import type { DriverCommandId, DriverInstanceId, SessionRunId } from "@mosoo/id"; import { and, asc, eq, exists, gt, inArray, isNull, lte, ne, or, sql } from "drizzle-orm"; -import { getAppDatabase, getD1ChangeCount } from "../../../../platform/db/drizzle"; +import { + getAppDatabase, + getD1ChangeCount, + runAppDatabaseBatch, +} from "../../../../platform/db/drizzle"; import { currentTimestampMs, toIsoString } from "../../../../time"; import { LIVE_DRIVER_INSTANCE_STATUSES } from "../../domain/driver-instance-lifecycle.machine"; +import { prepareExternalToolEffectIntent } from "./external-tool-effect-store.repository"; import { toRuntimeCommandRecordFromRow } from "./runtime-command-record.mapper"; import type { RuntimeCommandRecordRow } from "./runtime-command-record.mapper"; import { @@ -133,29 +138,41 @@ async function createRuntimeCommandRecordAttempt( throw new Error("Failed to allocate a runtime command sequence."); } - const seq = await getNextRuntimeCommandSeq(database, input.driverInstanceId); - try { - await getAppDatabase(database) - .insert(driverCommandsTable) - .values({ - ackedAt: null, - completedAt: null, - deliveryConnectionId: null, - driverInstanceId: input.driverInstanceId, - errorJson: null, - expiresAt: input.expiresAt ?? null, - id: state.commandId, - issuedAt: state.issuedAt, - kind: input.command.kind, - payloadJson: state.payloadJson, - resultJson: null, - seq, - status: state.status, - }) - .run(); + const externalToolEffectIntent = + input.command.kind === "mcp.execute" + ? await prepareExternalToolEffectIntent(database, { + command: input.command, + driverInstanceId: input.driverInstanceId, + }) + : null; + const seq = await getNextRuntimeCommandSeq(database, input.driverInstanceId); + const commandValues = { + ackedAt: null, + completedAt: null, + deliveryConnectionId: null, + driverInstanceId: input.driverInstanceId, + errorJson: null, + expiresAt: input.expiresAt ?? null, + id: state.commandId, + issuedAt: state.issuedAt, + kind: input.command.kind, + payloadJson: state.payloadJson, + resultJson: null, + seq, + status: state.status, + }; + + if (externalToolEffectIntent === null) { + await getAppDatabase(database).insert(driverCommandsTable).values(commandValues).run(); + } else { + await runAppDatabaseBatch(database, (appDatabase) => [ + appDatabase.insert(driverCommandsTable).values(commandValues), + appDatabase.insert(externalToolEffectsTable).values(externalToolEffectIntent), + ]); + } - return parseSchemaValue(RuntimeCommandRecord, { + const record = parseSchemaValue(RuntimeCommandRecord, { ackedAt: null, completedAt: null, driverInstanceId: input.driverInstanceId, @@ -172,6 +189,8 @@ async function createRuntimeCommandRecordAttempt( seq, status: state.status, }); + + return record; } catch (error) { if (state.attempt < 4 && isDriverCommandSeqConflict(error)) { return createRuntimeCommandRecordAttempt(database, input, { diff --git a/apps/api/tests/driver-finalization-repair.test.ts b/apps/api/tests/driver-finalization-repair.test.ts index a3ba2549..9e30023a 100644 --- a/apps/api/tests/driver-finalization-repair.test.ts +++ b/apps/api/tests/driver-finalization-repair.test.ts @@ -3,8 +3,25 @@ import { describe, expect, test } from "bun:test"; import type { RuntimeCommand } from "@mosoo/contracts/runtime-command"; import type { DriverCommandId, DriverInstanceId, SessionRunId } from "@mosoo/id"; +import type { AgentDriverBackend } from "../../driver/src/core/agent-driver-backend"; +import { createAgentDriverContext } from "../../driver/src/core/agent-driver-backend"; +import { DriverCommandDispatcher } from "../../driver/src/core/driver-command-dispatcher"; +import { DriverPermissionBroker } from "../../driver/src/core/driver-permission-broker"; +import type { DriverRuntimeIo } from "../../driver/src/core/driver-runtime-io"; +import { DriverRuntimeStateMachine } from "../../driver/src/core/driver-runtime-state"; +import type { AgentDriverMcpPort } from "../../driver/src/host-ports"; +import { createBufferedSinkLogger } from "../../driver/src/observability"; +import { createDriverStartInputFromBootPayload } from "../../driver/src/protocol/start"; +import type { RuntimeCommand as DriverRuntimeCommand } from "../../driver/src/runtime-command"; +import { driverBootPayload } from "../../driver/tests/driver-boot-payload-fixture"; import { recordCanonicalSessionRunFailure } from "../src/modules/runtime/application/session-runs/session-run-terminal-failure.service"; import { repairFinalizedTerminalDriverRunState } from "../src/modules/runtime/infrastructure/driver-instance/terminal-run-release"; +import { + claimExternalToolEffect, + completeExternalToolEffect, + getExternalToolEffectForCommand, + markExternalToolEffectUnknown, +} from "../src/modules/runtime/infrastructure/session-runs/external-tool-effect-store.repository"; import { createRuntimeCommandRecord, getRuntimeCommandRecord, @@ -20,6 +37,7 @@ import type { SqliteD1Database } from "./helpers/public-api-http-test-fixture"; const FINALIZE_RUN_ID = "01J0000000000000000000000T" as SessionRunId; const FINALIZE_COMMAND_ID = "01J0000000000000000000000V" as DriverCommandId; +const MCP_COMMAND_ID = "01J0000000000000000000000X" as DriverCommandId; const FINALIZE_CLOUDFLARE_SESSION_ID = "01J0000000000000000000000W"; const TURN_INTERRUPTED_MESSAGE = "This turn was interrupted before it completed. Please resend your last request."; @@ -53,6 +71,155 @@ interface DriverInterruptionBenchmarkMetrics { viewerTerminalRate: string; } +class PersistentEffectDriverIo implements DriverRuntimeIo { + readonly completedReceipt = Promise.withResolvers(); + readonly effectPersisted = Promise.withResolvers(); + readonly updates: Parameters[0][] = []; + readonly #commands: readonly DriverRuntimeCommand[]; + readonly #database: SqliteD1Database; + readonly #driverInstanceId: DriverInstanceId; + readonly #loseCompletedReceipt: boolean; + #commandIndex = 0; + + constructor(input: { + commands: readonly DriverRuntimeCommand[]; + database: SqliteD1Database; + driverInstanceId: DriverInstanceId; + loseCompletedReceipt?: boolean; + }) { + this.#commands = input.commands; + this.#database = input.database; + this.#driverInstanceId = input.driverInstanceId; + this.#loseCompletedReceipt = input.loseCompletedReceipt ?? false; + } + + beginRun(): void {} + + async claimExternalToolEffect( + input: Parameters[0], + _signal: AbortSignal, + ): ReturnType { + return claimExternalToolEffect(this.#database, { + commandId: input.commandId as DriverCommandId, + driverInstanceId: this.#driverInstanceId, + }); + } + + async commandUpdate( + input: Parameters[0], + _signal: AbortSignal, + ): Promise { + this.updates.push(input); + + if (this.#loseCompletedReceipt && input.status === "completed") { + throw new Error("injected terminal receipt loss after durable effect completion"); + } + + if (input.status === "completed") { + this.completedReceipt.resolve(); + } + } + + async completeExternalToolEffect( + input: Parameters[0], + _signal: AbortSignal, + ): Promise { + await completeExternalToolEffect(this.#database, { + commandId: input.commandId as DriverCommandId, + driverInstanceId: this.#driverInstanceId, + ...(input.providerReceiptJson === undefined + ? {} + : { providerReceiptJson: input.providerReceiptJson }), + result: input.result, + }); + this.effectPersisted.resolve(); + } + + async completeRun(): Promise {} + + endRun(): void {} + + async failRun(): Promise {} + + async heartbeat(): ReturnType { + return { heartbeatCount: 1, ok: true }; + } + + isDrained(): boolean { + return this.#commandIndex >= this.#commands.length; + } + + async markExternalToolEffectUnknown( + input: Parameters[0], + _signal: AbortSignal, + ): Promise { + await markExternalToolEffectUnknown(this.#database, { + commandId: input.commandId as DriverCommandId, + driverInstanceId: this.#driverInstanceId, + }); + } + + async nextCommand(_signal: AbortSignal): Promise { + const command = this.#commands[this.#commandIndex] ?? null; + + if (command !== null) { + this.#commandIndex += 1; + } + + return command; + } + + async pushEvents( + input: Parameters[0], + ): ReturnType { + return { + accepted: input.events.map((event, index) => ({ seq: index + 1, type: event.kind })), + }; + } +} + +function createPersistentEffectDispatcher(input: { + io: PersistentEffectDriverIo; + mcpExecute: AgentDriverMcpPort["execute"]; +}): { dispatcher: DriverCommandDispatcher; logger: ReturnType } { + const logger = createBufferedSinkLogger({ + level: "debug", + service: "persistent-effect-dispatcher-test", + sink: async () => {}, + }); + const backend: AgentDriverBackend = { + cancelActiveTurn: async () => {}, + handleInput: async () => {}, + runtime: "openai-runtime", + start: async () => {}, + stop: async () => {}, + }; + const payload = createDriverStartInputFromBootPayload(driverBootPayload); + const dispatcher = new DriverCommandDispatcher({ + backend, + driverInstanceId: PUBLIC_API_TEST_IDS.driverOwner, + isShuttingDown: () => input.io.isDrained(), + permissionRequests: new DriverPermissionBroker(() => logger), + runtimeContextFactory: (socket, runtimeLogger) => + createAgentDriverContext({ + eventSink: socket, + logger: runtimeLogger, + payload, + permission: { request: async () => "reject_once" }, + ports: { + commandSource: { nextCommand: (signal) => socket.nextCommand(signal) }, + mcp: { execute: input.mcpExecute }, + }, + }), + runtimeState: new DriverRuntimeStateMachine("ready"), + sandboxId: payload.sandboxId, + shutdown: async () => {}, + shutdownSignal: new AbortController().signal, + }); + + return { dispatcher, logger }; +} + function inputStartCommand(id: DriverCommandId): RuntimeCommand { return { commandId: id, @@ -65,6 +232,17 @@ function inputStartCommand(id: DriverCommandId): RuntimeCommand { }; } +function mcpExecuteCommand(id: DriverCommandId): RuntimeCommand { + return { + argumentsJson: '{"title":"do not duplicate"}', + commandId: id, + kind: "mcp.execute", + requestId: `request-${id}`, + serverId: "01J0000000000000000000000Y", + toolName: "createIssue", + }; +} + async function insertFinalizedDriverLeaseFixture(database: SqliteD1Database): Promise { await insertOwnerSession(database); database.execute(` @@ -83,6 +261,33 @@ async function insertFinalizedDriverLeaseFixture(database: SqliteD1Database): Pr seq integer NOT NULL, status text NOT NULL ); + + CREATE TABLE IF NOT EXISTS external_tool_effect ( + attempt_count integer NOT NULL, + command_id text NOT NULL UNIQUE, + created_at integer NOT NULL, + driver_instance_id text NOT NULL, + id text PRIMARY KEY NOT NULL, + idempotency_key text NOT NULL UNIQUE, + provider_receipt_json text, + result_json text, + server_id text NOT NULL, + session_run_id text NOT NULL, + status text NOT NULL, + tool_name text NOT NULL, + updated_at integer NOT NULL + ); + + CREATE TABLE IF NOT EXISTS external_tool_effect_attempt ( + attempt integer NOT NULL, + completed_at integer, + created_at integer NOT NULL, + effect_id text NOT NULL, + provider_receipt_json text, + result_json text, + status text NOT NULL, + PRIMARY KEY (effect_id, attempt) + ); `); await database .prepare( @@ -421,6 +626,210 @@ describe("driver finalization repair", () => { ); }); + test("does not queue an MCP command when its durable effect intent cannot be prepared", async () => { + const database = await createPublicHttpContractDatabase(); + await insertFinalizedDriverLeaseFixture(database); + await database + .prepare("UPDATE session_run SET status = 'failed' WHERE id = ?") + .bind(FINALIZE_RUN_ID) + .run(); + + await expect( + createRuntimeCommandRecord(database, { + command: mcpExecuteCommand(MCP_COMMAND_ID), + driverInstanceId: PUBLIC_API_TEST_IDS.driverOwner as DriverInstanceId, + status: "accepted", + }), + ).rejects.toThrow("MCP external tool effects require an active Session Run."); + + expect( + await getRuntimeCommandRecord( + database, + PUBLIC_API_TEST_IDS.driverOwner as DriverInstanceId, + MCP_COMMAND_ID, + ), + ).toBeNull(); + }); + + test("persists the MCP effect intent and fences it as unknown after Driver loss", async () => { + const database = await createPublicHttpContractDatabase(); + await insertFinalizedDriverLeaseFixture(database); + const bindings = createPublicHttpTestBindings(database) as ApiBindings; + + await createRuntimeCommandRecord(database, { + command: mcpExecuteCommand(MCP_COMMAND_ID), + driverInstanceId: PUBLIC_API_TEST_IDS.driverOwner as DriverInstanceId, + status: "accepted", + }); + + const intent = await getExternalToolEffectForCommand(database, { + commandId: MCP_COMMAND_ID, + driverInstanceId: PUBLIC_API_TEST_IDS.driverOwner as DriverInstanceId, + }); + expect(intent).toMatchObject({ + attemptCount: 0, + sessionRunId: FINALIZE_RUN_ID, + status: "intent", + }); + expect(intent?.idempotencyKey).toHaveLength(26); + + const claim = await claimExternalToolEffect(database, { + commandId: MCP_COMMAND_ID, + driverInstanceId: PUBLIC_API_TEST_IDS.driverOwner as DriverInstanceId, + }); + expect(claim).toMatchObject({ attempt: 1, kind: "execute" }); + + await repairFinalizedTerminalDriverRunState(bindings, { + driverInstanceId: PUBLIC_API_TEST_IDS.driverOwner as DriverInstanceId, + status: "failed", + }); + + await expect( + claimExternalToolEffect(database, { + commandId: MCP_COMMAND_ID, + driverInstanceId: PUBLIC_API_TEST_IDS.driverOwner as DriverInstanceId, + }), + ).resolves.toMatchObject({ kind: "unknown" }); + expect( + await getExternalToolEffectForCommand(database, { + commandId: MCP_COMMAND_ID, + driverInstanceId: PUBLIC_API_TEST_IDS.driverOwner as DriverInstanceId, + }), + ).toMatchObject({ attemptCount: 1, status: "unknown" }); + expect( + await database + .prepare("SELECT completed_at, status FROM external_tool_effect_attempt") + .first<{ completed_at: number; status: string }>(), + ).toMatchObject({ status: "unknown" }); + }); + + test("redelivers a persisted successful MCP result without a second provider invocation", async () => { + const database = await createPublicHttpContractDatabase(); + await insertFinalizedDriverLeaseFixture(database); + + await createRuntimeCommandRecord(database, { + command: mcpExecuteCommand(MCP_COMMAND_ID), + driverInstanceId: PUBLIC_API_TEST_IDS.driverOwner as DriverInstanceId, + status: "accepted", + }); + await claimExternalToolEffect(database, { + commandId: MCP_COMMAND_ID, + driverInstanceId: PUBLIC_API_TEST_IDS.driverOwner as DriverInstanceId, + }); + await completeExternalToolEffect(database, { + commandId: MCP_COMMAND_ID, + driverInstanceId: PUBLIC_API_TEST_IDS.driverOwner as DriverInstanceId, + providerReceiptJson: '{"orderId":"A-1"}', + result: { + outputText: "created issue A-1", + requestId: "request-01J0000000000000000000000X", + serverId: "01J0000000000000000000000Y", + toolName: "createIssue", + }, + }); + + await expect( + claimExternalToolEffect(database, { + commandId: MCP_COMMAND_ID, + driverInstanceId: PUBLIC_API_TEST_IDS.driverOwner as DriverInstanceId, + }), + ).resolves.toMatchObject({ + kind: "completed", + result: { + outputText: "created issue A-1", + requestId: "request-01J0000000000000000000000X", + serverId: "01J0000000000000000000000Y", + toolName: "createIssue", + }, + }); + expect( + await getExternalToolEffectForCommand(database, { + commandId: MCP_COMMAND_ID, + driverInstanceId: PUBLIC_API_TEST_IDS.driverOwner as DriverInstanceId, + }), + ).toMatchObject({ providerReceiptJson: '{"orderId":"A-1"}', status: "succeeded" }); + expect( + await database + .prepare("SELECT provider_receipt_json FROM external_tool_effect_attempt") + .first<{ provider_receipt_json: string | null }>(), + ).toEqual({ provider_receipt_json: '{"orderId":"A-1"}' }); + }); + + test("restarts a real Driver dispatcher without replaying a persisted MCP effect", async () => { + const database = await createPublicHttpContractDatabase(); + await insertFinalizedDriverLeaseFixture(database); + const command = mcpExecuteCommand(MCP_COMMAND_ID) as DriverRuntimeCommand; + const driverInstanceId = PUBLIC_API_TEST_IDS.driverOwner as DriverInstanceId; + await createRuntimeCommandRecord(database, { + command, + driverInstanceId, + status: "accepted", + }); + + let providerCalls = 0; + const firstIo = new PersistentEffectDriverIo({ + commands: [command], + database, + driverInstanceId, + loseCompletedReceipt: true, + }); + const first = createPersistentEffectDispatcher({ + io: firstIo, + mcpExecute: async (request) => { + providerCalls += 1; + return { + outputText: "created issue A-1", + providerReceiptJson: '{"orderId":"A-1"}', + requestId: request.requestId, + serverId: request.serverId, + toolName: request.toolName, + }; + }, + }); + + await first.dispatcher.run(firstIo, first.logger); + await firstIo.effectPersisted.promise; + await first.logger.destroy(); + + const secondIo = new PersistentEffectDriverIo({ + commands: [structuredClone(command)], + database, + driverInstanceId, + }); + const second = createPersistentEffectDispatcher({ + io: secondIo, + mcpExecute: async () => { + providerCalls += 1; + throw new Error("provider must not run after durable effect completion"); + }, + }); + + await second.dispatcher.run(secondIo, second.logger); + await secondIo.completedReceipt.promise; + await second.logger.destroy(); + + expect(providerCalls).toBe(1); + expect(secondIo.updates).toMatchObject([ + { commandId: command.commandId, status: "accepted" }, + { + commandId: command.commandId, + result: { + outputText: "created issue A-1", + requestId: command.requestId, + serverId: command.serverId, + toolName: command.toolName, + }, + status: "completed", + }, + ]); + expect( + await getExternalToolEffectForCommand(database, { + commandId: MCP_COMMAND_ID, + driverInstanceId, + }), + ).toMatchObject({ providerReceiptJson: '{"orderId":"A-1"}', status: "succeeded" }); + }); + test("benchmarks driver interruption finalization over 20 fault injections", async () => { const before = summarizeDriverInterruptionBenchmark( Array.from({ length: 20 }, () => createBeforeBenchmarkSample()), diff --git a/apps/driver b/apps/driver index 1b3f6ac6..8e55ce27 160000 --- a/apps/driver +++ b/apps/driver @@ -1 +1 @@ -Subproject commit 1b3f6ac6b5521ddf0ae945e5efbe3b45080b32e9 +Subproject commit 8e55ce27cc374c62dd675ec9997296d22f76dd5d diff --git a/docs/prd/session-lifecycle.md b/docs/prd/session-lifecycle.md index b2825bba..71f7245f 100644 --- a/docs/prd/session-lifecycle.md +++ b/docs/prd/session-lifecycle.md @@ -21,7 +21,14 @@ they create or continue work for an end user. 3. When an attempt completes or fails, the conversation and saved files remain readable. The user can send a follow-up. Preview offers retry actions for some provider checks and send failures. After an unexpected runtime loss, mosoo reports the failure but does not - automatically replay the request; the user must deliberately resend it. + automatically replay the request; the user must deliberately resend it. If the Run had a + write-capable external tool call whose final receipt was lost, Mosoo records the effect as + **unknown** and blocks automatic replay; an operator or the user must explicitly resolve it. + The error includes the durable effect id. For generic MCP servers, Mosoo sends a stable + idempotency key in request metadata and retains any returned metadata as an opaque provider + receipt, but MCP defines no universal receipt lookup or compensation protocol. Mosoo therefore + never infers that an unknown effect is safe to retry: creating another external action is a + deliberate user or operator decision, not recovery automation. 4. **Archive** moves the Thread out of active work. Its history and saved files stay readable, but messages and file changes are blocked. In the Console, sending a follow-up restores the Thread first. Archiving also asks active work to stop; if cleanup fails, the Thread can already diff --git a/pkgs/contracts/package.json b/pkgs/contracts/package.json index 128e14b7..bc10eb15 100644 --- a/pkgs/contracts/package.json +++ b/pkgs/contracts/package.json @@ -14,6 +14,7 @@ "./auth": "./src/auth/auth.contract.ts", "./channel": "./src/channel/channel.contract.ts", "./driver-instance": "./src/runtime/driver-instance.contract.ts", + "./external-tool-effect": "./src/runtime/external-tool-effect.contract.ts", "./environment": "./src/environment/environment.contract.ts", "./file": "./src/file/file.contract.ts", "./mcp": "./src/mcp/mcp.contract.ts", diff --git a/pkgs/contracts/src/index.ts b/pkgs/contracts/src/index.ts index f2f7359d..9bc6b653 100644 --- a/pkgs/contracts/src/index.ts +++ b/pkgs/contracts/src/index.ts @@ -15,6 +15,7 @@ export type * from "./transport/operation-result.contract"; export * from "./http/public-api.contract"; export type * from "./id/id.contract"; export * from "./runtime/driver-instance.contract"; +export * from "./runtime/external-tool-effect.contract"; export * from "./runtime/runtime-command.contract"; export * from "./runtime/sandbox.contract"; export type * from "./session/session.contract"; diff --git a/pkgs/contracts/src/runtime/external-tool-effect.contract.ts b/pkgs/contracts/src/runtime/external-tool-effect.contract.ts new file mode 100644 index 00000000..b14f100b --- /dev/null +++ b/pkgs/contracts/src/runtime/external-tool-effect.contract.ts @@ -0,0 +1,37 @@ +import { type } from "arktype"; + +import { NonEmptyString } from "../validation/primitives.contract"; +import { McpExecuteCommandResult } from "./runtime-command.contract"; + +/** + * Durable state for a write-capable call made outside the Mosoo control plane. + * + * An effect never transitions out of `unknown` automatically: no generic MCP + * receipt or reconciliation protocol exists, so replay would be unsafe. + */ +export const ExternalToolEffectStatus = type('"intent" | "executing" | "succeeded" | "unknown"'); +export type ExternalToolEffectStatus = typeof ExternalToolEffectStatus.infer; + +export const ExternalToolEffectAttemptStatus = type('"executing" | "succeeded" | "unknown"'); +export type ExternalToolEffectAttemptStatus = typeof ExternalToolEffectAttemptStatus.infer; + +export const ExternalToolEffectClaim = type({ + attempt: "number >= 1", + effectId: NonEmptyString, + idempotencyKey: NonEmptyString, + kind: '"execute"', +}) + .or( + type({ + effectId: NonEmptyString, + kind: '"completed"', + result: McpExecuteCommandResult, + }), + ) + .or( + type({ + effectId: NonEmptyString, + kind: '"unknown"', + }), + ); +export type ExternalToolEffectClaim = typeof ExternalToolEffectClaim.infer; diff --git a/pkgs/db/drizzle/0005_external-tool-effects.sql b/pkgs/db/drizzle/0005_external-tool-effects.sql new file mode 100644 index 00000000..0c6c1d1c --- /dev/null +++ b/pkgs/db/drizzle/0005_external-tool-effects.sql @@ -0,0 +1,38 @@ +CREATE TABLE `external_tool_effect_attempt` ( + `attempt` integer NOT NULL, + `completed_at` integer, + `created_at` integer NOT NULL, + `effect_id` text CHECK ("effect_id" = upper("effect_id") AND length("effect_id") = 26 AND substr("effect_id", 1, 1) GLOB '[0-7]' AND "effect_id" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*') NOT NULL, + `provider_receipt_json` text, + `result_json` text, + `status` text NOT NULL, + PRIMARY KEY(`effect_id`, `attempt`), + FOREIGN KEY (`effect_id`) REFERENCES `external_tool_effect`(`id`) ON UPDATE no action ON DELETE cascade, + CONSTRAINT "external_tool_effect_attempt_status_check" CHECK("external_tool_effect_attempt"."status" IN ('executing', 'succeeded', 'unknown')) +); +--> statement-breakpoint +CREATE INDEX `external_tool_effect_attempt_status_idx` ON `external_tool_effect_attempt` (`status`,`created_at`);--> statement-breakpoint +CREATE TABLE `external_tool_effect` ( + `attempt_count` integer DEFAULT 0 NOT NULL, + `command_id` text CHECK ("command_id" = upper("command_id") AND length("command_id") = 26 AND substr("command_id", 1, 1) GLOB '[0-7]' AND "command_id" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*') NOT NULL, + `created_at` integer NOT NULL, + `driver_instance_id` text CHECK ("driver_instance_id" = upper("driver_instance_id") AND length("driver_instance_id") = 26 AND substr("driver_instance_id", 1, 1) GLOB '[0-7]' AND "driver_instance_id" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*') NOT NULL, + `id` text CHECK ("id" = upper("id") AND length("id") = 26 AND substr("id", 1, 1) GLOB '[0-7]' AND "id" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*') PRIMARY KEY NOT NULL, + `idempotency_key` text NOT NULL, + `provider_receipt_json` text, + `result_json` text, + `server_id` text CHECK ("server_id" = upper("server_id") AND length("server_id") = 26 AND substr("server_id", 1, 1) GLOB '[0-7]' AND "server_id" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*') NOT NULL, + `session_run_id` text CHECK ("session_run_id" = upper("session_run_id") AND length("session_run_id") = 26 AND substr("session_run_id", 1, 1) GLOB '[0-7]' AND "session_run_id" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*') NOT NULL, + `status` text NOT NULL, + `tool_name` text NOT NULL, + `updated_at` integer NOT NULL, + FOREIGN KEY (`command_id`) REFERENCES `driver_command`(`id`) ON UPDATE no action ON DELETE cascade, + FOREIGN KEY (`driver_instance_id`) REFERENCES `driver_instance`(`id`) ON UPDATE no action ON DELETE cascade, + FOREIGN KEY (`session_run_id`) REFERENCES `session_run`(`id`) ON UPDATE no action ON DELETE cascade, + CONSTRAINT "external_tool_effect_status_check" CHECK("external_tool_effect"."status" IN ('intent', 'executing', 'succeeded', 'unknown')) +); +--> statement-breakpoint +CREATE UNIQUE INDEX `external_tool_effect_command_idx` ON `external_tool_effect` (`command_id`);--> statement-breakpoint +CREATE UNIQUE INDEX `external_tool_effect_idempotency_key_idx` ON `external_tool_effect` (`idempotency_key`);--> statement-breakpoint +CREATE INDEX `external_tool_effect_run_status_idx` ON `external_tool_effect` (`session_run_id`,`status`,`id`);--> statement-breakpoint +CREATE INDEX `external_tool_effect_driver_status_idx` ON `external_tool_effect` (`driver_instance_id`,`status`); diff --git a/pkgs/db/drizzle/meta/0005_snapshot.json b/pkgs/db/drizzle/meta/0005_snapshot.json new file mode 100644 index 00000000..65426b2b --- /dev/null +++ b/pkgs/db/drizzle/meta/0005_snapshot.json @@ -0,0 +1,7423 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "b331b152-4aac-412a-ab15-545a0104faf7", + "prevId": "b7c2f1a4-3e6d-4a8b-9c0f-1d2e3f4a5b6c", + "tables": { + "agent_deployment_version": { + "name": "agent_deployment_version", + "columns": { + "agent_id": { + "name": "agent_id", + "type": "text CHECK (\"agent_id\" = upper(\"agent_id\") AND length(\"agent_id\") = 26 AND substr(\"agent_id\", 1, 1) GLOB '[0-7]' AND \"agent_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "config_json": { + "name": "config_json", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by_account_id": { + "name": "created_by_account_id", + "type": "text CHECK (\"created_by_account_id\" = upper(\"created_by_account_id\") AND length(\"created_by_account_id\") = 26 AND substr(\"created_by_account_id\", 1, 1) GLOB '[0-7]' AND \"created_by_account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "environment_id": { + "name": "environment_id", + "type": "text CHECK (\"environment_id\" = upper(\"environment_id\") AND length(\"environment_id\") = 26 AND substr(\"environment_id\", 1, 1) GLOB '[0-7]' AND \"environment_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "mcp_bindings_json": { + "name": "mcp_bindings_json", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "runtime_id": { + "name": "runtime_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "skills_json": { + "name": "skills_json", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "version_number": { + "name": "version_number", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "agent_deployment_version_agent_number_idx": { + "name": "agent_deployment_version_agent_number_idx", + "columns": ["agent_id", "version_number"], + "isUnique": true + }, + "agent_deployment_version_agent_created_idx": { + "name": "agent_deployment_version_agent_created_idx", + "columns": ["agent_id", "created_at"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "agent_mcp_binding": { + "name": "agent_mcp_binding", + "columns": { + "agent_credential_id": { + "name": "agent_credential_id", + "type": "text CHECK (\"agent_credential_id\" = upper(\"agent_credential_id\") AND length(\"agent_credential_id\") = 26 AND substr(\"agent_credential_id\", 1, 1) GLOB '[0-7]' AND \"agent_credential_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text CHECK (\"agent_id\" = upper(\"agent_id\") AND length(\"agent_id\") = 26 AND substr(\"agent_id\", 1, 1) GLOB '[0-7]' AND \"agent_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_mode": { + "name": "credential_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'runtime_resolved'" + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "server_id": { + "name": "server_id", + "type": "text CHECK (\"server_id\" = upper(\"server_id\") AND length(\"server_id\") = 26 AND substr(\"server_id\", 1, 1) GLOB '[0-7]' AND \"server_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "agent_mcp_binding_agent_sort_idx": { + "name": "agent_mcp_binding_agent_sort_idx", + "columns": ["agent_id", "sort_order"], + "isUnique": true + }, + "agent_mcp_binding_server_idx": { + "name": "agent_mcp_binding_server_idx", + "columns": ["server_id"], + "isUnique": false + }, + "agent_mcp_binding_profile_server_idx": { + "name": "agent_mcp_binding_profile_server_idx", + "columns": ["agent_id", "server_id"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "agent_mcp_binding_agent_credential_shape_check": { + "name": "agent_mcp_binding_agent_credential_shape_check", + "value": "\n (\"agent_mcp_binding\".\"credential_mode\" = 'agent_bound' AND \"agent_mcp_binding\".\"agent_credential_id\" IS NOT NULL)\n OR (\"agent_mcp_binding\".\"credential_mode\" = 'runtime_resolved' AND \"agent_mcp_binding\".\"agent_credential_id\" IS NULL)\n " + } + } + }, + "agent_skill": { + "name": "agent_skill", + "columns": { + "agent_id": { + "name": "agent_id", + "type": "text CHECK (\"agent_id\" = upper(\"agent_id\") AND length(\"agent_id\") = 26 AND substr(\"agent_id\", 1, 1) GLOB '[0-7]' AND \"agent_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "skill_id": { + "name": "skill_id", + "type": "text CHECK (\"skill_id\" = upper(\"skill_id\") AND length(\"skill_id\") = 26 AND substr(\"skill_id\", 1, 1) GLOB '[0-7]' AND \"skill_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "agent_skill_agent_sort_idx": { + "name": "agent_skill_agent_sort_idx", + "columns": ["agent_id", "sort_order"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "agent_skill_agent_id_skill_id_pk": { + "columns": ["agent_id", "skill_id"], + "name": "agent_skill_agent_id_skill_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "agent": { + "name": "agent", + "columns": { + "config_json": { + "name": "config_json", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "environment_id": { + "name": "environment_id", + "type": "text CHECK (\"environment_id\" = upper(\"environment_id\") AND length(\"environment_id\") = 26 AND substr(\"environment_id\", 1, 1) GLOB '[0-7]' AND \"environment_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pet'" + }, + "live_deployment_version_id": { + "name": "live_deployment_version_id", + "type": "text CHECK (\"live_deployment_version_id\" = upper(\"live_deployment_version_id\") AND length(\"live_deployment_version_id\") = 26 AND substr(\"live_deployment_version_id\", 1, 1) GLOB '[0-7]' AND \"live_deployment_version_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "owner_account_id": { + "name": "owner_account_id", + "type": "text CHECK (\"owner_account_id\" = upper(\"owner_account_id\") AND length(\"owner_account_id\") = 26 AND substr(\"owner_account_id\", 1, 1) GLOB '[0-7]' AND \"owner_account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "app_id": { + "name": "app_id", + "type": "text CHECK (\"app_id\" = upper(\"app_id\") AND length(\"app_id\") = 26 AND substr(\"app_id\", 1, 1) GLOB '[0-7]' AND \"app_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "runtime_id": { + "name": "runtime_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'draft'" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'private'" + } + }, + "indexes": { + "agent_app_owner_account_idx": { + "name": "agent_app_owner_account_idx", + "columns": ["app_id", "owner_account_id"], + "isUnique": false + }, + "agent_app_status_idx": { + "name": "agent_app_status_idx", + "columns": ["app_id", "status"], + "isUnique": false + }, + "agent_environment_idx": { + "name": "agent_environment_idx", + "columns": ["environment_id"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "agent_published_live_deployment_version_check": { + "name": "agent_published_live_deployment_version_check", + "value": "\"agent\".\"status\" <> 'published' OR \"agent\".\"live_deployment_version_id\" IS NOT NULL" + } + } + }, + "api_command": { + "name": "api_command", + "columns": { + "attempt_count": { + "name": "attempt_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "claim_expires_at": { + "name": "claim_expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "claim_owner": { + "name": "claim_owner", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "completed_at": { + "name": "completed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "dedupe_key": { + "name": "dedupe_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_error_code": { + "name": "last_error_code", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_error_message": { + "name": "last_error_message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payload_json": { + "name": "payload_json", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "api_command_dedupe_idx": { + "name": "api_command_dedupe_idx", + "columns": ["dedupe_key"], + "isUnique": true + }, + "api_command_status_updated_idx": { + "name": "api_command_status_updated_idx", + "columns": ["status", "updated_at"], + "isUnique": false + }, + "api_command_claim_idx": { + "name": "api_command_claim_idx", + "columns": ["status", "claim_expires_at"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "auth_account": { + "name": "auth_account", + "columns": { + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "provider_account_id": { + "name": "provider_account_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "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 + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "account_id": { + "name": "account_id", + "type": "text CHECK (\"account_id\" = upper(\"account_id\") AND length(\"account_id\") = 26 AND substr(\"account_id\", 1, 1) GLOB '[0-7]' AND \"account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "auth_account_provider_account_idx": { + "name": "auth_account_provider_account_idx", + "columns": ["provider_id", "provider_account_id"], + "isUnique": true + }, + "auth_account_account_id_idx": { + "name": "auth_account_account_id_idx", + "columns": ["account_id"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "auth_session": { + "name": "auth_session", + "columns": { + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "account_id": { + "name": "account_id", + "type": "text CHECK (\"account_id\" = upper(\"account_id\") AND length(\"account_id\") = 26 AND substr(\"account_id\", 1, 1) GLOB '[0-7]' AND \"account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "auth_session_expires_at_idx": { + "name": "auth_session_expires_at_idx", + "columns": ["expires_at"], + "isUnique": false + }, + "auth_session_token_idx": { + "name": "auth_session_token_idx", + "columns": ["token"], + "isUnique": true + }, + "auth_session_account_id_idx": { + "name": "auth_session_account_id_idx", + "columns": ["account_id"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "auth_verification": { + "name": "auth_verification", + "columns": { + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "auth_verification_expires_at_idx": { + "name": "auth_verification_expires_at_idx", + "columns": ["expires_at"], + "isUnique": false + }, + "auth_verification_identifier_idx": { + "name": "auth_verification_identifier_idx", + "columns": ["identifier"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "cli_oauth_flow": { + "name": "cli_oauth_flow", + "columns": { + "account_id": { + "name": "account_id", + "type": "text CHECK (\"account_id\" = upper(\"account_id\") AND length(\"account_id\") = 26 AND substr(\"account_id\", 1, 1) GLOB '[0-7]' AND \"account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "authorized_at": { + "name": "authorized_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "completed_at": { + "name": "completed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "device_code_hash": { + "name": "device_code_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "hostname": { + "name": "hostname", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_code": { + "name": "user_code", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "cli_oauth_flow_status_expires_idx": { + "name": "cli_oauth_flow_status_expires_idx", + "columns": ["status", "expires_at"], + "isUnique": false + }, + "cli_oauth_flow_device_code_hash_idx": { + "name": "cli_oauth_flow_device_code_hash_idx", + "columns": ["device_code_hash"], + "isUnique": true + }, + "cli_oauth_flow_user_code_idx": { + "name": "cli_oauth_flow_user_code_idx", + "columns": ["user_code"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "personal_access_token": { + "name": "personal_access_token", + "columns": { + "account_id": { + "name": "account_id", + "type": "text CHECK (\"account_id\" = upper(\"account_id\") AND length(\"account_id\") = 26 AND substr(\"account_id\", 1, 1) GLOB '[0-7]' AND \"account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_used_at": { + "name": "last_used_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "revoked_at": { + "name": "revoked_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "personal_access_token_account_created_idx": { + "name": "personal_access_token_account_created_idx", + "columns": ["account_id", "created_at"], + "isUnique": false + }, + "personal_access_token_hash_idx": { + "name": "personal_access_token_hash_idx", + "columns": ["token_hash"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "agent_channel_binding": { + "name": "agent_channel_binding", + "columns": { + "agent_id": { + "name": "agent_id", + "type": "text CHECK (\"agent_id\" = upper(\"agent_id\") AND length(\"agent_id\") = 26 AND substr(\"agent_id\", 1, 1) GLOB '[0-7]' AND \"agent_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "display_metadata_json": { + "name": "display_metadata_json", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'{}'" + }, + "encrypted_creds_secret_id": { + "name": "encrypted_creds_secret_id", + "type": "text CHECK (\"encrypted_creds_secret_id\" = upper(\"encrypted_creds_secret_id\") AND length(\"encrypted_creds_secret_id\") = 26 AND substr(\"encrypted_creds_secret_id\", 1, 1) GLOB '[0-7]' AND \"encrypted_creds_secret_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_bot_id": { + "name": "external_bot_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_tenant_id": { + "name": "external_tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "last_error_code": { + "name": "last_error_code", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "app_id": { + "name": "app_id", + "type": "text CHECK (\"app_id\" = upper(\"app_id\") AND length(\"app_id\") = 26 AND substr(\"app_id\", 1, 1) GLOB '[0-7]' AND \"app_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "agent_channel_binding_agent_provider_idx": { + "name": "agent_channel_binding_agent_provider_idx", + "columns": ["agent_id", "provider"], + "isUnique": true + }, + "agent_channel_binding_provider_tenant_bot_idx": { + "name": "agent_channel_binding_provider_tenant_bot_idx", + "columns": ["provider", "external_tenant_id", "external_bot_id"], + "isUnique": true + }, + "agent_channel_binding_agent_status_idx": { + "name": "agent_channel_binding_agent_status_idx", + "columns": ["agent_id", "status"], + "isUnique": false + }, + "agent_channel_binding_app_status_idx": { + "name": "agent_channel_binding_app_status_idx", + "columns": ["app_id", "status"], + "isUnique": false + } + }, + "foreignKeys": { + "agent_channel_binding_agent_id_agent_id_fk": { + "name": "agent_channel_binding_agent_id_agent_id_fk", + "tableFrom": "agent_channel_binding", + "tableTo": "agent", + "columnsFrom": ["agent_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "agent_channel_binding_encrypted_creds_secret_id_vault_secret_id_fk": { + "name": "agent_channel_binding_encrypted_creds_secret_id_vault_secret_id_fk", + "tableFrom": "agent_channel_binding", + "tableTo": "vault_secret", + "columnsFrom": ["encrypted_creds_secret_id"], + "columnsTo": ["id"], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "agent_channel_binding_app_id_app_id_fk": { + "name": "agent_channel_binding_app_id_app_id_fk", + "tableFrom": "agent_channel_binding", + "tableTo": "app", + "columnsFrom": ["app_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "channel_runtime_state": { + "name": "channel_runtime_state", + "columns": { + "binding_id": { + "name": "binding_id", + "type": "text CHECK (\"binding_id\" = upper(\"binding_id\") AND length(\"binding_id\") = 26 AND substr(\"binding_id\", 1, 1) GLOB '[0-7]' AND \"binding_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "last_error_code": { + "name": "last_error_code", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_heartbeat_at": { + "name": "last_heartbeat_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_inbound_at": { + "name": "last_inbound_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_poll_at": { + "name": "last_poll_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "lease_expires_at": { + "name": "lease_expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "lease_owner_id": { + "name": "lease_owner_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "runtime_account_id": { + "name": "runtime_account_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "runtime_state_json": { + "name": "runtime_state_json", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'{}'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status_changed_at": { + "name": "status_changed_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "channel_runtime_state_provider_binding_account_idx": { + "name": "channel_runtime_state_provider_binding_account_idx", + "columns": ["provider", "binding_id", "runtime_account_id"], + "isUnique": true + }, + "channel_runtime_state_status_lease_idx": { + "name": "channel_runtime_state_status_lease_idx", + "columns": ["status", "lease_expires_at"], + "isUnique": false + }, + "channel_runtime_state_binding_updated_idx": { + "name": "channel_runtime_state_binding_updated_idx", + "columns": ["binding_id", "updated_at"], + "isUnique": false + } + }, + "foreignKeys": { + "channel_runtime_state_binding_id_agent_channel_binding_id_fk": { + "name": "channel_runtime_state_binding_id_agent_channel_binding_id_fk", + "tableFrom": "channel_runtime_state", + "tableTo": "agent_channel_binding", + "columnsFrom": ["binding_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "channel_event_receipt": { + "name": "channel_event_receipt", + "columns": { + "binding_id": { + "name": "binding_id", + "type": "text CHECK (\"binding_id\" = upper(\"binding_id\") AND length(\"binding_id\") = 26 AND substr(\"binding_id\", 1, 1) GLOB '[0-7]' AND \"binding_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_event_id": { + "name": "external_event_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_tenant_id": { + "name": "external_tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text CHECK (\"session_id\" = upper(\"session_id\") AND length(\"session_id\") = 26 AND substr(\"session_id\", 1, 1) GLOB '[0-7]' AND \"session_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "channel_event_receipt_provider_tenant_event_idx": { + "name": "channel_event_receipt_provider_tenant_event_idx", + "columns": ["provider", "external_tenant_id", "external_event_id"], + "isUnique": true + }, + "channel_event_receipt_binding_updated_idx": { + "name": "channel_event_receipt_binding_updated_idx", + "columns": ["binding_id", "updated_at"], + "isUnique": false + }, + "channel_event_receipt_expires_idx": { + "name": "channel_event_receipt_expires_idx", + "columns": ["expires_at"], + "isUnique": false + } + }, + "foreignKeys": { + "channel_event_receipt_binding_id_agent_channel_binding_id_fk": { + "name": "channel_event_receipt_binding_id_agent_channel_binding_id_fk", + "tableFrom": "channel_event_receipt", + "tableTo": "agent_channel_binding", + "columnsFrom": ["binding_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "channel_final_delivery_job": { + "name": "channel_final_delivery_job", + "columns": { + "attempt_count": { + "name": "attempt_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "binding_id": { + "name": "binding_id", + "type": "text CHECK (\"binding_id\" = upper(\"binding_id\") AND length(\"binding_id\") = 26 AND substr(\"binding_id\", 1, 1) GLOB '[0-7]' AND \"binding_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_event_id": { + "name": "external_event_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "last_error_code": { + "name": "last_error_code", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payload_json": { + "name": "payload_json", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "run_id": { + "name": "run_id", + "type": "text CHECK (\"run_id\" = upper(\"run_id\") AND length(\"run_id\") = 26 AND substr(\"run_id\", 1, 1) GLOB '[0-7]' AND \"run_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text CHECK (\"session_id\" = upper(\"session_id\") AND length(\"session_id\") = 26 AND substr(\"session_id\", 1, 1) GLOB '[0-7]' AND \"session_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "channel_final_delivery_provider_binding_event_idx": { + "name": "channel_final_delivery_provider_binding_event_idx", + "columns": ["provider", "binding_id", "external_event_id"], + "isUnique": true + }, + "channel_final_delivery_session_idx": { + "name": "channel_final_delivery_session_idx", + "columns": ["session_id"], + "isUnique": false + }, + "channel_final_delivery_run_idx": { + "name": "channel_final_delivery_run_idx", + "columns": ["run_id"], + "isUnique": false + } + }, + "foreignKeys": { + "channel_final_delivery_job_binding_id_agent_channel_binding_id_fk": { + "name": "channel_final_delivery_job_binding_id_agent_channel_binding_id_fk", + "tableFrom": "channel_final_delivery_job", + "tableTo": "agent_channel_binding", + "columnsFrom": ["binding_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "channel_final_delivery_job_run_id_session_run_id_fk": { + "name": "channel_final_delivery_job_run_id_session_run_id_fk", + "tableFrom": "channel_final_delivery_job", + "tableTo": "session_run", + "columnsFrom": ["run_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "channel_final_delivery_job_session_id_session_id_fk": { + "name": "channel_final_delivery_job_session_id_session_id_fk", + "tableFrom": "channel_final_delivery_job", + "tableTo": "session", + "columnsFrom": ["session_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "channel_thread_session": { + "name": "channel_thread_session", + "columns": { + "binding_id": { + "name": "binding_id", + "type": "text CHECK (\"binding_id\" = upper(\"binding_id\") AND length(\"binding_id\") = 26 AND substr(\"binding_id\", 1, 1) GLOB '[0-7]' AND \"binding_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_thread_id": { + "name": "external_thread_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text CHECK (\"session_id\" = upper(\"session_id\") AND length(\"session_id\") = 26 AND substr(\"session_id\", 1, 1) GLOB '[0-7]' AND \"session_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "channel_thread_session_provider_binding_thread_idx": { + "name": "channel_thread_session_provider_binding_thread_idx", + "columns": ["provider", "binding_id", "external_thread_id"], + "isUnique": true + }, + "channel_thread_session_session_idx": { + "name": "channel_thread_session_session_idx", + "columns": ["session_id"], + "isUnique": false + } + }, + "foreignKeys": { + "channel_thread_session_binding_id_agent_channel_binding_id_fk": { + "name": "channel_thread_session_binding_id_agent_channel_binding_id_fk", + "tableFrom": "channel_thread_session", + "tableTo": "agent_channel_binding", + "columnsFrom": ["binding_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "channel_thread_session_session_id_session_id_fk": { + "name": "channel_thread_session_session_id_session_id_fk", + "tableFrom": "channel_thread_session", + "tableTo": "session", + "columnsFrom": ["session_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "wechat_channel_account": { + "name": "wechat_channel_account", + "columns": { + "agent_id": { + "name": "agent_id", + "type": "text CHECK (\"agent_id\" = upper(\"agent_id\") AND length(\"agent_id\") = 26 AND substr(\"agent_id\", 1, 1) GLOB '[0-7]' AND \"agent_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "base_url": { + "name": "base_url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "cursor": { + "name": "cursor", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "encrypted_creds_secret_id": { + "name": "encrypted_creds_secret_id", + "type": "text CHECK (\"encrypted_creds_secret_id\" = upper(\"encrypted_creds_secret_id\") AND length(\"encrypted_creds_secret_id\") = 26 AND substr(\"encrypted_creds_secret_id\", 1, 1) GLOB '[0-7]' AND \"encrypted_creds_secret_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_account_id": { + "name": "external_account_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_bot_id": { + "name": "external_bot_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "last_error_code": { + "name": "last_error_code", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_heartbeat_at": { + "name": "last_heartbeat_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_inbound_at": { + "name": "last_inbound_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_poll_at": { + "name": "last_poll_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "owner_account_id": { + "name": "owner_account_id", + "type": "text CHECK (\"owner_account_id\" = upper(\"owner_account_id\") AND length(\"owner_account_id\") = 26 AND substr(\"owner_account_id\", 1, 1) GLOB '[0-7]' AND \"owner_account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "app_id": { + "name": "app_id", + "type": "text CHECK (\"app_id\" = upper(\"app_id\") AND length(\"app_id\") = 26 AND substr(\"app_id\", 1, 1) GLOB '[0-7]' AND \"app_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "runtime_state_json": { + "name": "runtime_state_json", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'{}'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status_changed_at": { + "name": "status_changed_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "wechat_channel_account_agent_idx": { + "name": "wechat_channel_account_agent_idx", + "columns": ["agent_id"], + "isUnique": true + }, + "wechat_channel_account_external_idx": { + "name": "wechat_channel_account_external_idx", + "columns": ["external_account_id", "external_bot_id"], + "isUnique": true + }, + "wechat_channel_account_status_idx": { + "name": "wechat_channel_account_status_idx", + "columns": ["status", "updated_at"], + "isUnique": false + }, + "wechat_channel_account_app_status_idx": { + "name": "wechat_channel_account_app_status_idx", + "columns": ["app_id", "status"], + "isUnique": false + } + }, + "foreignKeys": { + "wechat_channel_account_agent_id_agent_id_fk": { + "name": "wechat_channel_account_agent_id_agent_id_fk", + "tableFrom": "wechat_channel_account", + "tableTo": "agent", + "columnsFrom": ["agent_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "wechat_channel_account_encrypted_creds_secret_id_vault_secret_id_fk": { + "name": "wechat_channel_account_encrypted_creds_secret_id_vault_secret_id_fk", + "tableFrom": "wechat_channel_account", + "tableTo": "vault_secret", + "columnsFrom": ["encrypted_creds_secret_id"], + "columnsTo": ["id"], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "wechat_channel_account_owner_account_id_account_id_fk": { + "name": "wechat_channel_account_owner_account_id_account_id_fk", + "tableFrom": "wechat_channel_account", + "tableTo": "account", + "columnsFrom": ["owner_account_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "wechat_channel_account_app_id_app_id_fk": { + "name": "wechat_channel_account_app_id_app_id_fk", + "tableFrom": "wechat_channel_account", + "tableTo": "app", + "columnsFrom": ["app_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "wechat_channel_pairing": { + "name": "wechat_channel_pairing", + "columns": { + "agent_id": { + "name": "agent_id", + "type": "text CHECK (\"agent_id\" = upper(\"agent_id\") AND length(\"agent_id\") = 26 AND substr(\"agent_id\", 1, 1) GLOB '[0-7]' AND \"agent_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "consumed_at": { + "name": "consumed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by_account_id": { + "name": "created_by_account_id", + "type": "text CHECK (\"created_by_account_id\" = upper(\"created_by_account_id\") AND length(\"created_by_account_id\") = 26 AND substr(\"created_by_account_id\", 1, 1) GLOB '[0-7]' AND \"created_by_account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "app_id": { + "name": "app_id", + "type": "text CHECK (\"app_id\" = upper(\"app_id\") AND length(\"app_id\") = 26 AND substr(\"app_id\", 1, 1) GLOB '[0-7]' AND \"app_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "qr_token_hash": { + "name": "qr_token_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "wechat_channel_pairing_qr_token_hash_idx": { + "name": "wechat_channel_pairing_qr_token_hash_idx", + "columns": ["qr_token_hash"], + "isUnique": true + }, + "wechat_channel_pairing_agent_creator_idx": { + "name": "wechat_channel_pairing_agent_creator_idx", + "columns": ["agent_id", "created_by_account_id", "consumed_at"], + "isUnique": false + }, + "wechat_channel_pairing_app_creator_idx": { + "name": "wechat_channel_pairing_app_creator_idx", + "columns": ["app_id", "created_by_account_id", "consumed_at"], + "isUnique": false + }, + "wechat_channel_pairing_expires_idx": { + "name": "wechat_channel_pairing_expires_idx", + "columns": ["expires_at"], + "isUnique": false + } + }, + "foreignKeys": { + "wechat_channel_pairing_agent_id_agent_id_fk": { + "name": "wechat_channel_pairing_agent_id_agent_id_fk", + "tableFrom": "wechat_channel_pairing", + "tableTo": "agent", + "columnsFrom": ["agent_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "wechat_channel_pairing_created_by_account_id_account_id_fk": { + "name": "wechat_channel_pairing_created_by_account_id_account_id_fk", + "tableFrom": "wechat_channel_pairing", + "tableTo": "account", + "columnsFrom": ["created_by_account_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "wechat_channel_pairing_app_id_app_id_fk": { + "name": "wechat_channel_pairing_app_id_app_id_fk", + "tableFrom": "wechat_channel_pairing", + "tableTo": "app", + "columnsFrom": ["app_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "wechat_context_token": { + "name": "wechat_context_token", + "columns": { + "account_id": { + "name": "account_id", + "type": "text CHECK (\"account_id\" = upper(\"account_id\") AND length(\"account_id\") = 26 AND substr(\"account_id\", 1, 1) GLOB '[0-7]' AND \"account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "context_token_key": { + "name": "context_token_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "encrypted_context_token_secret_id": { + "name": "encrypted_context_token_secret_id", + "type": "text CHECK (\"encrypted_context_token_secret_id\" = upper(\"encrypted_context_token_secret_id\") AND length(\"encrypted_context_token_secret_id\") = 26 AND substr(\"encrypted_context_token_secret_id\", 1, 1) GLOB '[0-7]' AND \"encrypted_context_token_secret_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_account_id": { + "name": "external_account_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "peer_id": { + "name": "peer_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "to_user_id": { + "name": "to_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "wechat_context_token_key_idx": { + "name": "wechat_context_token_key_idx", + "columns": ["context_token_key"], + "isUnique": true + }, + "wechat_context_token_account_peer_idx": { + "name": "wechat_context_token_account_peer_idx", + "columns": ["account_id", "external_account_id", "peer_id"], + "isUnique": true + }, + "wechat_context_token_account_updated_idx": { + "name": "wechat_context_token_account_updated_idx", + "columns": ["account_id", "updated_at"], + "isUnique": false + } + }, + "foreignKeys": { + "wechat_context_token_account_id_wechat_channel_account_id_fk": { + "name": "wechat_context_token_account_id_wechat_channel_account_id_fk", + "tableFrom": "wechat_context_token", + "tableTo": "wechat_channel_account", + "columnsFrom": ["account_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "wechat_context_token_encrypted_context_token_secret_id_vault_secret_id_fk": { + "name": "wechat_context_token_encrypted_context_token_secret_id_vault_secret_id_fk", + "tableFrom": "wechat_context_token", + "tableTo": "vault_secret", + "columnsFrom": ["encrypted_context_token_secret_id"], + "columnsTo": ["id"], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "email_log": { + "name": "email_log", + "columns": { + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "recipient_domain": { + "name": "recipient_domain", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "recipient_masked": { + "name": "recipient_masked", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "email_log_created_at_idx": { + "name": "email_log_created_at_idx", + "columns": ["created_at"], + "isUnique": false + }, + "email_log_type_status_idx": { + "name": "email_log_type_status_idx", + "columns": ["type", "status"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "environment_revision": { + "name": "environment_revision", + "columns": { + "allow_mcp_servers": { + "name": "allow_mcp_servers", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "allow_package_managers": { + "name": "allow_package_managers", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "allowed_hosts_json": { + "name": "allowed_hosts_json", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by_account_id": { + "name": "created_by_account_id", + "type": "text CHECK (\"created_by_account_id\" = upper(\"created_by_account_id\") AND length(\"created_by_account_id\") = 26 AND substr(\"created_by_account_id\", 1, 1) GLOB '[0-7]' AND \"created_by_account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "env_vars_json": { + "name": "env_vars_json", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "environment_id": { + "name": "environment_id", + "type": "text CHECK (\"environment_id\" = upper(\"environment_id\") AND length(\"environment_id\") = 26 AND substr(\"environment_id\", 1, 1) GLOB '[0-7]' AND \"environment_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "network_policy": { + "name": "network_policy", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "packages_json": { + "name": "packages_json", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "app_id": { + "name": "app_id", + "type": "text CHECK (\"app_id\" = upper(\"app_id\") AND length(\"app_id\") = 26 AND substr(\"app_id\", 1, 1) GLOB '[0-7]' AND \"app_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "setup_script": { + "name": "setup_script", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "environment_revision_environment_created_at_idx": { + "name": "environment_revision_environment_created_at_idx", + "columns": ["environment_id", "created_at"], + "isUnique": false + }, + "environment_revision_app_created_at_idx": { + "name": "environment_revision_app_created_at_idx", + "columns": ["app_id", "created_at"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "environment_revision_network_policy_check": { + "name": "environment_revision_network_policy_check", + "value": "\"environment_revision\".\"network_policy\" IN ('full', 'limited')" + } + } + }, + "environment": { + "name": "environment", + "columns": { + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "current_revision_id": { + "name": "current_revision_id", + "type": "text CHECK (\"current_revision_id\" = upper(\"current_revision_id\") AND length(\"current_revision_id\") = 26 AND substr(\"current_revision_id\", 1, 1) GLOB '[0-7]' AND \"current_revision_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "forked_from_environment_id": { + "name": "forked_from_environment_id", + "type": "text CHECK (\"forked_from_environment_id\" = upper(\"forked_from_environment_id\") AND length(\"forked_from_environment_id\") = 26 AND substr(\"forked_from_environment_id\", 1, 1) GLOB '[0-7]' AND \"forked_from_environment_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "forked_from_environment_name": { + "name": "forked_from_environment_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "forked_from_owner_name": { + "name": "forked_from_owner_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "owner_account_id": { + "name": "owner_account_id", + "type": "text CHECK (\"owner_account_id\" = upper(\"owner_account_id\") AND length(\"owner_account_id\") = 26 AND substr(\"owner_account_id\", 1, 1) GLOB '[0-7]' AND \"owner_account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "app_id": { + "name": "app_id", + "type": "text CHECK (\"app_id\" = upper(\"app_id\") AND length(\"app_id\") = 26 AND substr(\"app_id\", 1, 1) GLOB '[0-7]' AND \"app_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "environment_app_updated_at_idx": { + "name": "environment_app_updated_at_idx", + "columns": ["app_id", "updated_at"], + "isUnique": false + }, + "environment_owner_updated_at_idx": { + "name": "environment_owner_updated_at_idx", + "columns": ["owner_account_id", "updated_at"], + "isUnique": false + }, + "environment_owner_name_idx": { + "name": "environment_owner_name_idx", + "columns": ["app_id", "owner_account_id", "name"], + "isUnique": true, + "where": "\"environment\".\"owner_account_id\" IS NOT NULL" + }, + "environment_system_default_idx": { + "name": "environment_system_default_idx", + "columns": ["app_id"], + "isUnique": true, + "where": "\"environment\".\"owner_account_id\" IS NULL" + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "file_record": { + "name": "file_record", + "columns": { + "committed": { + "name": "committed", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by_account_id": { + "name": "created_by_account_id", + "type": "text CHECK (\"created_by_account_id\" = upper(\"created_by_account_id\") AND length(\"created_by_account_id\") = 26 AND substr(\"created_by_account_id\", 1, 1) GLOB '[0-7]' AND \"created_by_account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "etag": { + "name": "etag", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "mime_type": { + "name": "mime_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "object_key": { + "name": "object_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "owner_id": { + "name": "owner_id", + "type": "text CHECK (\"owner_id\" = upper(\"owner_id\") AND length(\"owner_id\") = 26 AND substr(\"owner_id\", 1, 1) GLOB '[0-7]' AND \"owner_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "owner_kind": { + "name": "owner_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "parent_path": { + "name": "parent_path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "purpose": { + "name": "purpose", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "scope_id": { + "name": "scope_id", + "type": "text CHECK (\"scope_id\" = upper(\"scope_id\") AND length(\"scope_id\") = 26 AND substr(\"scope_id\", 1, 1) GLOB '[0-7]' AND \"scope_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scope_kind": { + "name": "scope_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_kind": { + "name": "session_kind", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "file_record_object_key_idx": { + "name": "file_record_object_key_idx", + "columns": ["object_key"], + "isUnique": true + }, + "file_record_unscoped_parent_path_name_status_idx": { + "name": "file_record_unscoped_parent_path_name_status_idx", + "columns": ["scope_kind", "parent_path", "name", "status"], + "isUnique": true, + "where": "\"file_record\".\"scope_id\" IS NULL" + }, + "file_record_scoped_parent_path_name_status_idx": { + "name": "file_record_scoped_parent_path_name_status_idx", + "columns": ["scope_kind", "scope_id", "parent_path", "name", "status"], + "isUnique": true + }, + "file_record_unscoped_pending_path_idx": { + "name": "file_record_unscoped_pending_path_idx", + "columns": ["scope_kind", "path"], + "isUnique": true, + "where": "\"file_record\".\"status\" = 'pending' AND \"file_record\".\"scope_id\" IS NULL" + }, + "file_record_scoped_pending_path_idx": { + "name": "file_record_scoped_pending_path_idx", + "columns": ["scope_kind", "scope_id", "path"], + "isUnique": true, + "where": "\"file_record\".\"status\" = 'pending' AND \"file_record\".\"scope_id\" IS NOT NULL" + }, + "file_record_unscoped_ready_path_idx": { + "name": "file_record_unscoped_ready_path_idx", + "columns": ["scope_kind", "path"], + "isUnique": true, + "where": "\"file_record\".\"status\" = 'ready' AND \"file_record\".\"scope_id\" IS NULL" + }, + "file_record_scoped_ready_path_idx": { + "name": "file_record_scoped_ready_path_idx", + "columns": ["scope_kind", "scope_id", "path"], + "isUnique": true, + "where": "\"file_record\".\"status\" = 'ready' AND \"file_record\".\"scope_id\" IS NOT NULL" + }, + "file_record_governance_idx": { + "name": "file_record_governance_idx", + "columns": ["purpose", "owner_kind", "owner_id", "status", "expires_at"], + "isUnique": false + }, + "file_record_listing_idx": { + "name": "file_record_listing_idx", + "columns": ["scope_kind", "scope_id", "parent_path", "status", "lower(\"name\")"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "file_upload": { + "name": "file_upload", + "columns": { + "content_type": { + "name": "content_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by_account_id": { + "name": "created_by_account_id", + "type": "text CHECK (\"created_by_account_id\" = upper(\"created_by_account_id\") AND length(\"created_by_account_id\") = 26 AND substr(\"created_by_account_id\", 1, 1) GLOB '[0-7]' AND \"created_by_account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expected_size": { + "name": "expected_size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "file_id": { + "name": "file_id", + "type": "text CHECK (\"file_id\" = upper(\"file_id\") AND length(\"file_id\") = 26 AND substr(\"file_id\", 1, 1) GLOB '[0-7]' AND \"file_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "if_match_etag": { + "name": "if_match_etag", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "multipart_upload_id": { + "name": "multipart_upload_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "overwrite": { + "name": "overwrite", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "part_size": { + "name": "part_size", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scope_id": { + "name": "scope_id", + "type": "text CHECK (\"scope_id\" = upper(\"scope_id\") AND length(\"scope_id\") = 26 AND substr(\"scope_id\", 1, 1) GLOB '[0-7]' AND \"scope_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scope_kind": { + "name": "scope_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "strategy": { + "name": "strategy", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "file_upload_file_id_idx": { + "name": "file_upload_file_id_idx", + "columns": ["file_id"], + "isUnique": true + }, + "file_upload_status_expires_idx": { + "name": "file_upload_status_expires_idx", + "columns": ["status", "expires_at"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "file_version": { + "name": "file_version", + "columns": { + "committed": { + "name": "committed", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "committed_at": { + "name": "committed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by_account_id": { + "name": "created_by_account_id", + "type": "text CHECK (\"created_by_account_id\" = upper(\"created_by_account_id\") AND length(\"created_by_account_id\") = 26 AND substr(\"created_by_account_id\", 1, 1) GLOB '[0-7]' AND \"created_by_account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "file_id": { + "name": "file_id", + "type": "text CHECK (\"file_id\" = upper(\"file_id\") AND length(\"file_id\") = 26 AND substr(\"file_id\", 1, 1) GLOB '[0-7]' AND \"file_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "mime_type": { + "name": "mime_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "object_key": { + "name": "object_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "scope_id": { + "name": "scope_id", + "type": "text CHECK (\"scope_id\" = upper(\"scope_id\") AND length(\"scope_id\") = 26 AND substr(\"scope_id\", 1, 1) GLOB '[0-7]' AND \"scope_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scope_kind": { + "name": "scope_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source_etag": { + "name": "source_etag", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source_object_key": { + "name": "source_object_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "file_version_object_key_idx": { + "name": "file_version_object_key_idx", + "columns": ["object_key"], + "isUnique": true + }, + "file_version_scope_path_created_idx": { + "name": "file_version_scope_path_created_idx", + "columns": ["scope_kind", "scope_id", "path", "created_at"], + "isUnique": false + }, + "file_version_file_created_idx": { + "name": "file_version_file_created_idx", + "columns": ["file_id", "created_at"], + "isUnique": false + }, + "file_version_pending_idx": { + "name": "file_version_pending_idx", + "columns": ["committed", "created_at"], + "isUnique": false, + "where": "\"file_version\".\"committed\" = 0" + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "mcp_credential": { + "name": "mcp_credential", + "columns": { + "account_id": { + "name": "account_id", + "type": "text CHECK (\"account_id\" = upper(\"account_id\") AND length(\"account_id\") = 26 AND substr(\"account_id\", 1, 1) GLOB '[0-7]' AND \"account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text CHECK (\"agent_id\" = upper(\"agent_id\") AND length(\"agent_id\") = 26 AND substr(\"agent_id\", 1, 1) GLOB '[0-7]' AND \"agent_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "auth_type": { + "name": "auth_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "last_refreshed_at": { + "name": "last_refreshed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "oauth_client_id": { + "name": "oauth_client_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "oauth_client_secret_secret_id": { + "name": "oauth_client_secret_secret_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "app_id": { + "name": "app_id", + "type": "text CHECK (\"app_id\" = upper(\"app_id\") AND length(\"app_id\") = 26 AND substr(\"app_id\", 1, 1) GLOB '[0-7]' AND \"app_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "refresh_secret_id": { + "name": "refresh_secret_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "scope_values_json": { + "name": "scope_values_json", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "secret_id": { + "name": "secret_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "server_id": { + "name": "server_id", + "type": "text CHECK (\"server_id\" = upper(\"server_id\") AND length(\"server_id\") = 26 AND substr(\"server_id\", 1, 1) GLOB '[0-7]' AND \"server_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "subject_label": { + "name": "subject_label", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "mcp_credential_server_scope_status_idx": { + "name": "mcp_credential_server_scope_status_idx", + "columns": ["server_id", "scope", "status"], + "isUnique": false + }, + "mcp_credential_app_scope_status_idx": { + "name": "mcp_credential_app_scope_status_idx", + "columns": ["app_id", "scope", "status"], + "isUnique": false + }, + "mcp_credential_app_scope_idx": { + "name": "mcp_credential_app_scope_idx", + "columns": ["server_id", "scope"], + "isUnique": true, + "where": "\"mcp_credential\".\"scope\" = 'app'" + }, + "mcp_credential_agent_scope_idx": { + "name": "mcp_credential_agent_scope_idx", + "columns": ["server_id", "agent_id", "scope"], + "isUnique": true, + "where": "\"mcp_credential\".\"scope\" = 'agent' AND \"mcp_credential\".\"agent_id\" IS NOT NULL" + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "mcp_credential_scope_shape_check": { + "name": "mcp_credential_scope_shape_check", + "value": "\n (\"mcp_credential\".\"scope\" = 'app' AND \"mcp_credential\".\"account_id\" IS NULL AND \"mcp_credential\".\"agent_id\" IS NULL)\n OR (\"mcp_credential\".\"scope\" = 'agent' AND \"mcp_credential\".\"account_id\" IS NULL AND \"mcp_credential\".\"agent_id\" IS NOT NULL)\n " + }, + "mcp_credential_scope_values_json_check": { + "name": "mcp_credential_scope_values_json_check", + "value": "\n \"mcp_credential\".\"scope_values_json\" IS NULL\n OR (json_valid(\"mcp_credential\".\"scope_values_json\") AND json_type(\"mcp_credential\".\"scope_values_json\") = 'array')\n " + }, + "mcp_credential_bearer_shape_check": { + "name": "mcp_credential_bearer_shape_check", + "value": "\n \"mcp_credential\".\"auth_type\" != 'bearer'\n OR (\n \"mcp_credential\".\"oauth_client_id\" IS NULL\n AND \"mcp_credential\".\"oauth_client_secret_secret_id\" IS NULL\n AND \"mcp_credential\".\"refresh_secret_id\" IS NULL\n )\n " + } + } + }, + "mcp_oauth_flow": { + "name": "mcp_oauth_flow", + "columns": { + "authorization_endpoint": { + "name": "authorization_endpoint", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "cleanup_after": { + "name": "cleanup_after", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "code_verifier": { + "name": "code_verifier", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "completed_at": { + "name": "completed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "initiator_account_id": { + "name": "initiator_account_id", + "type": "text CHECK (\"initiator_account_id\" = upper(\"initiator_account_id\") AND length(\"initiator_account_id\") = 26 AND substr(\"initiator_account_id\", 1, 1) GLOB '[0-7]' AND \"initiator_account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "oauth_client_id": { + "name": "oauth_client_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "oauth_client_secret_secret_id": { + "name": "oauth_client_secret_secret_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "app_id": { + "name": "app_id", + "type": "text CHECK (\"app_id\" = upper(\"app_id\") AND length(\"app_id\") = 26 AND substr(\"app_id\", 1, 1) GLOB '[0-7]' AND \"app_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "registration_endpoint": { + "name": "registration_endpoint", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "return_url": { + "name": "return_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scope_values_json": { + "name": "scope_values_json", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "server_id": { + "name": "server_id", + "type": "text CHECK (\"server_id\" = upper(\"server_id\") AND length(\"server_id\") = 26 AND substr(\"server_id\", 1, 1) GLOB '[0-7]' AND \"server_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "subject_label": { + "name": "subject_label", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "token_endpoint": { + "name": "token_endpoint", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "mcp_oauth_flow_status_cleanup_after_idx": { + "name": "mcp_oauth_flow_status_cleanup_after_idx", + "columns": ["status", "cleanup_after"], + "isUnique": false + }, + "mcp_oauth_flow_expires_at_idx": { + "name": "mcp_oauth_flow_expires_at_idx", + "columns": ["expires_at"], + "isUnique": false + }, + "mcp_oauth_flow_server_account_idx": { + "name": "mcp_oauth_flow_server_account_idx", + "columns": ["server_id", "initiator_account_id"], + "isUnique": false + }, + "mcp_oauth_flow_app_server_account_idx": { + "name": "mcp_oauth_flow_app_server_account_idx", + "columns": ["app_id", "server_id", "initiator_account_id"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "mcp_oauth_flow_scope_values_json_check": { + "name": "mcp_oauth_flow_scope_values_json_check", + "value": "\n \"mcp_oauth_flow\".\"scope_values_json\" IS NULL\n OR (json_valid(\"mcp_oauth_flow\".\"scope_values_json\") AND json_type(\"mcp_oauth_flow\".\"scope_values_json\") = 'array')\n " + } + } + }, + "mcp_server": { + "name": "mcp_server", + "columns": { + "auth_type": { + "name": "auth_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "byo_client_id": { + "name": "byo_client_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "byo_client_secret_secret_id": { + "name": "byo_client_secret_secret_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_scope": { + "name": "credential_scope", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "icon_url": { + "name": "icon_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "oauth_metadata_json": { + "name": "oauth_metadata_json", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "owner_account_id": { + "name": "owner_account_id", + "type": "text CHECK (\"owner_account_id\" = upper(\"owner_account_id\") AND length(\"owner_account_id\") = 26 AND substr(\"owner_account_id\", 1, 1) GLOB '[0-7]' AND \"owner_account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "app_id": { + "name": "app_id", + "type": "text CHECK (\"app_id\" = upper(\"app_id\") AND length(\"app_id\") = 26 AND substr(\"app_id\", 1, 1) GLOB '[0-7]' AND \"app_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "mcp_server_app_enabled_idx": { + "name": "mcp_server_app_enabled_idx", + "columns": ["app_id", "enabled"], + "isUnique": false + }, + "mcp_server_owner_app_idx": { + "name": "mcp_server_owner_app_idx", + "columns": ["owner_account_id", "app_id"], + "isUnique": false + }, + "mcp_server_app_url_idx": { + "name": "mcp_server_app_url_idx", + "columns": ["app_id", "url"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "mcp_server_source_scope_check": { + "name": "mcp_server_source_scope_check", + "value": "\"mcp_server\".\"source\" = 'app' AND \"mcp_server\".\"credential_scope\" = 'app'" + } + } + }, + "vault_secret": { + "name": "vault_secret", + "columns": { + "algorithm": { + "name": "algorithm", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'AES-GCM'" + }, + "ciphertext": { + "name": "ciphertext", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ciphertext_iv": { + "name": "ciphertext_iv", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "wrapped_dek": { + "name": "wrapped_dek", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "wrapped_dek_iv": { + "name": "wrapped_dek_iv", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "vault_secret_kind_created_at_idx": { + "name": "vault_secret_kind_created_at_idx", + "columns": ["kind", "created_at"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "organization": { + "name": "organization", + "columns": { + "avatar_url": { + "name": "avatar_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "creator_account_id": { + "name": "creator_account_id", + "type": "text CHECK (\"creator_account_id\" = upper(\"creator_account_id\") AND length(\"creator_account_id\") = 26 AND substr(\"creator_account_id\", 1, 1) GLOB '[0-7]' AND \"creator_account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "organization_creator_account_idx": { + "name": "organization_creator_account_idx", + "columns": ["creator_account_id"], + "isUnique": true, + "where": "\"organization\".\"creator_account_id\" IS NOT NULL" + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "app_deployment_run": { + "name": "app_deployment_run", + "columns": { + "app_id": { + "name": "app_id", + "type": "text CHECK (\"app_id\" = upper(\"app_id\") AND length(\"app_id\") = 26 AND substr(\"app_id\", 1, 1) GLOB '[0-7]' AND \"app_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "deployment_id": { + "name": "deployment_id", + "type": "text CHECK (\"deployment_id\" = upper(\"deployment_id\") AND length(\"deployment_id\") = 26 AND substr(\"deployment_id\", 1, 1) GLOB '[0-7]' AND \"deployment_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "error_code": { + "name": "error_code", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "external_deployment_id": { + "name": "external_deployment_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "external_project_id": { + "name": "external_project_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "external_version_id": { + "name": "external_version_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "generated_wrangler_config_json": { + "name": "generated_wrangler_config_json", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "mosoo_config_json": { + "name": "mosoo_config_json", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "plan_json": { + "name": "plan_json", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source_branch": { + "name": "source_branch", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source_commit_sha": { + "name": "source_commit_sha", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_kind": { + "name": "target_kind", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_project_name": { + "name": "target_project_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_script_name": { + "name": "target_script_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "app_deployment_run_app_id_idx": { + "name": "app_deployment_run_app_id_idx", + "columns": ["app_id", "id"], + "isUnique": false + }, + "app_deployment_run_deployment_id_idx": { + "name": "app_deployment_run_deployment_id_idx", + "columns": ["deployment_id", "id"], + "isUnique": false + }, + "app_deployment_run_active_app_idx": { + "name": "app_deployment_run_active_app_idx", + "columns": ["app_id"], + "isUnique": true, + "where": "\"app_deployment_run\".\"status\" IN ('queued', 'preparing', 'building', 'submitting', 'submitted', 'activating')" + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "app_deployment_run_status_check": { + "name": "app_deployment_run_status_check", + "value": "\"app_deployment_run\".\"status\" IN ('queued', 'preparing', 'building', 'submitting', 'submitted', 'activating', 'success', 'failed')" + }, + "app_deployment_run_target_kind_check": { + "name": "app_deployment_run_target_kind_check", + "value": "\"app_deployment_run\".\"target_kind\" IS NULL OR \"app_deployment_run\".\"target_kind\" IN ('cloudflare_pages', 'cloudflare_worker')" + } + } + }, + "app_deployment": { + "name": "app_deployment", + "columns": { + "app_id": { + "name": "app_id", + "type": "text CHECK (\"app_id\" = upper(\"app_id\") AND length(\"app_id\") = 26 AND substr(\"app_id\", 1, 1) GLOB '[0-7]' AND \"app_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "default_branch": { + "name": "default_branch", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "last_successful_url": { + "name": "last_successful_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "latest_run_id": { + "name": "latest_run_id", + "type": "text CHECK (\"latest_run_id\" = upper(\"latest_run_id\") AND length(\"latest_run_id\") = 26 AND substr(\"latest_run_id\", 1, 1) GLOB '[0-7]' AND \"latest_run_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "mosoo_subdomain": { + "name": "mosoo_subdomain", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "owner_account_id": { + "name": "owner_account_id", + "type": "text CHECK (\"owner_account_id\" = upper(\"owner_account_id\") AND length(\"owner_account_id\") = 26 AND substr(\"owner_account_id\", 1, 1) GLOB '[0-7]' AND \"owner_account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "repo_name": { + "name": "repo_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "repo_owner": { + "name": "repo_owner", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "repo_url": { + "name": "repo_url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source_kind": { + "name": "source_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "app_deployment_active_app_idx": { + "name": "app_deployment_active_app_idx", + "columns": ["app_id"], + "isUnique": true, + "where": "\"app_deployment\".\"deleted_at\" IS NULL" + }, + "app_deployment_active_subdomain_idx": { + "name": "app_deployment_active_subdomain_idx", + "columns": ["mosoo_subdomain"], + "isUnique": true, + "where": "\"app_deployment\".\"deleted_at\" IS NULL" + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "app_deployment_source_kind_check": { + "name": "app_deployment_source_kind_check", + "value": "\"app_deployment\".\"source_kind\" IN ('github_public')" + } + } + }, + "app": { + "name": "app", + "columns": { + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "default_environment_id": { + "name": "default_environment_id", + "type": "text CHECK (\"default_environment_id\" = upper(\"default_environment_id\") AND length(\"default_environment_id\") = 26 AND substr(\"default_environment_id\", 1, 1) GLOB '[0-7]' AND \"default_environment_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "text CHECK (\"organization_id\" = upper(\"organization_id\") AND length(\"organization_id\") = 26 AND substr(\"organization_id\", 1, 1) GLOB '[0-7]' AND \"organization_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "owner_account_id": { + "name": "owner_account_id", + "type": "text CHECK (\"owner_account_id\" = upper(\"owner_account_id\") AND length(\"owner_account_id\") = 26 AND substr(\"owner_account_id\", 1, 1) GLOB '[0-7]' AND \"owner_account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "bound_agent_call_idempotency_key": { + "name": "bound_agent_call_idempotency_key", + "columns": { + "body_hash": { + "name": "body_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "run_id": { + "name": "run_id", + "type": "text CHECK (\"run_id\" = upper(\"run_id\") AND length(\"run_id\") = 26 AND substr(\"run_id\", 1, 1) GLOB '[0-7]' AND \"run_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text CHECK (\"session_id\" = upper(\"session_id\") AND length(\"session_id\") = 26 AND substr(\"session_id\", 1, 1) GLOB '[0-7]' AND \"session_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "subject_hash": { + "name": "subject_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "bound_agent_call_idempotency_subject_key_idx": { + "name": "bound_agent_call_idempotency_subject_key_idx", + "columns": ["subject_hash", "idempotency_key"], + "isUnique": true + }, + "bound_agent_call_idempotency_updated_idx": { + "name": "bound_agent_call_idempotency_updated_idx", + "columns": ["updated_at"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public_api_idempotency_key": { + "name": "public_api_idempotency_key", + "columns": { + "body_hash": { + "name": "body_hash", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "response_json": { + "name": "response_json", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "response_status": { + "name": "response_status", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "route": { + "name": "route", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_id": { + "name": "token_id", + "type": "text CHECK (\"token_id\" = upper(\"token_id\") AND length(\"token_id\") = 26 AND substr(\"token_id\", 1, 1) GLOB '[0-7]' AND \"token_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "public_api_idempotency_token_key_idx": { + "name": "public_api_idempotency_token_key_idx", + "columns": ["token_id", "idempotency_key"], + "isUnique": true + }, + "public_api_idempotency_updated_idx": { + "name": "public_api_idempotency_updated_idx", + "columns": ["updated_at"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public_api_rate_limit_window": { + "name": "public_api_rate_limit_window", + "columns": { + "bucket_key": { + "name": "bucket_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "request_count": { + "name": "request_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "shard": { + "name": "shard", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "window_start": { + "name": "window_start", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "public_api_rate_limit_window_updated_idx": { + "name": "public_api_rate_limit_window_updated_idx", + "columns": ["updated_at"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "public_api_rate_limit_window_bucket_key_window_start_shard_pk": { + "columns": ["bucket_key", "window_start", "shard"], + "name": "public_api_rate_limit_window_bucket_key_window_start_shard_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "driver_command": { + "name": "driver_command", + "columns": { + "acked_at": { + "name": "acked_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "completed_at": { + "name": "completed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "delivery_connection_id": { + "name": "delivery_connection_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "driver_instance_id": { + "name": "driver_instance_id", + "type": "text CHECK (\"driver_instance_id\" = upper(\"driver_instance_id\") AND length(\"driver_instance_id\") = 26 AND substr(\"driver_instance_id\", 1, 1) GLOB '[0-7]' AND \"driver_instance_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "error_json": { + "name": "error_json", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "issued_at": { + "name": "issued_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "payload_json": { + "name": "payload_json", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "result_json": { + "name": "result_json", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "seq": { + "name": "seq", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "driver_command_instance_seq_idx": { + "name": "driver_command_instance_seq_idx", + "columns": ["driver_instance_id", "seq"], + "isUnique": true + }, + "driver_command_instance_status_idx": { + "name": "driver_command_instance_status_idx", + "columns": ["driver_instance_id", "status", "expires_at"], + "isUnique": false + } + }, + "foreignKeys": { + "driver_command_driver_instance_id_driver_instance_id_fk": { + "name": "driver_command_driver_instance_id_driver_instance_id_fk", + "tableFrom": "driver_command", + "tableTo": "driver_instance", + "columnsFrom": ["driver_instance_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "driver_instance_mcp_grant": { + "name": "driver_instance_mcp_grant", + "columns": { + "auth_type": { + "name": "auth_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "authorization_state": { + "name": "authorization_state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "can_invalidate": { + "name": "can_invalidate", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "can_refresh": { + "name": "can_refresh", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_id": { + "name": "credential_id", + "type": "text CHECK (\"credential_id\" = upper(\"credential_id\") AND length(\"credential_id\") = 26 AND substr(\"credential_id\", 1, 1) GLOB '[0-7]' AND \"credential_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "driver_instance_id": { + "name": "driver_instance_id", + "type": "text CHECK (\"driver_instance_id\" = upper(\"driver_instance_id\") AND length(\"driver_instance_id\") = 26 AND substr(\"driver_instance_id\", 1, 1) GLOB '[0-7]' AND \"driver_instance_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "app_id": { + "name": "app_id", + "type": "text CHECK (\"app_id\" = upper(\"app_id\") AND length(\"app_id\") = 26 AND substr(\"app_id\", 1, 1) GLOB '[0-7]' AND \"app_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "server_id": { + "name": "server_id", + "type": "text CHECK (\"server_id\" = upper(\"server_id\") AND length(\"server_id\") = 26 AND substr(\"server_id\", 1, 1) GLOB '[0-7]' AND \"server_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "driver_instance_mcp_grant_instance_server_idx": { + "name": "driver_instance_mcp_grant_instance_server_idx", + "columns": ["driver_instance_id", "server_id"], + "isUnique": true + }, + "driver_instance_mcp_grant_instance_credential_idx": { + "name": "driver_instance_mcp_grant_instance_credential_idx", + "columns": ["driver_instance_id", "credential_id"], + "isUnique": false + } + }, + "foreignKeys": { + "driver_instance_mcp_grant_driver_instance_id_driver_instance_id_fk": { + "name": "driver_instance_mcp_grant_driver_instance_id_driver_instance_id_fk", + "tableFrom": "driver_instance_mcp_grant", + "tableTo": "driver_instance", + "columnsFrom": ["driver_instance_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "driver_instance": { + "name": "driver_instance", + "columns": { + "boot_token_expires_at": { + "name": "boot_token_expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "boot_token_hash": { + "name": "boot_token_hash", + "type": "blob", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "boot_token_used_at": { + "name": "boot_token_used_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "close_code": { + "name": "close_code", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "close_reason": { + "name": "close_reason", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "connection_id": { + "name": "connection_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "command_seq_cursor": { + "name": "command_seq_cursor", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "driver_pid": { + "name": "driver_pid", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "driver_started_at": { + "name": "driver_started_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "driver_version": { + "name": "driver_version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "heartbeat_count": { + "name": "heartbeat_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "generation": { + "name": "generation", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "last_heartbeat_at": { + "name": "last_heartbeat_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "process_id": { + "name": "process_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "protocol": { + "name": "protocol", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "protocol_version": { + "name": "protocol_version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "restart_count": { + "name": "restart_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "runtime": { + "name": "runtime", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sandbox_id": { + "name": "sandbox_id", + "type": "text CHECK (\"sandbox_id\" = upper(\"sandbox_id\") AND length(\"sandbox_id\") = 26 AND substr(\"sandbox_id\", 1, 1) GLOB '[0-7]' AND \"sandbox_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sandbox_session_id": { + "name": "sandbox_session_id", + "type": "text CHECK (\"sandbox_session_id\" = upper(\"sandbox_session_id\") AND length(\"sandbox_session_id\") = 26 AND substr(\"sandbox_session_id\", 1, 1) GLOB '[0-7]' AND \"sandbox_session_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status_changed_at": { + "name": "status_changed_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "status_event": { + "name": "status_event", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'driver.provision'" + }, + "status_operation_id": { + "name": "status_operation_id", + "type": "text CHECK (\"status_operation_id\" = upper(\"status_operation_id\") AND length(\"status_operation_id\") = 26 AND substr(\"status_operation_id\", 1, 1) GLOB '[0-7]' AND \"status_operation_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status_seq": { + "name": "status_seq", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "status_source": { + "name": "status_source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'system'" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "driver_instance_completed_idx": { + "name": "driver_instance_completed_idx", + "columns": ["expires_at", "status"], + "isUnique": false + }, + "driver_instance_connection_idx": { + "name": "driver_instance_connection_idx", + "columns": ["connection_id"], + "isUnique": true, + "where": "\"driver_instance\".\"connection_id\" IS NOT NULL" + }, + "driver_instance_boot_token_expiry_idx": { + "name": "driver_instance_boot_token_expiry_idx", + "columns": ["status", "boot_token_expires_at"], + "isUnique": false, + "where": "\"driver_instance\".\"boot_token_used_at\" IS NULL" + }, + "driver_instance_boot_token_hash_idx": { + "name": "driver_instance_boot_token_hash_idx", + "columns": ["boot_token_hash"], + "isUnique": true + }, + "driver_instance_sandbox_session_idx": { + "name": "driver_instance_sandbox_session_idx", + "columns": ["sandbox_id", "sandbox_session_id", "status", "updated_at"], + "isUnique": false + }, + "driver_instance_live_sandbox_session_idx": { + "name": "driver_instance_live_sandbox_session_idx", + "columns": ["sandbox_id", "sandbox_session_id"], + "isUnique": true, + "where": "\"driver_instance\".\"status\" IN ('provisioning', 'connecting', 'ready', 'stopping')" + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "driver_instance_status_check": { + "name": "driver_instance_status_check", + "value": "\"driver_instance\".\"status\" IN ('provisioning', 'connecting', 'ready', 'stopping', 'stopped', 'failed')" + }, + "driver_instance_status_seq_check": { + "name": "driver_instance_status_seq_check", + "value": "\"driver_instance\".\"status_seq\" >= 0" + } + } + }, + "external_tool_effect_attempt": { + "name": "external_tool_effect_attempt", + "columns": { + "attempt": { + "name": "attempt", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "completed_at": { + "name": "completed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "effect_id": { + "name": "effect_id", + "type": "text CHECK (\"effect_id\" = upper(\"effect_id\") AND length(\"effect_id\") = 26 AND substr(\"effect_id\", 1, 1) GLOB '[0-7]' AND \"effect_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider_receipt_json": { + "name": "provider_receipt_json", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "result_json": { + "name": "result_json", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "external_tool_effect_attempt_status_idx": { + "name": "external_tool_effect_attempt_status_idx", + "columns": ["status", "created_at"], + "isUnique": false + } + }, + "foreignKeys": { + "external_tool_effect_attempt_effect_id_external_tool_effect_id_fk": { + "name": "external_tool_effect_attempt_effect_id_external_tool_effect_id_fk", + "tableFrom": "external_tool_effect_attempt", + "tableTo": "external_tool_effect", + "columnsFrom": ["effect_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "external_tool_effect_attempt_effect_id_attempt_pk": { + "columns": ["effect_id", "attempt"], + "name": "external_tool_effect_attempt_effect_id_attempt_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": { + "external_tool_effect_attempt_status_check": { + "name": "external_tool_effect_attempt_status_check", + "value": "\"external_tool_effect_attempt\".\"status\" IN ('executing', 'succeeded', 'unknown')" + } + } + }, + "external_tool_effect": { + "name": "external_tool_effect", + "columns": { + "attempt_count": { + "name": "attempt_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "command_id": { + "name": "command_id", + "type": "text CHECK (\"command_id\" = upper(\"command_id\") AND length(\"command_id\") = 26 AND substr(\"command_id\", 1, 1) GLOB '[0-7]' AND \"command_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "driver_instance_id": { + "name": "driver_instance_id", + "type": "text CHECK (\"driver_instance_id\" = upper(\"driver_instance_id\") AND length(\"driver_instance_id\") = 26 AND substr(\"driver_instance_id\", 1, 1) GLOB '[0-7]' AND \"driver_instance_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider_receipt_json": { + "name": "provider_receipt_json", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "result_json": { + "name": "result_json", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "server_id": { + "name": "server_id", + "type": "text CHECK (\"server_id\" = upper(\"server_id\") AND length(\"server_id\") = 26 AND substr(\"server_id\", 1, 1) GLOB '[0-7]' AND \"server_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_run_id": { + "name": "session_run_id", + "type": "text CHECK (\"session_run_id\" = upper(\"session_run_id\") AND length(\"session_run_id\") = 26 AND substr(\"session_run_id\", 1, 1) GLOB '[0-7]' AND \"session_run_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tool_name": { + "name": "tool_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "external_tool_effect_command_idx": { + "name": "external_tool_effect_command_idx", + "columns": ["command_id"], + "isUnique": true + }, + "external_tool_effect_idempotency_key_idx": { + "name": "external_tool_effect_idempotency_key_idx", + "columns": ["idempotency_key"], + "isUnique": true + }, + "external_tool_effect_run_status_idx": { + "name": "external_tool_effect_run_status_idx", + "columns": ["session_run_id", "status", "id"], + "isUnique": false + }, + "external_tool_effect_driver_status_idx": { + "name": "external_tool_effect_driver_status_idx", + "columns": ["driver_instance_id", "status"], + "isUnique": false + } + }, + "foreignKeys": { + "external_tool_effect_command_id_driver_command_id_fk": { + "name": "external_tool_effect_command_id_driver_command_id_fk", + "tableFrom": "external_tool_effect", + "tableTo": "driver_command", + "columnsFrom": ["command_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "external_tool_effect_driver_instance_id_driver_instance_id_fk": { + "name": "external_tool_effect_driver_instance_id_driver_instance_id_fk", + "tableFrom": "external_tool_effect", + "tableTo": "driver_instance", + "columnsFrom": ["driver_instance_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "external_tool_effect_session_run_id_session_run_id_fk": { + "name": "external_tool_effect_session_run_id_session_run_id_fk", + "tableFrom": "external_tool_effect", + "tableTo": "session_run", + "columnsFrom": ["session_run_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "external_tool_effect_status_check": { + "name": "external_tool_effect_status_check", + "value": "\"external_tool_effect\".\"status\" IN ('intent', 'executing', 'succeeded', 'unknown')" + } + } + }, + "native_resume_ref": { + "name": "native_resume_ref", + "columns": { + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "observed_driver_instance_id": { + "name": "observed_driver_instance_id", + "type": "text CHECK (\"observed_driver_instance_id\" = upper(\"observed_driver_instance_id\") AND length(\"observed_driver_instance_id\") = 26 AND substr(\"observed_driver_instance_id\", 1, 1) GLOB '[0-7]' AND \"observed_driver_instance_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "observed_session_run_id": { + "name": "observed_session_run_id", + "type": "text CHECK (\"observed_session_run_id\" = upper(\"observed_session_run_id\") AND length(\"observed_session_run_id\") = 26 AND substr(\"observed_session_run_id\", 1, 1) GLOB '[0-7]' AND \"observed_session_run_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "runtime_id": { + "name": "runtime_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text CHECK (\"session_id\" = upper(\"session_id\") AND length(\"session_id\") = 26 AND substr(\"session_id\", 1, 1) GLOB '[0-7]' AND \"session_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "native_resume_ref_runtime_updated_idx": { + "name": "native_resume_ref_runtime_updated_idx", + "columns": ["runtime_id", "updated_at"], + "isUnique": false + } + }, + "foreignKeys": { + "native_resume_ref_session_id_session_id_fk": { + "name": "native_resume_ref_session_id_session_id_fk", + "tableFrom": "native_resume_ref", + "tableTo": "session", + "columnsFrom": ["session_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sandbox_backup": { + "name": "sandbox_backup", + "columns": { + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "dir": { + "name": "dir", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "keep": { + "name": "keep", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "sandbox_id": { + "name": "sandbox_id", + "type": "text CHECK (\"sandbox_id\" = upper(\"sandbox_id\") AND length(\"sandbox_id\") = 26 AND substr(\"sandbox_id\", 1, 1) GLOB '[0-7]' AND \"sandbox_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ttl_seconds": { + "name": "ttl_seconds", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "sandbox_backup_sandbox_status_created_idx": { + "name": "sandbox_backup_sandbox_status_created_idx", + "columns": ["sandbox_id", "status", "created_at"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sandbox_session": { + "name": "sandbox_session", + "columns": { + "cloudflare_session_id": { + "name": "cloudflare_session_id", + "type": "text CHECK (\"cloudflare_session_id\" = upper(\"cloudflare_session_id\") AND length(\"cloudflare_session_id\") = 26 AND substr(\"cloudflare_session_id\", 1, 1) GLOB '[0-7]' AND \"cloudflare_session_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "cwd": { + "name": "cwd", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "origin_json": { + "name": "origin_json", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sandbox_id": { + "name": "sandbox_id", + "type": "text CHECK (\"sandbox_id\" = upper(\"sandbox_id\") AND length(\"sandbox_id\") = 26 AND substr(\"sandbox_id\", 1, 1) GLOB '[0-7]' AND \"sandbox_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text CHECK (\"session_id\" = upper(\"session_id\") AND length(\"session_id\") = 26 AND substr(\"session_id\", 1, 1) GLOB '[0-7]' AND \"session_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "sandbox_session_sandbox_status_idx": { + "name": "sandbox_session_sandbox_status_idx", + "columns": ["sandbox_id", "status", "updated_at"], + "isUnique": false + }, + "sandbox_session_cloudflare_session_idx": { + "name": "sandbox_session_cloudflare_session_idx", + "columns": ["cloudflare_session_id"], + "isUnique": true + } + }, + "foreignKeys": { + "sandbox_session_session_id_session_id_fk": { + "name": "sandbox_session_session_id_session_id_fk", + "tableFrom": "sandbox_session", + "tableTo": "session", + "columnsFrom": ["session_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sandbox": { + "name": "sandbox", + "columns": { + "bind_mount_ready": { + "name": "bind_mount_ready", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "claim_expires_at": { + "name": "claim_expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "claim_owner": { + "name": "claim_owner", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "global_mounts_json": { + "name": "global_mounts_json", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "inactive_deadline_at": { + "name": "inactive_deadline_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_backup_id": { + "name": "last_backup_id", + "type": "text CHECK (\"last_backup_id\" = upper(\"last_backup_id\") AND length(\"last_backup_id\") = 26 AND substr(\"last_backup_id\", 1, 1) GLOB '[0-7]' AND \"last_backup_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_error_code": { + "name": "last_error_code", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_restore_backup_id": { + "name": "last_restore_backup_id", + "type": "text CHECK (\"last_restore_backup_id\" = upper(\"last_restore_backup_id\") AND length(\"last_restore_backup_id\") = 26 AND substr(\"last_restore_backup_id\", 1, 1) GLOB '[0-7]' AND \"last_restore_backup_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status_changed_at": { + "name": "status_changed_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "status_event": { + "name": "status_event", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'runtime_subject.cold'" + }, + "status_operation_id": { + "name": "status_operation_id", + "type": "text CHECK (\"status_operation_id\" = upper(\"status_operation_id\") AND length(\"status_operation_id\") = 26 AND substr(\"status_operation_id\", 1, 1) GLOB '[0-7]' AND \"status_operation_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status_seq": { + "name": "status_seq", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "status_source": { + "name": "status_source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'system'" + }, + "subject_id": { + "name": "subject_id", + "type": "text CHECK (\"subject_id\" = upper(\"subject_id\") AND length(\"subject_id\") = 26 AND substr(\"subject_id\", 1, 1) GLOB '[0-7]' AND \"subject_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "subject_kind": { + "name": "subject_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "sandbox_subject_idx": { + "name": "sandbox_subject_idx", + "columns": ["kind", "subject_kind", "subject_id"], + "isUnique": true + }, + "sandbox_status_deadline_idx": { + "name": "sandbox_status_deadline_idx", + "columns": ["status", "inactive_deadline_at", "updated_at"], + "isUnique": false + }, + "sandbox_claim_idx": { + "name": "sandbox_claim_idx", + "columns": ["claim_expires_at", "claim_owner"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "sandbox_status_check": { + "name": "sandbox_status_check", + "value": "\"sandbox\".\"status\" IN ('cold', 'restoring', 'active', 'backing_up', 'destroying', 'error')" + }, + "sandbox_status_seq_check": { + "name": "sandbox_status_seq_check", + "value": "\"sandbox\".\"status_seq\" >= 0" + } + } + }, + "session_message": { + "name": "session_message", + "columns": { + "content_text": { + "name": "content_text", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by_account_id": { + "name": "created_by_account_id", + "type": "text CHECK (\"created_by_account_id\" = upper(\"created_by_account_id\") AND length(\"created_by_account_id\") = 26 AND substr(\"created_by_account_id\", 1, 1) GLOB '[0-7]' AND \"created_by_account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "plan_json": { + "name": "plan_json", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "segments_json": { + "name": "segments_json", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "seq": { + "name": "seq", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text CHECK (\"session_id\" = upper(\"session_id\") AND length(\"session_id\") = 26 AND substr(\"session_id\", 1, 1) GLOB '[0-7]' AND \"session_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_run_id": { + "name": "session_run_id", + "type": "text CHECK (\"session_run_id\" = upper(\"session_run_id\") AND length(\"session_run_id\") = 26 AND substr(\"session_run_id\", 1, 1) GLOB '[0-7]' AND \"session_run_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "session_message_session_seq_idx": { + "name": "session_message_session_seq_idx", + "columns": ["session_id", "seq"], + "isUnique": true + }, + "session_message_run_idx": { + "name": "session_message_run_idx", + "columns": ["session_run_id"], + "isUnique": false + } + }, + "foreignKeys": { + "session_message_session_id_session_id_fk": { + "name": "session_message_session_id_session_id_fk", + "tableFrom": "session_message", + "tableTo": "session", + "columnsFrom": ["session_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "session": { + "name": "session", + "columns": { + "agent_id": { + "name": "agent_id", + "type": "text CHECK (\"agent_id\" = upper(\"agent_id\") AND length(\"agent_id\") = 26 AND substr(\"agent_id\", 1, 1) GLOB '[0-7]' AND \"agent_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "archived_at": { + "name": "archived_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "attributed_user_id": { + "name": "attributed_user_id", + "type": "text CHECK (\"attributed_user_id\" = upper(\"attributed_user_id\") AND length(\"attributed_user_id\") = 26 AND substr(\"attributed_user_id\", 1, 1) GLOB '[0-7]' AND \"attributed_user_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "creator_account_id": { + "name": "creator_account_id", + "type": "text CHECK (\"creator_account_id\" = upper(\"creator_account_id\") AND length(\"creator_account_id\") = 26 AND substr(\"creator_account_id\", 1, 1) GLOB '[0-7]' AND \"creator_account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "deployment_version_id": { + "name": "deployment_version_id", + "type": "text CHECK (\"deployment_version_id\" = upper(\"deployment_version_id\") AND length(\"deployment_version_id\") = 26 AND substr(\"deployment_version_id\", 1, 1) GLOB '[0-7]' AND \"deployment_version_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "deployment_version_number": { + "name": "deployment_version_number", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_message_at": { + "name": "last_message_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_run_id": { + "name": "last_run_id", + "type": "text CHECK (\"last_run_id\" = upper(\"last_run_id\") AND length(\"last_run_id\") = 26 AND substr(\"last_run_id\", 1, 1) GLOB '[0-7]' AND \"last_run_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "message_seq_cursor": { + "name": "message_seq_cursor", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "metadata_json": { + "name": "metadata_json", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'{}'" + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "app_id": { + "name": "app_id", + "type": "text CHECK (\"app_id\" = upper(\"app_id\") AND length(\"app_id\") = 26 AND substr(\"app_id\", 1, 1) GLOB '[0-7]' AND \"app_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "renamed": { + "name": "renamed", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "runtime_id": { + "name": "runtime_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status_operation_id": { + "name": "status_operation_id", + "type": "text CHECK (\"status_operation_id\" = upper(\"status_operation_id\") AND length(\"status_operation_id\") = 26 AND substr(\"status_operation_id\", 1, 1) GLOB '[0-7]' AND \"status_operation_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status_seq": { + "name": "status_seq", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "runtime_event_seq_cursor": { + "name": "runtime_event_seq_cursor", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'preview'" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "session_agent_updated_idx": { + "name": "session_agent_updated_idx", + "columns": ["agent_id", "updated_at", "id"], + "isUnique": false + }, + "session_app_creator_archived_updated_idx": { + "name": "session_app_creator_archived_updated_idx", + "columns": ["app_id", "creator_account_id", "archived_at", "updated_at", "id"], + "isUnique": false + }, + "session_app_attributed_archived_updated_idx": { + "name": "session_app_attributed_archived_updated_idx", + "columns": ["app_id", "attributed_user_id", "archived_at", "updated_at", "id"], + "isUnique": false + }, + "session_app_creator_type_archived_updated_idx": { + "name": "session_app_creator_type_archived_updated_idx", + "columns": ["app_id", "creator_account_id", "type", "archived_at", "updated_at", "id"], + "isUnique": false + }, + "session_app_attributed_type_archived_updated_idx": { + "name": "session_app_attributed_type_archived_updated_idx", + "columns": ["app_id", "attributed_user_id", "type", "archived_at", "updated_at", "id"], + "isUnique": false + }, + "session_status_operation_updated_idx": { + "name": "session_status_operation_updated_idx", + "columns": ["status", "status_operation_id", "updated_at"], + "isUnique": false + }, + "session_status_updated_idx": { + "name": "session_status_updated_idx", + "columns": ["status", "updated_at", "id"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "session_status_check": { + "name": "session_status_check", + "value": "\"session\".\"status\" IN ('IDLE', 'RUNNING', 'RESCHEDULING', 'TERMINATED')" + }, + "session_status_seq_check": { + "name": "session_status_seq_check", + "value": "\"session\".\"status_seq\" >= 0" + } + } + }, + "session_execution_snapshot": { + "name": "session_execution_snapshot", + "columns": { + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "plan_json": { + "name": "plan_json", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text CHECK (\"session_id\" = upper(\"session_id\") AND length(\"session_id\") = 26 AND substr(\"session_id\", 1, 1) GLOB '[0-7]' AND \"session_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "session_execution_snapshot_session_id_session_id_fk": { + "name": "session_execution_snapshot_session_id_session_id_fk", + "tableFrom": "session_execution_snapshot", + "tableTo": "session", + "columnsFrom": ["session_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "session_run_skill": { + "name": "session_run_skill", + "columns": { + "blob_sha256": { + "name": "blob_sha256", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "materialization_status": { + "name": "materialization_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "mount_path": { + "name": "mount_path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "resolution_mode": { + "name": "resolution_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_run_id": { + "name": "session_run_id", + "type": "text CHECK (\"session_run_id\" = upper(\"session_run_id\") AND length(\"session_run_id\") = 26 AND substr(\"session_run_id\", 1, 1) GLOB '[0-7]' AND \"session_run_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "skill_id": { + "name": "skill_id", + "type": "text CHECK (\"skill_id\" = upper(\"skill_id\") AND length(\"skill_id\") = 26 AND substr(\"skill_id\", 1, 1) GLOB '[0-7]' AND \"skill_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "skill_name": { + "name": "skill_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "snapshot_id": { + "name": "snapshot_id", + "type": "text CHECK (\"snapshot_id\" = upper(\"snapshot_id\") AND length(\"snapshot_id\") = 26 AND substr(\"snapshot_id\", 1, 1) GLOB '[0-7]' AND \"snapshot_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "warning_code": { + "name": "warning_code", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "session_run_skill_run_resolution_idx": { + "name": "session_run_skill_run_resolution_idx", + "columns": ["session_run_id", "resolution_mode"], + "isUnique": false + } + }, + "foreignKeys": { + "session_run_skill_session_run_id_session_run_id_fk": { + "name": "session_run_skill_session_run_id_session_run_id_fk", + "tableFrom": "session_run_skill", + "tableTo": "session_run", + "columnsFrom": ["session_run_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "session_run_skill_session_run_id_skill_id_pk": { + "columns": ["session_run_id", "skill_id"], + "name": "session_run_skill_session_run_id_skill_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "session_run": { + "name": "session_run", + "columns": { + "agent_id": { + "name": "agent_id", + "type": "text CHECK (\"agent_id\" = upper(\"agent_id\") AND length(\"agent_id\") = 26 AND substr(\"agent_id\", 1, 1) GLOB '[0-7]' AND \"agent_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "bound_capability_agent_id": { + "name": "bound_capability_agent_id", + "type": "text CHECK (\"bound_capability_agent_id\" = upper(\"bound_capability_agent_id\") AND length(\"bound_capability_agent_id\") = 26 AND substr(\"bound_capability_agent_id\", 1, 1) GLOB '[0-7]' AND \"bound_capability_agent_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "bound_capability_app_id": { + "name": "bound_capability_app_id", + "type": "text CHECK (\"bound_capability_app_id\" = upper(\"bound_capability_app_id\") AND length(\"bound_capability_app_id\") = 26 AND substr(\"bound_capability_app_id\", 1, 1) GLOB '[0-7]' AND \"bound_capability_app_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "bound_capability_binding_env": { + "name": "bound_capability_binding_env", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "bound_capability_binding_name": { + "name": "bound_capability_binding_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "bound_capability_deployment_id": { + "name": "bound_capability_deployment_id", + "type": "text CHECK (\"bound_capability_deployment_id\" = upper(\"bound_capability_deployment_id\") AND length(\"bound_capability_deployment_id\") = 26 AND substr(\"bound_capability_deployment_id\", 1, 1) GLOB '[0-7]' AND \"bound_capability_deployment_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "bound_capability_deployment_run_id": { + "name": "bound_capability_deployment_run_id", + "type": "text CHECK (\"bound_capability_deployment_run_id\" = upper(\"bound_capability_deployment_run_id\") AND length(\"bound_capability_deployment_run_id\") = 26 AND substr(\"bound_capability_deployment_run_id\", 1, 1) GLOB '[0-7]' AND \"bound_capability_deployment_run_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "completed_at": { + "name": "completed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by_account_id": { + "name": "created_by_account_id", + "type": "text CHECK (\"created_by_account_id\" = upper(\"created_by_account_id\") AND length(\"created_by_account_id\") = 26 AND substr(\"created_by_account_id\", 1, 1) GLOB '[0-7]' AND \"created_by_account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "deployment_version_id": { + "name": "deployment_version_id", + "type": "text CHECK (\"deployment_version_id\" = upper(\"deployment_version_id\") AND length(\"deployment_version_id\") = 26 AND substr(\"deployment_version_id\", 1, 1) GLOB '[0-7]' AND \"deployment_version_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "deployment_version_number": { + "name": "deployment_version_number", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "driver_instance_id": { + "name": "driver_instance_id", + "type": "text CHECK (\"driver_instance_id\" = upper(\"driver_instance_id\") AND length(\"driver_instance_id\") = 26 AND substr(\"driver_instance_id\", 1, 1) GLOB '[0-7]' AND \"driver_instance_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error_code": { + "name": "error_code", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error_details_json": { + "name": "error_details_json", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "runtime_id": { + "name": "runtime_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text CHECK (\"session_id\" = upper(\"session_id\") AND length(\"session_id\") = 26 AND substr(\"session_id\", 1, 1) GLOB '[0-7]' AND \"session_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "started_at": { + "name": "started_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status_changed_at": { + "name": "status_changed_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "status_event": { + "name": "status_event", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'run.queue'" + }, + "status_operation_id": { + "name": "status_operation_id", + "type": "text CHECK (\"status_operation_id\" = upper(\"status_operation_id\") AND length(\"status_operation_id\") = 26 AND substr(\"status_operation_id\", 1, 1) GLOB '[0-7]' AND \"status_operation_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status_seq": { + "name": "status_seq", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "status_source": { + "name": "status_source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'system'" + }, + "trace_id": { + "name": "trace_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "trigger": { + "name": "trigger", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "session_run_driver_instance_idx": { + "name": "session_run_driver_instance_idx", + "columns": ["driver_instance_id", "created_at"], + "isUnique": false + }, + "session_run_active_driver_lease_idx": { + "name": "session_run_active_driver_lease_idx", + "columns": ["driver_instance_id"], + "isUnique": true, + "where": "\"session_run\".\"driver_instance_id\" IS NOT NULL AND \"session_run\".\"status\" IN ('queued', 'booting', 'running', 'waiting_input')" + }, + "session_run_session_created_at_idx": { + "name": "session_run_session_created_at_idx", + "columns": ["session_id", "created_at"], + "isUnique": false + }, + "session_run_session_status_idx": { + "name": "session_run_session_status_idx", + "columns": ["session_id", "status"], + "isUnique": false + } + }, + "foreignKeys": { + "session_run_session_id_session_id_fk": { + "name": "session_run_session_id_session_id_fk", + "tableFrom": "session_run", + "tableTo": "session", + "columnsFrom": ["session_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "session_run_status_check": { + "name": "session_run_status_check", + "value": "\"session_run\".\"status\" IN ('queued', 'booting', 'running', 'waiting_input', 'completed', 'failed', 'cancelled', 'expired')" + }, + "session_run_status_seq_check": { + "name": "session_run_status_seq_check", + "value": "\"session_run\".\"status_seq\" >= 0" + } + } + }, + "session_event": { + "name": "session_event", + "columns": { + "agent_id": { + "name": "agent_id", + "type": "text CHECK (\"agent_id\" = upper(\"agent_id\") AND length(\"agent_id\") = 26 AND substr(\"agent_id\", 1, 1) GLOB '[0-7]' AND \"agent_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "content_text": { + "name": "content_text", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ended_at": { + "name": "ended_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "family": { + "name": "family", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "occurred_at": { + "name": "occurred_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "process_status": { + "name": "process_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "process_type": { + "name": "process_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "run_id": { + "name": "run_id", + "type": "text CHECK (\"run_id\" = upper(\"run_id\") AND length(\"run_id\") = 26 AND substr(\"run_id\", 1, 1) GLOB '[0-7]' AND \"run_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "seq": { + "name": "seq", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text CHECK (\"session_id\" = upper(\"session_id\") AND length(\"session_id\") = 26 AND substr(\"session_id\", 1, 1) GLOB '[0-7]' AND \"session_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source_event_id": { + "name": "source_event_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tokens": { + "name": "tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "trace_id": { + "name": "trace_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "session_event_agent_family_created_idx": { + "name": "session_event_agent_family_created_idx", + "columns": ["agent_id", "family", "created_at", "id"], + "isUnique": false + }, + "session_event_agent_visibility_created_idx": { + "name": "session_event_agent_visibility_created_idx", + "columns": ["agent_id", "visibility", "created_at", "id"], + "isUnique": false + }, + "session_event_agent_created_idx": { + "name": "session_event_agent_created_idx", + "columns": ["agent_id", "created_at", "id"], + "isUnique": false + }, + "session_event_session_visibility_seq_idx": { + "name": "session_event_session_visibility_seq_idx", + "columns": ["session_id", "visibility", "seq"], + "isUnique": false + }, + "session_event_session_seq_idx": { + "name": "session_event_session_seq_idx", + "columns": ["session_id", "seq"], + "isUnique": true + }, + "session_event_session_source_idx": { + "name": "session_event_session_source_idx", + "columns": ["session_id", "source_event_id"], + "isUnique": true + } + }, + "foreignKeys": { + "session_event_session_id_session_id_fk": { + "name": "session_event_session_id_session_id_fk", + "tableFrom": "session_event", + "tableTo": "session", + "columnsFrom": ["session_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "session_model_call": { + "name": "session_model_call", + "columns": { + "cache_creation_tokens": { + "name": "cache_creation_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_read_tokens": { + "name": "cache_read_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "call_key": { + "name": "call_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "completed_at": { + "name": "completed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cost_currency": { + "name": "cost_currency", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "driver_instance_id": { + "name": "driver_instance_id", + "type": "text CHECK (\"driver_instance_id\" = upper(\"driver_instance_id\") AND length(\"driver_instance_id\") = 26 AND substr(\"driver_instance_id\", 1, 1) GLOB '[0-7]' AND \"driver_instance_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error_code": { + "name": "error_code", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata_json": { + "name": "metadata_json", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "native_call_id": { + "name": "native_call_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "output_tokens": { + "name": "output_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text CHECK (\"session_id\" = upper(\"session_id\") AND length(\"session_id\") = 26 AND substr(\"session_id\", 1, 1) GLOB '[0-7]' AND \"session_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_run_id": { + "name": "session_run_id", + "type": "text CHECK (\"session_run_id\" = upper(\"session_run_id\") AND length(\"session_run_id\") = 26 AND substr(\"session_run_id\", 1, 1) GLOB '[0-7]' AND \"session_run_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "started_at": { + "name": "started_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "total_cost_usd_micros": { + "name": "total_cost_usd_micros", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "trace_id": { + "name": "trace_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "session_model_call_run_created_idx": { + "name": "session_model_call_run_created_idx", + "columns": ["session_run_id", "created_at"], + "isUnique": false + }, + "session_model_call_session_created_idx": { + "name": "session_model_call_session_created_idx", + "columns": ["session_id", "created_at"], + "isUnique": false + }, + "session_model_call_run_key_idx": { + "name": "session_model_call_run_key_idx", + "columns": ["session_run_id", "call_key"], + "isUnique": true + }, + "session_model_call_native_idx": { + "name": "session_model_call_native_idx", + "columns": ["driver_instance_id", "native_call_id"], + "isUnique": true + } + }, + "foreignKeys": { + "session_model_call_session_id_session_id_fk": { + "name": "session_model_call_session_id_session_id_fk", + "tableFrom": "session_model_call", + "tableTo": "session", + "columnsFrom": ["session_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "session_model_call_session_run_id_session_run_id_fk": { + "name": "session_model_call_session_run_id_session_run_id_fk", + "tableFrom": "session_model_call", + "tableTo": "session_run", + "columnsFrom": ["session_run_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "session_permission_request": { + "name": "session_permission_request", + "columns": { + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "driver_instance_id": { + "name": "driver_instance_id", + "type": "text CHECK (\"driver_instance_id\" = upper(\"driver_instance_id\") AND length(\"driver_instance_id\") = 26 AND substr(\"driver_instance_id\", 1, 1) GLOB '[0-7]' AND \"driver_instance_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "raw_input": { + "name": "raw_input", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "request_id": { + "name": "request_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "run_id": { + "name": "run_id", + "type": "text CHECK (\"run_id\" = upper(\"run_id\") AND length(\"run_id\") = 26 AND substr(\"run_id\", 1, 1) GLOB '[0-7]' AND \"run_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text CHECK (\"session_id\" = upper(\"session_id\") AND length(\"session_id\") = 26 AND substr(\"session_id\", 1, 1) GLOB '[0-7]' AND \"session_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tool_call_id": { + "name": "tool_call_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tool_kind": { + "name": "tool_kind", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "session_permission_request_run_idx": { + "name": "session_permission_request_run_idx", + "columns": ["session_id", "run_id"], + "isUnique": false + } + }, + "foreignKeys": { + "session_permission_request_session_id_session_id_fk": { + "name": "session_permission_request_session_id_session_id_fk", + "tableFrom": "session_permission_request", + "tableTo": "session", + "columnsFrom": ["session_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "session_permission_request_session_id_request_id_pk": { + "columns": ["session_id", "request_id"], + "name": "session_permission_request_session_id_request_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "session_readiness_snapshot": { + "name": "session_readiness_snapshot", + "columns": { + "readiness_json": { + "name": "readiness_json", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text CHECK (\"session_id\" = upper(\"session_id\") AND length(\"session_id\") = 26 AND substr(\"session_id\", 1, 1) GLOB '[0-7]' AND \"session_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "session_readiness_snapshot_session_id_session_id_fk": { + "name": "session_readiness_snapshot_session_id_session_id_fk", + "tableFrom": "session_readiness_snapshot", + "tableTo": "session", + "columnsFrom": ["session_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "skill_snapshot_entry": { + "name": "skill_snapshot_entry", + "columns": { + "entry_kind": { + "name": "entry_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "is_executable": { + "name": "is_executable", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "mime_type": { + "name": "mime_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "snapshot_id": { + "name": "snapshot_id", + "type": "text CHECK (\"snapshot_id\" = upper(\"snapshot_id\") AND length(\"snapshot_id\") = 26 AND substr(\"snapshot_id\", 1, 1) GLOB '[0-7]' AND \"snapshot_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "skill_snapshot_entry_snapshot_id_path_pk": { + "columns": ["snapshot_id", "path"], + "name": "skill_snapshot_entry_snapshot_id_path_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "skill_snapshot": { + "name": "skill_snapshot", + "columns": { + "author": { + "name": "author", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "blob_key": { + "name": "blob_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "blob_sha256": { + "name": "blob_sha256", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "blob_size": { + "name": "blob_size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "app_id": { + "name": "app_id", + "type": "text CHECK (\"app_id\" = upper(\"app_id\") AND length(\"app_id\") = 26 AND substr(\"app_id\", 1, 1) GLOB '[0-7]' AND \"app_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "skill_markdown_path": { + "name": "skill_markdown_path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "uncompressed_size": { + "name": "uncompressed_size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "skill_snapshot_app_created_at_idx": { + "name": "skill_snapshot_app_created_at_idx", + "columns": ["app_id", "created_at"], + "isUnique": false + }, + "skill_snapshot_blob_sha256_idx": { + "name": "skill_snapshot_blob_sha256_idx", + "columns": ["app_id", "blob_sha256"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "skill": { + "name": "skill", + "columns": { + "author": { + "name": "author", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "current_snapshot_id": { + "name": "current_snapshot_id", + "type": "text CHECK (\"current_snapshot_id\" = upper(\"current_snapshot_id\") AND length(\"current_snapshot_id\") = 26 AND substr(\"current_snapshot_id\", 1, 1) GLOB '[0-7]' AND \"current_snapshot_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "forked_from_owner_name": { + "name": "forked_from_owner_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "forked_from_skill_id": { + "name": "forked_from_skill_id", + "type": "text CHECK (\"forked_from_skill_id\" = upper(\"forked_from_skill_id\") AND length(\"forked_from_skill_id\") = 26 AND substr(\"forked_from_skill_id\", 1, 1) GLOB '[0-7]' AND \"forked_from_skill_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "forked_from_skill_name": { + "name": "forked_from_skill_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "owner_account_id": { + "name": "owner_account_id", + "type": "text CHECK (\"owner_account_id\" = upper(\"owner_account_id\") AND length(\"owner_account_id\") = 26 AND substr(\"owner_account_id\", 1, 1) GLOB '[0-7]' AND \"owner_account_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "app_id": { + "name": "app_id", + "type": "text CHECK (\"app_id\" = upper(\"app_id\") AND length(\"app_id\") = 26 AND substr(\"app_id\", 1, 1) GLOB '[0-7]' AND \"app_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source_kind": { + "name": "source_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "skill_app_updated_at_idx": { + "name": "skill_app_updated_at_idx", + "columns": ["app_id", "updated_at"], + "isUnique": false + }, + "skill_owner_account_updated_at_idx": { + "name": "skill_owner_account_updated_at_idx", + "columns": ["owner_account_id", "updated_at"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "account": { + "name": "account", + "columns": { + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email_verified": { + "name": "email_verified", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "image_url": { + "name": "image_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_active_organization_id": { + "name": "last_active_organization_id", + "type": "text CHECK (\"last_active_organization_id\" = upper(\"last_active_organization_id\") AND length(\"last_active_organization_id\") = 26 AND substr(\"last_active_organization_id\", 1, 1) GLOB '[0-7]' AND \"last_active_organization_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "system_agent_model": { + "name": "system_agent_model", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "account_email_idx": { + "name": "account_email_idx", + "columns": ["email"], + "isUnique": true + }, + "account_last_active_organization_idx": { + "name": "account_last_active_organization_idx", + "columns": ["last_active_organization_id"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "usage_daily_rollup": { + "name": "usage_daily_rollup", + "columns": { + "actor_user_id": { + "name": "actor_user_id", + "type": "text CHECK (\"actor_user_id\" = upper(\"actor_user_id\") AND length(\"actor_user_id\") = 26 AND substr(\"actor_user_id\", 1, 1) GLOB '[0-7]' AND \"actor_user_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text CHECK (\"agent_id\" = upper(\"agent_id\") AND length(\"agent_id\") = 26 AND substr(\"agent_id\", 1, 1) GLOB '[0-7]' AND \"agent_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_owner_user_id": { + "name": "agent_owner_user_id", + "type": "text CHECK (\"agent_owner_user_id\" = upper(\"agent_owner_user_id\") AND length(\"agent_owner_user_id\") = 26 AND substr(\"agent_owner_user_id\", 1, 1) GLOB '[0-7]' AND \"agent_owner_user_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_publication_state_at_run": { + "name": "agent_publication_state_at_run", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "cache_creation_tokens": { + "name": "cache_creation_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "cache_read_tokens": { + "name": "cache_read_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "date": { + "name": "date", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "text CHECK (\"organization_id\" = upper(\"organization_id\") AND length(\"organization_id\") = 26 AND substr(\"organization_id\", 1, 1) GLOB '[0-7]' AND \"organization_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "app_id": { + "name": "app_id", + "type": "text CHECK (\"app_id\" = upper(\"app_id\") AND length(\"app_id\") = 26 AND substr(\"app_id\", 1, 1) GLOB '[0-7]' AND \"app_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "output_tokens": { + "name": "output_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "request_count": { + "name": "request_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "run_purpose": { + "name": "run_purpose", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "total_cost_usd_micros": { + "name": "total_cost_usd_micros", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "unpriced_request_count": { + "name": "unpriced_request_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "usage_daily_rollup_app_date_idx": { + "name": "usage_daily_rollup_app_date_idx", + "columns": ["app_id", "date"], + "isUnique": false + }, + "usage_daily_rollup_organization_date_idx": { + "name": "usage_daily_rollup_organization_date_idx", + "columns": ["organization_id", "date"], + "isUnique": false + }, + "usage_daily_rollup_agent_date_idx": { + "name": "usage_daily_rollup_agent_date_idx", + "columns": ["agent_id", "date"], + "isUnique": false + }, + "usage_daily_rollup_actor_date_idx": { + "name": "usage_daily_rollup_actor_date_idx", + "columns": ["actor_user_id", "date"], + "isUnique": false + }, + "usage_daily_rollup_owner_date_idx": { + "name": "usage_daily_rollup_owner_date_idx", + "columns": ["agent_owner_user_id", "date"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "usage_daily_rollup_organization_id_app_id_agent_id_actor_user_id_agent_owner_user_id_date_agent_publication_state_at_run_run_purpose_provider_model_pk": { + "columns": [ + "organization_id", + "app_id", + "agent_id", + "actor_user_id", + "agent_owner_user_id", + "date", + "agent_publication_state_at_run", + "run_purpose", + "provider", + "model" + ], + "name": "usage_daily_rollup_organization_id_app_id_agent_id_actor_user_id_agent_owner_user_id_date_agent_publication_state_at_run_run_purpose_provider_model_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "usage_event_rollup_receipt": { + "name": "usage_event_rollup_receipt", + "columns": { + "rolled_up_at": { + "name": "rolled_up_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source_event_id": { + "name": "source_event_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "usage_event_rollup_receipt_rolled_up_at_idx": { + "name": "usage_event_rollup_receipt_rolled_up_at_idx", + "columns": ["rolled_up_at"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "usage_event_rollup_receipt_source_source_event_id_pk": { + "columns": ["source", "source_event_id"], + "name": "usage_event_rollup_receipt_source_source_event_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "usage_event": { + "name": "usage_event", + "columns": { + "actor_user_id": { + "name": "actor_user_id", + "type": "text CHECK (\"actor_user_id\" = upper(\"actor_user_id\") AND length(\"actor_user_id\") = 26 AND substr(\"actor_user_id\", 1, 1) GLOB '[0-7]' AND \"actor_user_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text CHECK (\"agent_id\" = upper(\"agent_id\") AND length(\"agent_id\") = 26 AND substr(\"agent_id\", 1, 1) GLOB '[0-7]' AND \"agent_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_owner_user_id": { + "name": "agent_owner_user_id", + "type": "text CHECK (\"agent_owner_user_id\" = upper(\"agent_owner_user_id\") AND length(\"agent_owner_user_id\") = 26 AND substr(\"agent_owner_user_id\", 1, 1) GLOB '[0-7]' AND \"agent_owner_user_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_publication_state_at_run": { + "name": "agent_publication_state_at_run", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_revision_id": { + "name": "agent_revision_id", + "type": "text CHECK (\"agent_revision_id\" = upper(\"agent_revision_id\") AND length(\"agent_revision_id\") = 26 AND substr(\"agent_revision_id\", 1, 1) GLOB '[0-7]' AND \"agent_revision_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_creation_tokens": { + "name": "cache_creation_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "cache_read_tokens": { + "name": "cache_read_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organization_id": { + "name": "organization_id", + "type": "text CHECK (\"organization_id\" = upper(\"organization_id\") AND length(\"organization_id\") = 26 AND substr(\"organization_id\", 1, 1) GLOB '[0-7]' AND \"organization_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "app_id": { + "name": "app_id", + "type": "text CHECK (\"app_id\" = upper(\"app_id\") AND length(\"app_id\") = 26 AND substr(\"app_id\", 1, 1) GLOB '[0-7]' AND \"app_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "output_tokens": { + "name": "output_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "price_snapshot_json": { + "name": "price_snapshot_json", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pricing_status": { + "name": "pricing_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "run_purpose": { + "name": "run_purpose", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "runtime_id": { + "name": "runtime_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text CHECK (\"session_id\" = upper(\"session_id\") AND length(\"session_id\") = 26 AND substr(\"session_id\", 1, 1) GLOB '[0-7]' AND \"session_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "session_run_id": { + "name": "session_run_id", + "type": "text CHECK (\"session_run_id\" = upper(\"session_run_id\") AND length(\"session_run_id\") = 26 AND substr(\"session_run_id\", 1, 1) GLOB '[0-7]' AND \"session_run_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source_event_id": { + "name": "source_event_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "total_cost_usd_micros": { + "name": "total_cost_usd_micros", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "usage_contract": { + "name": "usage_contract", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "usage_event_app_created_idx": { + "name": "usage_event_app_created_idx", + "columns": ["app_id", "created_at"], + "isUnique": false + }, + "usage_event_organization_created_idx": { + "name": "usage_event_organization_created_idx", + "columns": ["organization_id", "created_at"], + "isUnique": false + }, + "usage_event_agent_created_idx": { + "name": "usage_event_agent_created_idx", + "columns": ["agent_id", "created_at"], + "isUnique": false + }, + "usage_event_actor_created_idx": { + "name": "usage_event_actor_created_idx", + "columns": ["actor_user_id", "created_at"], + "isUnique": false + }, + "usage_event_owner_created_idx": { + "name": "usage_event_owner_created_idx", + "columns": ["agent_owner_user_id", "created_at"], + "isUnique": false + }, + "usage_event_session_run_idx": { + "name": "usage_event_session_run_idx", + "columns": ["session_run_id"], + "isUnique": false + }, + "usage_event_source_event_idx": { + "name": "usage_event_source_event_idx", + "columns": ["source", "source_event_id"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "vendor_credential": { + "name": "vendor_credential", + "columns": { + "api_base": { + "name": "api_base", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "api_key_secret_id": { + "name": "api_key_secret_id", + "type": "text CHECK (\"api_key_secret_id\" = upper(\"api_key_secret_id\") AND length(\"api_key_secret_id\") = 26 AND substr(\"api_key_secret_id\", 1, 1) GLOB '[0-7]' AND \"api_key_secret_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text CHECK (\"id\" = upper(\"id\") AND length(\"id\") = 26 AND substr(\"id\", 1, 1) GLOB '[0-7]' AND \"id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "is_default": { + "name": "is_default", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "models": { + "name": "models", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "app_id": { + "name": "app_id", + "type": "text CHECK (\"app_id\" = upper(\"app_id\") AND length(\"app_id\") = 26 AND substr(\"app_id\", 1, 1) GLOB '[0-7]' AND \"app_id\" NOT GLOB '*[^0-9A-HJKMNP-TV-Z]*')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "vendor_id": { + "name": "vendor_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "vendor_credential_app_vendor_idx": { + "name": "vendor_credential_app_vendor_idx", + "columns": ["app_id", "vendor_id"], + "isUnique": false + }, + "vendor_credential_app_vendor_name_idx": { + "name": "vendor_credential_app_vendor_name_idx", + "columns": ["app_id", "vendor_id", "name"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": { + "file_record_listing_idx": { + "columns": { + "lower(\"name\")": { + "isExpression": true + } + } + } + } + } +} diff --git a/pkgs/db/drizzle/meta/_journal.json b/pkgs/db/drizzle/meta/_journal.json index 7194293c..944eca94 100644 --- a/pkgs/db/drizzle/meta/_journal.json +++ b/pkgs/db/drizzle/meta/_journal.json @@ -36,6 +36,13 @@ "when": 1785082039000, "tag": "0004_usage-rollup-receipt", "breakpoints": true + }, + { + "idx": 5, + "version": "6", + "when": 1785332217208, + "tag": "0005_external-tool-effects", + "breakpoints": true } ] } diff --git a/pkgs/db/src/schema/runtime.schema.ts b/pkgs/db/src/schema/runtime.schema.ts index ea5bc9ca..639a2d77 100644 --- a/pkgs/db/src/schema/runtime.schema.ts +++ b/pkgs/db/src/schema/runtime.schema.ts @@ -1,5 +1,9 @@ import type { AgentKind } from "@mosoo/contracts/agent"; import type { DriverInstanceProtocol } from "@mosoo/contracts/driver-instance"; +import type { + ExternalToolEffectAttemptStatus, + ExternalToolEffectStatus, +} from "@mosoo/contracts/external-tool-effect"; import type { McpAuthType, McpAuthorizationState } from "@mosoo/contracts/mcp"; import type { RuntimeCommandStatus } from "@mosoo/contracts/runtime-command"; import type { @@ -14,6 +18,7 @@ import type { CredentialId, DriverCommandId, DriverInstanceId, + ExternalToolEffectId, McpServerId, PlatformId, AppId, @@ -30,6 +35,7 @@ import { check, index, integer, + primaryKey, sqliteTable, text, uniqueIndex, @@ -37,6 +43,7 @@ import { import { platformIdColumn } from "./id-column"; import { sessionsTable } from "./session/core.schema"; +import { sessionRunsTable } from "./session/runs.schema"; export const sandboxesTable = sqliteTable( "sandbox", @@ -219,6 +226,74 @@ export const driverCommandsTable = sqliteTable( ], ); +/** + * The durable fence around a write-capable MCP call. A command is allowed to + * invoke the provider only after this record moves from intent to executing. + */ +export const externalToolEffectsTable = sqliteTable( + "external_tool_effect", + { + attemptCount: integer("attempt_count").notNull().default(0), + commandId: platformIdColumn("command_id") + .notNull() + .references(() => driverCommandsTable.id, { onDelete: "cascade" }), + createdAt: integer("created_at").notNull(), + driverInstanceId: platformIdColumn("driver_instance_id") + .notNull() + .references(() => driverInstancesTable.id, { onDelete: "cascade" }), + id: platformIdColumn("id").primaryKey(), + idempotencyKey: text("idempotency_key").notNull(), + providerReceiptJson: text("provider_receipt_json"), + resultJson: text("result_json"), + serverId: platformIdColumn("server_id").notNull(), + sessionRunId: platformIdColumn("session_run_id") + .notNull() + .references(() => sessionRunsTable.id, { onDelete: "cascade" }), + status: text("status").$type().notNull(), + toolName: text("tool_name").notNull(), + updatedAt: integer("updated_at").notNull(), + }, + (table) => [ + check( + "external_tool_effect_status_check", + sql`${table.status} IN ('intent', 'executing', 'succeeded', 'unknown')`, + ), + uniqueIndex("external_tool_effect_command_idx").on(table.commandId), + uniqueIndex("external_tool_effect_idempotency_key_idx").on(table.idempotencyKey), + index("external_tool_effect_run_status_idx").on(table.sessionRunId, table.status, table.id), + index("external_tool_effect_driver_status_idx").on(table.driverInstanceId, table.status), + ], +); + +/** + * Append-only execution observations. A provider response is optional because + * MCP does not define a portable receipt or reconciliation endpoint. + */ +export const externalToolEffectAttemptsTable = sqliteTable( + "external_tool_effect_attempt", + { + attempt: integer("attempt").notNull(), + completedAt: integer("completed_at"), + createdAt: integer("created_at").notNull(), + effectId: platformIdColumn("effect_id") + .notNull() + .references(() => externalToolEffectsTable.id, { onDelete: "cascade" }), + providerReceiptJson: text("provider_receipt_json"), + resultJson: text("result_json"), + status: text("status").$type().notNull(), + }, + (table) => [ + primaryKey({ + columns: [table.effectId, table.attempt], + }), + check( + "external_tool_effect_attempt_status_check", + sql`${table.status} IN ('executing', 'succeeded', 'unknown')`, + ), + index("external_tool_effect_attempt_status_idx").on(table.status, table.createdAt), + ], +); + export const driverInstanceMcpGrantsTable = sqliteTable( "driver_instance_mcp_grant", { @@ -272,6 +347,8 @@ export type SandboxRow = typeof sandboxesTable.$inferSelect; export type SandboxSessionRow = typeof sandboxSessionsTable.$inferSelect; export type SandboxBackupRow = typeof sandboxBackupsTable.$inferSelect; export type DriverCommandRow = typeof driverCommandsTable.$inferSelect; +export type ExternalToolEffectAttemptRow = typeof externalToolEffectAttemptsTable.$inferSelect; +export type ExternalToolEffectRow = typeof externalToolEffectsTable.$inferSelect; export type DriverInstanceMcpGrantRow = typeof driverInstanceMcpGrantsTable.$inferSelect; export type DriverInstanceRow = typeof driverInstancesTable.$inferSelect; export type NativeResumeRefRow = typeof nativeResumeRefsTable.$inferSelect; diff --git a/pkgs/id/src/index.ts b/pkgs/id/src/index.ts index 73568102..49014911 100644 --- a/pkgs/id/src/index.ts +++ b/pkgs/id/src/index.ts @@ -19,6 +19,7 @@ export type CliOAuthFlowId = SemanticPlatformId<"CliOAuthFlowId">; export type CredentialId = SemanticPlatformId<"CredentialId">; export type DriverCommandId = SemanticPlatformId<"DriverCommandId">; export type DriverInstanceId = SemanticPlatformId<"DriverInstanceId">; +export type ExternalToolEffectId = SemanticPlatformId<"ExternalToolEffectId">; export type EnvironmentId = SemanticPlatformId<"EnvironmentId">; export type EnvironmentRevisionId = SemanticPlatformId<"EnvironmentRevisionId">; export type FileId = SemanticPlatformId<"FileId">;