@opengeni/db 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-NZA6YVN7.js → chunk-T2U4H4Z2.js} +8 -1
- package/dist/chunk-T2U4H4Z2.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +57 -3
- package/dist/index.js.map +1 -1
- package/dist/provision-roles.d.ts +25 -2
- package/dist/{schema-BI0iqN9U.d.ts → schema-DuRsrmzD.d.ts} +17 -0
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +1 -1
- package/drizzle/0036_modal_lease_orphan_reaper.sql +92 -0
- package/drizzle/0037_session_instructions.sql +18 -0
- package/package.json +3 -3
- package/src/index.ts +95 -4
- package/src/schema.ts +7 -0
- package/dist/chunk-NZA6YVN7.js.map +0 -1
|
@@ -233,6 +233,13 @@ var sessions = pgTable("sessions", {
|
|
|
233
233
|
initialMessage: text("initial_message").notNull(),
|
|
234
234
|
title: text("title"),
|
|
235
235
|
titleSource: text("title_source"),
|
|
236
|
+
// Per-session agent persona/system instructions supplied at create (the
|
|
237
|
+
// per-agent-type prompt lever for embedding hosts). NULL ⇒ the session
|
|
238
|
+
// carried none, so the composed agent instructions are byte-identical to a
|
|
239
|
+
// workspace-only persona (no backfill, no behavior change for existing rows).
|
|
240
|
+
// Composed system-level AFTER the workspace agentInstructions; never emitted
|
|
241
|
+
// as a timeline event.
|
|
242
|
+
instructions: text("instructions"),
|
|
236
243
|
resources: jsonb("resources").$type().notNull().default([]),
|
|
237
244
|
tools: jsonb("tools").$type().notNull().default([]),
|
|
238
245
|
metadata: jsonb("metadata").$type().notNull().default({}),
|
|
@@ -1113,4 +1120,4 @@ export {
|
|
|
1113
1120
|
socialPosts,
|
|
1114
1121
|
schema_exports
|
|
1115
1122
|
};
|
|
1116
|
-
//# sourceMappingURL=chunk-
|
|
1123
|
+
//# sourceMappingURL=chunk-T2U4H4Z2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schema.ts"],"sourcesContent":["import { sql } from \"drizzle-orm\";\nimport { bigint, boolean, index, integer, jsonb, numeric, pgTable, text, timestamp, uniqueIndex, uuid, customType } from \"drizzle-orm/pg-core\";\n\nconst vector = customType<{ data: number[]; driverData: string }>({\n dataType() {\n return \"vector(3072)\";\n },\n toDriver(value) {\n return `[${value.join(\",\")}]`;\n },\n});\n\nexport const managedAccounts = pgTable(\"managed_accounts\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n name: text(\"name\").notNull(),\n externalSource: text(\"external_source\"),\n externalId: text(\"external_id\"),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n external: uniqueIndex(\"managed_accounts_external_idx\").on(table.externalSource, table.externalId),\n}));\n\nexport const workspaces = pgTable(\"workspaces\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n name: text(\"name\").notNull(),\n slug: text(\"slug\"),\n externalSource: text(\"external_source\"),\n externalId: text(\"external_id\"),\n // White-label agent persona template override. NULL means the deployment\n // default (OPENGENI_AGENT_INSTRUCTIONS_TEMPLATE / DEFAULT_AGENT_INSTRUCTIONS).\n agentInstructions: text(\"agent_instructions\"),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n account: index(\"workspaces_account_idx\").on(table.accountId),\n accountSlug: uniqueIndex(\"workspaces_account_slug_idx\").on(table.accountId, table.slug).where(sql`${table.slug} is not null`),\n external: uniqueIndex(\"workspaces_external_idx\").on(table.externalSource, table.externalId),\n}));\n\nexport const workspaceMemberships = pgTable(\"workspace_memberships\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n subjectId: text(\"subject_id\").notNull(),\n subjectLabel: text(\"subject_label\"),\n role: text(\"role\").notNull().default(\"member\"),\n permissions: jsonb(\"permissions\").$type<string[]>().notNull().default([]),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n subjectWorkspace: uniqueIndex(\"workspace_memberships_subject_workspace_idx\").on(table.subjectId, table.workspaceId),\n subject: index(\"workspace_memberships_subject_idx\").on(table.subjectId),\n account: index(\"workspace_memberships_account_idx\").on(table.accountId),\n}));\n\nexport const apiKeys = pgTable(\"api_keys\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").references(() => workspaces.id, { onDelete: \"cascade\" }),\n name: text(\"name\").notNull(),\n prefix: text(\"prefix\").notNull(),\n keyHash: text(\"key_hash\").notNull(),\n permissions: jsonb(\"permissions\").$type<string[]>().notNull().default([]),\n expiresAt: timestamp(\"expires_at\", { withTimezone: true }),\n revokedAt: timestamp(\"revoked_at\", { withTimezone: true }),\n lastUsedAt: timestamp(\"last_used_at\", { withTimezone: true }),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n prefix: index(\"api_keys_prefix_idx\").on(table.prefix),\n hash: uniqueIndex(\"api_keys_key_hash_idx\").on(table.keyHash),\n account: index(\"api_keys_account_idx\").on(table.accountId),\n workspace: index(\"api_keys_workspace_idx\").on(table.workspaceId),\n}));\n\nexport const workspaceEnvironments = pgTable(\"workspace_environments\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n name: text(\"name\").notNull(),\n description: text(\"description\"),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n workspaceName: uniqueIndex(\"workspace_environments_workspace_name_idx\").on(table.workspaceId, table.name),\n workspaceCreated: index(\"workspace_environments_workspace_created_idx\").on(table.workspaceId, table.createdAt),\n}));\n\nexport const workspaceEnvironmentVariables = pgTable(\"workspace_environment_variables\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n environmentId: uuid(\"environment_id\").notNull().references(() => workspaceEnvironments.id, { onDelete: \"cascade\" }),\n name: text(\"name\").notNull(),\n // Format: v1:<base64 iv>:<base64 ciphertext||gcm-tag>. Never returned by any API.\n valueEncrypted: text(\"value_encrypted\").notNull(),\n version: integer(\"version\").notNull().default(1),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n environmentName: uniqueIndex(\"workspace_environment_variables_env_name_idx\").on(table.workspaceId, table.environmentId, table.name),\n environment: index(\"workspace_environment_variables_workspace_env_idx\").on(table.workspaceId, table.environmentId),\n}));\n\n// Per-workspace ChatGPT/Codex subscription credential. One row per workspace.\n// access/refresh/id tokens live INSIDE credential_encrypted (v1 AES-256-GCM,\n// same envelope as workspace_environment_variables); the other columns are\n// plaintext metadata (header value + UI). RLS-isolated per workspace.\nexport const codexSubscriptionCredentials = pgTable(\"codex_subscription_credentials\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n // Format: v1:<base64 iv>:<base64 ciphertext||gcm-tag>. JSON {access_token, refresh_token, id_token}. Never returned by any API.\n credentialEncrypted: text(\"credential_encrypted\").notNull(),\n chatgptAccountId: text(\"chatgpt_account_id\"), // plaintext ChatGPT-Account-ID header value (non-secret)\n scopes: text(\"scopes\"), // space-delimited, as granted\n planType: text(\"plan_type\"),\n isFedramp: boolean(\"is_fedramp\").notNull().default(false),\n expiresAt: timestamp(\"expires_at\", { withTimezone: true }), // derived from access-token JWT exp\n lastRefreshAt: timestamp(\"last_refresh_at\", { withTimezone: true }),\n status: text(\"status\").notNull().default(\"active\"), // active | needs_relogin | error\n lastError: text(\"last_error\"),\n version: integer(\"version\").notNull().default(1),\n label: text(\"label\"), // user-chosen nickname; null ⇒ derive from email/plan/account\n accountEmail: text(\"account_email\"), // email from the id_token (user's own email; non-secret)\n // P2 usage cache (plaintext metadata; NEVER a token). Snapshotted from\n // GET /wham/usage; drives the quota bars + the cache TTL. primary = 5h window\n // (limit_window_seconds 18000), secondary = weekly (604800).\n primaryUsedPercent: integer(\"primary_used_percent\"),\n primaryResetAt: timestamp(\"primary_reset_at\", { withTimezone: true }),\n secondaryUsedPercent: integer(\"secondary_used_percent\"),\n secondaryResetAt: timestamp(\"secondary_reset_at\", { withTimezone: true }),\n usageCheckedAt: timestamp(\"usage_checked_at\", { withTimezone: true }), // snapshot freshness → cache TTL clock\n // P3 rotation cooldown (plaintext metadata; NEVER a token). Set when this account hit its\n // usage cap on a rotation turn; the rotation engine treats `exhausted_until > now()` as\n // capped/skip so it isn't immediately re-picked. Self-clears via the now() comparison.\n exhaustedUntil: timestamp(\"exhausted_until\", { withTimezone: true }),\n // P4 connector-aware rotation cache (plaintext metadata; NEVER a token). The set\n // of ORIGINAL-dotted connector namespaces (github/gmail/linear/…) this account\n // exposes via codex_apps, captured from the per-turn tools/list. null ⇒ never\n // probed (the ranker treats it as unknown: never credited as covering, never\n // excluded). The writer only ever sets a NON-empty set, so a flaky empty turn\n // can't false-drop coverage. connectorsCheckedAt is the freshness clock.\n connectorNamespaces: text(\"connector_namespaces\").array(),\n connectorsCheckedAt: timestamp(\"connectors_checked_at\", { withTimezone: true }),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n // REPLACES codex_subscription_credentials_workspace_idx (the one-per-workspace cap).\n // One row per (workspace, ChatGPT account). Partial WHERE chatgpt_account_id IS NOT NULL\n // so degenerate null-account rows can't collide; the device-grant connect path always\n // populates chatgpt_account_id.\n wsAccount: uniqueIndex(\"codex_subscription_credentials_ws_account_idx\")\n .on(table.workspaceId, table.chatgptAccountId)\n .where(sql`${table.chatgptAccountId} is not null`),\n workspace: index(\"codex_subscription_credentials_workspace_lookup_idx\").on(table.workspaceId),\n}));\n\n// Per-workspace Codex account selection (the ACTIVE pointer) + P3 rotation\n// forward-compat. One row per workspace. The only P1-load-bearing column is\n// activeCredentialId — the account a session runs on when it has no pin. NULL ⇒\n// none selected (e.g. the active one was just disconnected). The\n// (account_id, workspace_id) pair inherits the verbatim workspace_rls_visible\n// policy. active_credential_id's FK is declared in the MIGRATION (not\n// .references()) to avoid a forward-reference on the const ordering, exactly like\n// sessions.activeSandboxId; ON DELETE SET NULL.\nexport const codexRotationSettings = pgTable(\"codex_rotation_settings\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n activeCredentialId: uuid(\"active_credential_id\"),\n rotationEnabled: boolean(\"rotation_enabled\").notNull().default(false), // P3, inert in P1\n rotationStrategy: text(\"rotation_strategy\").notNull().default(\"most_remaining\"), // P3, inert\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n workspace: uniqueIndex(\"codex_rotation_settings_workspace_idx\").on(table.workspaceId),\n}));\n\nexport const sessions = pgTable(\"sessions\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n status: text(\"status\").notNull().default(\"queued\"),\n initialMessage: text(\"initial_message\").notNull(),\n title: text(\"title\"),\n titleSource: text(\"title_source\"),\n // Per-session agent persona/system instructions supplied at create (the\n // per-agent-type prompt lever for embedding hosts). NULL ⇒ the session\n // carried none, so the composed agent instructions are byte-identical to a\n // workspace-only persona (no backfill, no behavior change for existing rows).\n // Composed system-level AFTER the workspace agentInstructions; never emitted\n // as a timeline event.\n instructions: text(\"instructions\"),\n resources: jsonb(\"resources\").$type<unknown[]>().notNull().default([]),\n tools: jsonb(\"tools\").$type<unknown[]>().notNull().default([]),\n metadata: jsonb(\"metadata\").$type<Record<string, unknown>>().notNull().default({}),\n model: text(\"model\").notNull(),\n sandboxBackend: text(\"sandbox_backend\").notNull(),\n // The OS this session's box runs. Defaults to 'linux' (today's only OS, so\n // every existing + new row is a behavior-preserving no-op). CHECK-constrained\n // to the SandboxOs enum (linux|macos|windows) in migration 0018.\n sandboxOs: text(\"sandbox_os\").notNull().default(\"linux\"),\n // The shared-sandbox group this session's box belongs to. Defaults to the\n // session's OWN id (a singleton group: group === session — today's 1:1\n // behavior). When spawned shared via session_create, set to the PARENT's\n // sandboxGroupId so both run in ONE box. Immutable once set. NOT an FK (the\n // value is this row's id or an ancestor session's id in the same workspace;\n // the live lease row, not a sandbox_groups table, materializes the group).\n // The app generates the uuid and uses it for both id and sandbox_group_id in\n // one insert — it cannot SQL-default to id (id is defaultRandom()).\n sandboxGroupId: uuid(\"sandbox_group_id\").notNull(),\n // The first-class swappable-sandbox POINTER (bring-your-own-compute M2,\n // dossier §10.3). NULL == \"use the session's own group sandbox\" (the\n // backward-compat default — every existing/new row is a behavior-preserving\n // no-op). The routing proxy re-reads (active_sandbox_id, active_epoch) PER\n // TOOL CALL to make a Modal<->selfhosted hot-swap seamless. The FK\n // (-> sandboxes(id) ON DELETE SET NULL — a deleted sandbox degrades the\n // pointer to the group default, never dangles) lives in migration 0024, NOT a\n // Drizzle .references() — exactly like parentSessionId below, so the const\n // ordering imposes no forward-reference.\n activeSandboxId: uuid(\"active_sandbox_id\"),\n // The SECOND epoch ABOVE sandbox_leases.lease_epoch, bumped on every swap; an\n // in-flight op fenced by a stale active_epoch retries against the new active\n // sandbox. integer (NOT bigint) — the lease-epoch spike: int8 reads back as a\n // JS string and breaks the strict fence; int4 returns a number.\n activeEpoch: integer(\"active_epoch\").notNull().default(0),\n // The session's WORKING DIRECTORY — the path/cwd base the (selfhosted) box's\n // agent/terminal/file-dock operate under. A launch-workspace_root-relative\n // subdir or an absolute machine path; surfaced alongside the active-sandbox\n // pointer (readActiveSandbox) and written through the epoch-fenced\n // setActiveSandbox CAS, NOT the row INSERT. NULL (the default) ⇒ today's\n // behavior exactly — the agent substitutes its workspace_root for an empty cwd,\n // so an unset working_dir is a byte-identical no-op. Create-time only (Stage A).\n workingDir: text(\"working_dir\"),\n environmentId: uuid(\"environment_id\").references(() => workspaceEnvironments.id, { onDelete: \"set null\" }),\n // Non-default first-party MCP token permissions (manager-style sessions);\n // null means the fixed worker default set in @opengeni/runtime.\n firstPartyMcpPermissions: jsonb(\"first_party_mcp_permissions\").$type<string[]>(),\n // The manager session that spawned this one via session_create. Set only\n // when the creating grant carried a worker-signed sessionId claim (a session\n // spawning a worker); null for direct API creates and scheduled-task runs.\n // When set, this worker's terminal-for-now transitions wake the parent so a\n // manager can orchestrate workers without busy-polling. Self-referencing FK,\n // ON DELETE SET NULL so deleting a manager never cascades into its workers.\n parentSessionId: uuid(\"parent_session_id\"),\n // Workspace-scoped CREATE idempotency key. NULL means the create carried no\n // key (each such create is independent). When set, the partial unique index\n // below collapses concurrent/retried creates with the same key in the same\n // workspace to a single session row — the dedup that closes the\n // double-submit/double-dispatch stuck-queued bug.\n createIdempotencyKey: text(\"create_idempotency_key\"),\n temporalWorkflowId: text(\"temporal_workflow_id\"),\n activeTurnId: uuid(\"active_turn_id\"),\n // Actual input tokens reported for the last model call of the most recent\n // turn. The pre-turn client-side compaction trigger reads this as its budget\n // signal (char/4 estimate is the same-turn fallback). Null until a turn with\n // usage has completed.\n lastInputTokens: integer(\"last_input_tokens\"),\n // Operator /compact request flag (client-side compaction path). The API sets\n // it true; the worker honors it BEFORE the next turn's model call by forcing\n // a compaction, then clears it. A durable flag (not a transient signal) so\n // the trigger survives a worker restart and converges before the next turn.\n compactRequested: boolean(\"compact_requested\").notNull().default(false),\n lastSequence: integer(\"last_sequence\").notNull().default(0),\n // The session's PINNED Codex account (manual override from the in-session\n // switcher). NULL ⇒ follow the workspace active pointer. FK declared in the\n // migration with ON DELETE SET NULL (a disconnected pin degrades to \"follow\n // active\", never dangles), same pattern as activeSandboxId.\n codexPinnedCredentialId: uuid(\"codex_pinned_credential_id\"),\n // The Codex account the session's most recent turn ACTUALLY ran on — drives\n // the \"Running on:\" indicator. Written by the worker at the turn boundary. FK\n // ON DELETE SET NULL (migration).\n codexLastCredentialId: uuid(\"codex_last_credential_id\"),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n workspaceCreated: index(\"sessions_workspace_created_idx\").on(table.workspaceId, table.createdAt),\n environment: index(\"sessions_environment_idx\").on(table.workspaceId, table.environmentId),\n parent: index(\"sessions_parent_idx\").on(table.workspaceId, table.parentSessionId),\n // Routing index: resolve session_id -> sandbox_group_id at every lease entry\n // point and enumerate all sessions in a group for attribution/disclosure.\n sandboxGroup: index(\"sessions_sandbox_group_idx\").on(table.workspaceId, table.sandboxGroupId),\n // Partial unique index: one session per (workspace, create_idempotency_key)\n // when a key is present. Concurrent creates racing on the same key see a\n // unique violation on all but one; the domain layer catches it and returns\n // the winning row instead of erroring.\n createIdempotency: uniqueIndex(\"sessions_workspace_create_idempotency_idx\").on(table.workspaceId, table.createIdempotencyKey).where(sql`${table.createIdempotencyKey} is not null`),\n}));\n\nexport const sessionMcpServers = pgTable(\"session_mcp_servers\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n sessionId: uuid(\"session_id\").notNull().references(() => sessions.id, { onDelete: \"cascade\" }),\n serverId: text(\"server_id\").notNull(),\n name: text(\"name\"),\n url: text(\"url\").notNull(),\n allowedTools: jsonb(\"allowed_tools\").$type<string[]>(),\n timeoutMs: integer(\"timeout_ms\"),\n cacheToolsList: boolean(\"cache_tools_list\").notNull().default(false),\n // Map of header name -> AES-GCM ciphertext. Values are decrypted only by the\n // worker's run-preparation path and never returned by API helpers.\n headersEncrypted: jsonb(\"headers_encrypted\").$type<Record<string, string>>().notNull().default({}),\n credentialVersion: integer(\"credential_version\").notNull().default(1),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n sessionServer: uniqueIndex(\"session_mcp_servers_session_server_idx\").on(table.workspaceId, table.sessionId, table.serverId),\n session: index(\"session_mcp_servers_session_idx\").on(table.workspaceId, table.sessionId),\n}));\n\nexport const files = pgTable(\"files\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n status: text(\"status\").notNull().default(\"pending_upload\"),\n filename: text(\"filename\").notNull(),\n safeFilename: text(\"safe_filename\").notNull(),\n contentType: text(\"content_type\").notNull(),\n sizeBytes: bigint(\"size_bytes\", { mode: \"number\" }).notNull(),\n sha256: text(\"sha256\"),\n bucket: text(\"bucket\").notNull(),\n objectKey: text(\"object_key\").notNull(),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n workspaceCreated: index(\"files_workspace_created_idx\").on(table.workspaceId, table.createdAt),\n objectKey: uniqueIndex(\"files_object_key_idx\").on(table.objectKey),\n status: index(\"files_status_idx\").on(table.status),\n}));\n\nexport const fileUploads = pgTable(\"file_uploads\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n fileId: uuid(\"file_id\").notNull().references(() => files.id, { onDelete: \"cascade\" }),\n status: text(\"status\").notNull().default(\"pending\"),\n expiresAt: timestamp(\"expires_at\", { withTimezone: true }).notNull(),\n completedAt: timestamp(\"completed_at\", { withTimezone: true }),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n workspace: index(\"file_uploads_workspace_idx\").on(table.workspaceId),\n fileId: index(\"file_uploads_file_id_idx\").on(table.fileId),\n status: index(\"file_uploads_status_idx\").on(table.status),\n}));\n\nexport const documentBases = pgTable(\"document_bases\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n name: text(\"name\").notNull(),\n description: text(\"description\"),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n workspaceCreated: index(\"document_bases_workspace_created_idx\").on(table.workspaceId, table.createdAt),\n}));\n\nexport const documents = pgTable(\"documents\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n baseId: uuid(\"base_id\").notNull().references(() => documentBases.id, { onDelete: \"cascade\" }),\n fileId: uuid(\"file_id\").notNull().references(() => files.id, { onDelete: \"restrict\" }),\n status: text(\"status\").notNull().default(\"queued\"),\n title: text(\"title\").notNull(),\n parser: text(\"parser\").notNull().default(\"liteparse\"),\n chunkCount: integer(\"chunk_count\").notNull().default(0),\n error: text(\"error\"),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n baseFile: uniqueIndex(\"documents_workspace_base_file_idx\").on(table.workspaceId, table.baseId, table.fileId),\n baseStatus: index(\"documents_workspace_base_status_idx\").on(table.workspaceId, table.baseId, table.status),\n}));\n\nexport const documentChunks = pgTable(\"document_chunks\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n documentId: uuid(\"document_id\").notNull().references(() => documents.id, { onDelete: \"cascade\" }),\n baseId: uuid(\"base_id\").notNull().references(() => documentBases.id, { onDelete: \"cascade\" }),\n fileId: uuid(\"file_id\").notNull().references(() => files.id, { onDelete: \"restrict\" }),\n chunkIndex: integer(\"chunk_index\").notNull(),\n text: text(\"text\").notNull(),\n metadata: jsonb(\"metadata\").$type<Record<string, unknown>>().notNull().default({}),\n embedding: vector(\"embedding\").notNull(),\n embeddingModel: text(\"embedding_model\").notNull(),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n documentIndex: uniqueIndex(\"document_chunks_workspace_document_index_idx\").on(table.workspaceId, table.documentId, table.chunkIndex),\n base: index(\"document_chunks_workspace_base_idx\").on(table.workspaceId, table.baseId),\n}));\n\nexport const sessionTurns = pgTable(\"session_turns\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n sessionId: uuid(\"session_id\").notNull().references(() => sessions.id, { onDelete: \"cascade\" }),\n triggerEventId: uuid(\"trigger_event_id\").notNull(),\n temporalWorkflowId: text(\"temporal_workflow_id\").notNull(),\n status: text(\"status\").notNull(),\n source: text(\"source\").notNull().default(\"user\"),\n position: integer(\"position\").notNull(),\n prompt: text(\"prompt\").notNull(),\n resources: jsonb(\"resources\").$type<unknown[]>().notNull().default([]),\n tools: jsonb(\"tools\").$type<unknown[]>().notNull().default([]),\n model: text(\"model\").notNull(),\n reasoningEffort: text(\"reasoning_effort\").notNull(),\n sandboxBackend: text(\"sandbox_backend\").notNull(),\n // Per-turn OS override. NULL = inherit the session's sandbox_os. CHECK-\n // constrained to the SandboxOs enum (or NULL) in migration 0018.\n sandboxOs: text(\"sandbox_os\"),\n metadata: jsonb(\"metadata\").$type<Record<string, unknown>>().notNull().default({}),\n startedAt: timestamp(\"started_at\", { withTimezone: true }),\n finishedAt: timestamp(\"finished_at\", { withTimezone: true }),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n queue: index(\"session_turns_workspace_queue_idx\").on(table.workspaceId, table.sessionId, table.status, table.position),\n}));\n\nexport const sessionGoals = pgTable(\"session_goals\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n sessionId: uuid(\"session_id\").notNull().references(() => sessions.id, { onDelete: \"cascade\" }),\n status: text(\"status\").notNull().default(\"active\"), // active | paused | completed\n text: text(\"text\").notNull(),\n successCriteria: text(\"success_criteria\"),\n evidence: text(\"evidence\"), // set by goal_complete\n rationale: text(\"rationale\"), // set by goal_pause\n pausedReason: text(\"paused_reason\"), // agent | user_interrupt | api | no_progress | max_auto_continuations | limits\n createdBy: text(\"created_by\").notNull().default(\"api\"), // api | agent | scheduled_task\n version: integer(\"version\").notNull().default(1), // bumped on every set/update; progress signal\n autoContinuations: integer(\"auto_continuations\").notNull().default(0),\n noProgressStreak: integer(\"no_progress_streak\").notNull().default(0),\n maxAutoContinuations: integer(\"max_auto_continuations\"), // per-goal override; a configured settings cap (if any) remains the hard ceiling\n lastContinuationTurnId: uuid(\"last_continuation_turn_id\"),\n versionAtLastContinuation: integer(\"version_at_last_continuation\"),\n metadata: jsonb(\"metadata\").$type<Record<string, unknown>>().notNull().default({}),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n workspaceSession: uniqueIndex(\"session_goals_workspace_session_idx\").on(table.workspaceId, table.sessionId),\n status: index(\"session_goals_workspace_status_idx\").on(table.workspaceId, table.status),\n}));\n\nexport const sessionEvents = pgTable(\"session_events\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n sessionId: uuid(\"session_id\").notNull().references(() => sessions.id, { onDelete: \"cascade\" }),\n turnId: uuid(\"turn_id\"),\n sequence: integer(\"sequence\").notNull(),\n type: text(\"type\").notNull(),\n payload: jsonb(\"payload\").$type<unknown>().notNull().default({}),\n clientEventId: text(\"client_event_id\"),\n producerId: text(\"producer_id\"),\n producerSeq: integer(\"producer_seq\"),\n occurredAt: timestamp(\"occurred_at\", { withTimezone: true }).notNull().defaultNow(),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n sessionSequence: uniqueIndex(\"session_events_workspace_session_sequence_idx\").on(table.workspaceId, table.sessionId, table.sequence),\n clientEvent: uniqueIndex(\"session_events_workspace_client_event_idx\").on(table.workspaceId, table.sessionId, table.clientEventId).where(sql`${table.clientEventId} is not null`),\n producer: uniqueIndex(\"session_events_workspace_producer_idx\").on(table.workspaceId, table.sessionId, table.producerId, table.producerSeq).where(sql`${table.producerId} is not null and ${table.producerSeq} is not null`),\n sessionCreated: index(\"session_events_workspace_session_created_idx\").on(table.workspaceId, table.sessionId, table.createdAt),\n}));\n\nexport const agentRunStates = pgTable(\"agent_run_states\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n sessionId: uuid(\"session_id\").notNull().references(() => sessions.id, { onDelete: \"cascade\" }),\n turnId: uuid(\"turn_id\").references(() => sessionTurns.id, { onDelete: \"set null\" }),\n stateVersion: integer(\"state_version\").notNull(),\n serializedRunState: text(\"serialized_run_state\").notNull(),\n pendingApprovals: jsonb(\"pending_approvals\").$type<unknown[]>().notNull().default([]),\n // The Codex account that FROZE this run state: the turn's resolved codex\n // credential id (pin > workspace-active), or NULL when frozen on the\n // non-codex / Azure path (or before this column existed). The serialized\n // RunState blob round-trips `reasoning.encrypted_content` minted by the\n // ChatGPT/Codex backend — account/org-bound, so a foreign blob 400s — and the\n // foreign reasoning ids the Responses backend validates; but the blob carries\n // NO per-item producer tag (those live only on session_history_items). So we\n // stamp the freezing account here: on a resume (approval decision, or the\n // items-mode run-state fallback) whose codex account DIFFERS from this value,\n // the replay path neutralizes every reasoning item's account-bound identity\n // (encrypted_content + provider id) in the blob before it reaches the model.\n // Deliberately NO FK: provenance must OUTLIVE the account's hard-disconnect (a\n // stale-but-null tag still mismatches a live codex id, so the strip stays\n // correct either way). NULL on both sides (non-codex freeze + non-codex\n // resume) is a no-op, so single-account and non-codex sessions are unchanged.\n frozenCodexCredentialId: uuid(\"frozen_codex_credential_id\"),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n});\n\n// Conversation truth: ordered, verbatim SDK input items (issue #35). The\n// model-facing memory store — unredacted and replay-ready. session_events\n// remains the redacted human/audit timeline.\nexport const sessionHistoryItems = pgTable(\"session_history_items\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n sessionId: uuid(\"session_id\").notNull().references(() => sessions.id, { onDelete: \"cascade\" }),\n turnId: uuid(\"turn_id\").references(() => sessionTurns.id, { onDelete: \"set null\" }),\n // Numeric (not integer) so the synthetic compaction-summary row can be\n // inserted at a FRACTIONAL position (boundaryPosition - 0.5) that sorts ahead\n // of the kept tail without colliding with — and thus overwriting — the real\n // prefix row at boundaryPosition - 1. Normally-appended rows keep whole-number\n // positions; only the summary uses the half-step. `mode: \"number\"` maps the\n // postgres.js string back to a JS number so every reader stays numeric.\n position: numeric(\"position\", { mode: \"number\" }).notNull(),\n item: jsonb(\"item\").$type<Record<string, unknown>>().notNull(),\n // Live-row flag for client-side context compaction. The read path selects\n // only active rows; a compaction supersedes the summarized prefix (sets this\n // false — never deletes, so the full transcript stays as an audit trail) and\n // inserts ONE synthetic active summary row at the boundary. Defaults true so\n // every existing and normally-appended row is live.\n active: boolean(\"active\").notNull().default(true),\n // The Codex account that PRODUCED these items: the per-turn resolved codex\n // credential id (pin > workspace-active), or NULL when produced on the\n // non-codex / Azure path (or before this column existed). Used to strip\n // cross-account `reasoning.encrypted_content` blobs — those are account/org-\n // bound, minted by the ChatGPT/Codex backend, so replaying account A's blob\n // into a turn running on account B 400s. The read path drops the encrypted\n // reasoning of any item whose producer != the turn's current codex account.\n // Deliberately NO FK: provenance must OUTLIVE the account's hard-disconnect\n // (an ON DELETE SET NULL would erase the tag, and a stale-but-null tag still\n // mismatches a live codex id so the strip stays correct either way).\n producerCodexCredentialId: uuid(\"producer_codex_credential_id\"),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n positionIdx: uniqueIndex(\"session_history_items_position_idx\").on(table.workspaceId, table.sessionId, table.position),\n}));\n\n// Sandbox recovery descriptor, decoupled from the RunState blob: the small\n// versioned envelope (provider handle / snapshot ref / manifest) needed to\n// reattach, restore, or rebuild the session's sandbox on its next turn.\nexport const sandboxSessionEnvelopes = pgTable(\"sandbox_session_envelopes\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n sessionId: uuid(\"session_id\").notNull().references(() => sessions.id, { onDelete: \"cascade\" }),\n envelope: jsonb(\"envelope\").$type<Record<string, unknown>>().notNull(),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n sessionIdx: uniqueIndex(\"sandbox_session_envelopes_session_idx\").on(table.workspaceId, table.sessionId),\n}));\n\n// The 4 liveness states of the singleton lease. Exported so the query layer and\n// the stateless resume-by-id path share one source of truth for the domain.\nexport const sandboxLeaseLivenessValues = [\"cold\", \"warming\", \"warm\", \"draining\"] as const;\n\n// One row per GROUP: the SOLE enforcer of the strict-singleton-box invariant.\n// uniqueIndex(workspaceId, sandboxGroupId) + SELECT…FOR UPDATE + cold->warming\n// CAS + integer lease_epoch fence. Re-keyed to sandboxGroupId from the start\n// (addendum B.2) so today's 1:1 world (sandboxGroupId == session id, set in\n// 0018) is a behavior-preserving no-op. Mirrors the account/workspace FK chain\n// of sandboxSessionEnvelopes; sandboxGroupId is a BARE uuid (NOT an FK — the\n// value is a session id or an ancestor's, and an FK would let a founder's\n// deletion cascade-kill a box still in use by a spawned session).\nexport const sandboxLeases = pgTable(\"sandbox_leases\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n sandboxGroupId: uuid(\"sandbox_group_id\").notNull(),\n\n liveness: text(\"liveness\", { enum: sandboxLeaseLivenessValues }).notNull().default(\"cold\"),\n refcount: integer(\"refcount\").notNull().default(0),\n turnHolders: integer(\"turn_holders\").notNull().default(0),\n viewerHolders: integer(\"viewer_holders\").notNull().default(0),\n\n instanceId: text(\"instance_id\"),\n backend: text(\"backend\").notNull(),\n os: text(\"os\").notNull().default(\"linux\"),\n // The container IMAGE the group box runs (Modal image ref / docker image). A shared\n // box is SHARED STATE: all its sessions run the SAME filesystem, so they must run the\n // same image. This column stamps the image the live box was created with; a resume\n // whose resolved image DIFFERS is a conflict (B3): a solo holder recreates the box on\n // the new image, N-holders are rejected (SandboxImageConflictError). Nullable — a\n // legacy/cold row reads NULL = \"image unknown\", which never conflicts.\n image: text(\"image\"),\n dataPlaneUrl: text(\"data_plane_url\"),\n // The REAL PTY terminal (ttyd pty-ws) rides a SEPARATE provider tunnel (7681)\n // from the desktop noVNC (6080), so its resolved URL is cached independently.\n // Recorded under the epoch fence by recordLeaseTerminalDataPlaneUrl; reset to\n // null on every box re-key (warm-commit / fail / drain), symmetric with\n // data_plane_url.\n terminalDataPlaneUrl: text(\"terminal_data_plane_url\"),\n\n // integer (NOT bigint): the lease-epoch spike proved a raw int8 read returns a\n // JS STRING from postgres-js, breaking the strict epoch-fence comparison (it\n // was always-true → every turn fenced); int4 returns a JS number, the fix.\n // Epochs never approach 2^31, so the narrower type loses nothing.\n leaseEpoch: integer(\"lease_epoch\").notNull().default(0),\n\n // The group box-envelope (the \"envelope split\" Critical): the small recovery\n // descriptor to resume()-by-id the group's box without a per-session join.\n resumeBackendId: text(\"resume_backend_id\"),\n resumeState: jsonb(\"resume_state\").$type<Record<string, unknown>>(),\n\n // Warm-time billing cursor: last_meter_at = accrual cursor; last_meter_tick =\n // idempotency tick (warm_seconds accrued idempotent on\n // (sandbox_group_id, lease_epoch, last_meter_tick) in P2.1).\n lastMeterAt: timestamp(\"last_meter_at\", { withTimezone: true }),\n lastMeterTick: integer(\"last_meter_tick\").notNull().default(0),\n\n expiresAt: timestamp(\"expires_at\", { withTimezone: true }).notNull(),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n groupIdx: uniqueIndex(\"sandbox_leases_group_idx\").on(table.workspaceId, table.sandboxGroupId),\n reaperIdx: index(\"sandbox_leases_reaper_idx\").on(table.expiresAt)\n .where(sql`${table.liveness} in ('warming','warm','draining')`),\n}));\n\n// N rows per group: one per live holder. Makes release idempotent\n// (delete-my-row, never blind decrement) and lets the reaper recompute refcount.\nexport const sandboxLeaseHolders = pgTable(\"sandbox_lease_holders\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n leaseId: uuid(\"lease_id\").notNull().references(() => sandboxLeases.id, { onDelete: \"cascade\" }),\n kind: text(\"kind\", { enum: [\"turn\", \"viewer\"] }).notNull(),\n holderId: text(\"holder_id\").notNull(),\n // The attributing session within the (possibly shared) group.\n subjectId: uuid(\"subject_id\"),\n lastHeartbeatAt: timestamp(\"last_heartbeat_at\", { withTimezone: true }).notNull().defaultNow(),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n holderIdx: uniqueIndex(\"sandbox_lease_holders_holder_idx\").on(table.leaseId, table.kind, table.holderId),\n staleIdx: index(\"sandbox_lease_holders_stale_idx\").on(table.kind, table.lastHeartbeatAt),\n leaseIdx: index(\"sandbox_lease_holders_lease_idx\").on(table.leaseId),\n}));\n\n// The recording lifecycle states (P4.3). Exported so the activity + the query\n// layer share one source of truth for the §3.1 state machine.\nexport const sessionRecordingStateValues = [\"recording\", \"finalizing\", \"available\", \"failed\"] as const;\nexport const sessionRecordingModeValues = [\"manual\", \"on-turn\", \"on-verify\"] as const;\nexport const sessionRecordingCodecValues = [\"h264-mp4\", \"vp9-webm\"] as const;\n\n// One row per recording — the durable index for the \"agent films itself proving\n// the fix\" loop. ffmpeg x11grab of the SAME :0 humans watch, finalized by\n// reading the bytes off the box and PUTting them to @opengeni/storage in the\n// process that holds the resumed-by-id handle (never a Temporal payload, F10).\n// Mirrors the account/workspace/session FK chain of sandboxSessionEnvelopes;\n// turnId is ON DELETE SET NULL (a deleted turn must not kill the artifact row).\nexport const sessionRecordings = pgTable(\"session_recordings\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n sessionId: uuid(\"session_id\").notNull().references(() => sessions.id, { onDelete: \"cascade\" }),\n turnId: uuid(\"turn_id\").references(() => sessionTurns.id, { onDelete: \"set null\" }),\n\n state: text(\"state\", { enum: sessionRecordingStateValues }).notNull(),\n mode: text(\"mode\", { enum: sessionRecordingModeValues }).notNull(),\n codec: text(\"codec\", { enum: sessionRecordingCodecValues }).notNull(),\n\n storageKey: text(\"storage_key\"),\n sizeBytes: bigint(\"size_bytes\", { mode: \"number\" }),\n durationSeconds: numeric(\"duration_seconds\").$type<number>(),\n\n width: integer(\"width\").notNull(),\n height: integer(\"height\").notNull(),\n\n reason: text(\"reason\"),\n\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n finalizedAt: timestamp(\"finalized_at\", { withTimezone: true }),\n}, (table) => ({\n sessionIdx: index(\"session_recordings_session_idx\").on(table.workspaceId, table.sessionId, table.createdAt),\n}));\n\n// Channel-A interactive PTY sessions (P4.4 / modules/08-channel-a.md §3.1). The\n// ONLY new persistent state Channel A needs — FS/Git reads are stateless point\n// queries; an interactive PTY is a live in-box process keyed by the SDK's numeric\n// exec-session id (writeStdin({sessionId})). We map our UUID ptyId <-> that id,\n// the owning workspace/session, the lease_epoch that fences it to the box it was\n// opened on (a box re-key strands the PTY -> reaped with reason owner_gone), and\n// a last_input_at heartbeat so the reaper can kill idle/orphaned PTYs. Mirrors\n// the account/workspace/session FK chain of sandboxSessionEnvelopes.\nexport const sandboxPtySessions = pgTable(\"sandbox_pty_sessions\", {\n id: uuid(\"id\").primaryKey().defaultRandom(), // == ptyId on the wire\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n sessionId: uuid(\"session_id\").notNull().references(() => sessions.id, { onDelete: \"cascade\" }),\n // The SDK numeric exec-session id used by writeStdin({ sessionId }). Null until\n // the open exec yields a still-running process (a fast-exiting shell has none).\n execSessionId: integer(\"exec_session_id\"),\n leaseEpoch: integer(\"lease_epoch\").notNull(), // fenced to the box that opened it\n cols: integer(\"cols\").notNull(),\n rows: integer(\"rows\").notNull(),\n shell: text(\"shell\").notNull(),\n cwd: text(\"cwd\").notNull(),\n status: text(\"status\").notNull().default(\"open\"), // 'open' | 'closed'\n // The viewer grant/subject that opened it (free-text — access subjects are not\n // always UUIDs, M5; so a text column, never a uuid NOT NULL).\n openedBy: text(\"opened_by\").notNull(),\n lastInputAt: timestamp(\"last_input_at\", { withTimezone: true }).notNull().defaultNow(),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n closedAt: timestamp(\"closed_at\", { withTimezone: true }),\n}, (table) => ({\n openIdx: index(\"sandbox_pty_sessions_session_idx\")\n .on(table.workspaceId, table.sessionId)\n .where(sql`${table.status} = 'open'`),\n}));\n\n// ============================================================================\n// Bring-your-own-compute (M2): first-class swappable sandboxes + enrollment +\n// metrics (migration 0024 / dossier §10.3 + §10.7 + §23). The session→box\n// binding becomes a per-session mutable, epoch-fenced active_sandbox_id pointer\n// (declared on sessions above) that the routing proxy resolves PER TOOL CALL.\n\n// The lifecycle/enum domains, exported so the query layer + the migration share\n// ONE source of truth for each CHECK.\nexport const enrollmentExposureValues = [\"whole-machine\"] as const;\nexport const enrollmentStatusValues = [\"active\", \"revoked\"] as const;\nexport const enrollmentOsValues = [\"linux\", \"macos\", \"windows\"] as const;\nexport const sandboxKindValues = [\"modal\", \"selfhosted\"] as const;\n\n// One row per registered machine. The agent's ed25519 PUBLIC key IS the machine\n// identity (the NATS control-plane subject the agent subscribes to maps to it).\n// exposure is the loudly-consented access mode; has_display/allow_screen_control\n// are the desktop/computer-use consent bits (default false — opt-in). status is\n// the active|revoked lifecycle; last_seen_at the heartbeat liveness cursor the\n// Machines dashboard renders online/reconnecting/offline from.\nexport const enrollments = pgTable(\"enrollments\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n // The agent's ed25519 public key (the machine identity).\n pubkey: text(\"pubkey\").notNull(),\n exposure: text(\"exposure\", { enum: enrollmentExposureValues }).notNull().default(\"whole-machine\"),\n hasDisplay: boolean(\"has_display\").notNull().default(false),\n allowScreenControl: boolean(\"allow_screen_control\").notNull().default(false),\n status: text(\"status\", { enum: enrollmentStatusValues }).notNull().default(\"active\"),\n os: text(\"os\", { enum: enrollmentOsValues }).notNull().default(\"linux\"),\n arch: text(\"arch\").notNull().default(\"x86_64\"),\n // Heartbeat liveness cursor. Null until the first connect.\n lastSeenAt: timestamp(\"last_seen_at\", { withTimezone: true }),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n revokedAt: timestamp(\"revoked_at\", { withTimezone: true }),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n // One enrollment per (workspace, pubkey): a re-enroll is an idempotent upsert.\n workspacePubkey: uniqueIndex(\"enrollments_workspace_pubkey_idx\").on(table.workspaceId, table.pubkey),\n // List a workspace's ACTIVE machines without scanning revoked rows.\n workspaceStatus: index(\"enrollments_workspace_status_idx\").on(table.workspaceId, table.status),\n}));\n\n// The OAuth 2.0 device-authorization (RFC 8628) PENDING request (M5, migration\n// 0025 / dossier §10.2 enrollment + §18 LOUD consent). An agent's `enroll` starts\n// a flow (POST /enrollments/device/start) → one short-TTL, single-use row keyed by\n// an opaque `device_code` (the agent polls with) + a short `user_code` (the user\n// types at the approve page). The user (workspace-membership / workspace:admin\n// gated) approves it (POST /enrollments/device/approve), which records WHO\n// (subject + label) consented WHEN (approved_at) to WHAT (whole-machine mandatory +\n// screen-control per allow_screen_control) and stamps the resulting enrollment_id /\n// sandbox_id. The agent then polls (POST /enrollments/device/poll) and the approved\n// row yields the EnrollmentCredentials. State machine: pending → approved | denied;\n// a pending row past expires_at is EXPIRED; once the agent has polled an approved\n// row its credentials, the row flips to consumed (single-use). NOT a long-lived\n// record — a retention sweep prunes terminal rows; the durable identity is the\n// `enrollments` row the approve produced.\nexport const deviceEnrollmentStatusValues = [\"pending\", \"approved\", \"denied\", \"consumed\"] as const;\n\nexport const deviceEnrollmentRequests = pgTable(\"device_enrollment_requests\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n // The opaque code the agent polls with (unguessable, single-use). Unique.\n deviceCode: text(\"device_code\").notNull(),\n // The short human-typed code (e.g. \"WDJB-MJHT\"). Unique among LIVE (pending)\n // rows via a partial unique index so a recycled code never collides with a\n // terminal row.\n userCode: text(\"user_code\").notNull(),\n // The workspace this request was started for (resolved from the deployment-edge\n // request context — the agent presents the access key, the flow binds to the\n // single managed workspace OR a workspace hint). account_id rides along for RLS.\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n // The agent's ed25519 public key (the machine identity the enrollment binds to).\n pubkey: text(\"pubkey\").notNull(),\n os: text(\"os\", { enum: enrollmentOsValues }).notNull().default(\"linux\"),\n arch: text(\"arch\").notNull().default(\"x86_64\"),\n machineName: text(\"machine_name\"),\n // The exposure the agent REQUESTED (whole-machine in v1; loudly consented at\n // approve). Mirrors the enrollment column domain.\n requestedExposure: text(\"requested_exposure\", { enum: enrollmentExposureValues }).notNull().default(\"whole-machine\"),\n // The agent CAN offer a display (a real screen / Xvfb is available) — gates\n // whether screen-control consent is even meaningful. has_display on the\n // resulting enrollment is derived from this.\n canOfferDisplay: boolean(\"can_offer_display\").notNull().default(false),\n // The agent REQUESTS screen control (computer-use). The user's allow_screen_control\n // at approve is the AUTHORITATIVE consent; this is only the agent's request.\n requestsScreenControl: boolean(\"requests_screen_control\").notNull().default(false),\n status: text(\"status\", { enum: deviceEnrollmentStatusValues }).notNull().default(\"pending\"),\n // ── LOUD CONSENT capture (who/when/what), stamped at approve ──────────────\n approvedBySubjectId: text(\"approved_by_subject_id\"),\n approvedBySubjectLabel: text(\"approved_by_subject_label\"),\n // The user's screen-control consent decision (whole-machine is mandatory at\n // approve; screen-control is opt-in per this flag).\n allowScreenControl: boolean(\"allow_screen_control\").notNull().default(false),\n approvedAt: timestamp(\"approved_at\", { withTimezone: true }),\n // The enrollment + sandbox the approve produced (acceptance #2: an enrollment\n // row AND a sandbox row appear). Null until approved.\n enrollmentId: uuid(\"enrollment_id\").references(() => enrollments.id, { onDelete: \"set null\" }),\n sandboxId: uuid(\"sandbox_id\").references(() => sandboxes.id, { onDelete: \"set null\" }),\n // The short-TTL expiry; a pending row past this is EXPIRED on poll.\n expiresAt: timestamp(\"expires_at\", { withTimezone: true }).notNull(),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n // The device_code is the agent's poll key — globally unique + indexed.\n deviceCode: uniqueIndex(\"device_enrollment_requests_device_code_idx\").on(table.deviceCode),\n // The user_code must be unique among LIVE (pending) rows so the approve lookup\n // is unambiguous; a terminal row's code may be recycled.\n userCodePending: uniqueIndex(\"device_enrollment_requests_user_code_pending_idx\")\n .on(table.userCode)\n .where(sql`${table.status} = 'pending'`),\n workspaceCreated: index(\"device_enrollment_requests_workspace_created_idx\").on(table.workspaceId, table.createdAt),\n expires: index(\"device_enrollment_requests_expires_idx\").on(table.expiresAt),\n}));\n\n// The first-class NAMED sandbox a session's active_sandbox_id points AT. kind\n// discriminates the backend the routing proxy resolves to: 'modal' (cloud box,\n// NULL enrollment_id) or 'selfhosted' (a user's machine, enrollment_id -> the\n// enrollment it lives on). The selfhosted-needs-enrollment invariant is pinned by\n// the sandboxes_selfhosted_enrollment_chk CHECK in migration 0024. enrollment_id\n// is ON DELETE SET NULL so deleting an enrollment never cascade-kills a sandbox a\n// session might still point at (the routing layer surfaces agent_offline instead).\nexport const sandboxes = pgTable(\"sandboxes\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n kind: text(\"kind\", { enum: sandboxKindValues }).notNull(),\n name: text(\"name\").notNull(),\n enrollmentId: uuid(\"enrollment_id\").references(() => enrollments.id, { onDelete: \"set null\" }),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n workspaceCreated: index(\"sandboxes_workspace_created_idx\").on(table.workspaceId, table.createdAt),\n enrollment: index(\"sandboxes_enrollment_idx\").on(table.enrollmentId).where(sql`${table.enrollmentId} is not null`),\n}));\n\n// Last-sample upsert: ONE row per enrollment, overwritten on every sample (the\n// PK on enrollment_id is the ON CONFLICT target). The §10.7 signals; nullable\n// where a platform/sample may not provide it (no GPU, headless).\nexport const machineMetricsLatest = pgTable(\"machine_metrics_latest\", {\n enrollmentId: uuid(\"enrollment_id\").primaryKey().references(() => enrollments.id, { onDelete: \"cascade\" }),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n cpuPercent: numeric(\"cpu_percent\").$type<number>(),\n load1: numeric(\"load1\").$type<number>(),\n load5: numeric(\"load5\").$type<number>(),\n load15: numeric(\"load15\").$type<number>(),\n memUsedBytes: bigint(\"mem_used_bytes\", { mode: \"number\" }),\n memTotalBytes: bigint(\"mem_total_bytes\", { mode: \"number\" }),\n diskUsedBytes: bigint(\"disk_used_bytes\", { mode: \"number\" }),\n diskTotalBytes: bigint(\"disk_total_bytes\", { mode: \"number\" }),\n gpuUtilPercent: numeric(\"gpu_util_percent\").$type<number>(),\n gpuMemUsedBytes: bigint(\"gpu_mem_used_bytes\", { mode: \"number\" }),\n gpuMemTotalBytes: bigint(\"gpu_mem_total_bytes\", { mode: \"number\" }),\n contention: numeric(\"contention\").$type<number>(),\n sampledAt: timestamp(\"sampled_at\", { withTimezone: true }).notNull(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n workspace: index(\"machine_metrics_latest_workspace_idx\").on(table.workspaceId),\n}));\n\n// Append-only downsampled history (~1/min per enrollment, retained N days). Same\n// signal columns as _latest. The (enrollment_id, sampled_at) index serves the\n// dashboard time-range read AND the (later) retention sweep.\nexport const machineMetricsSeries = pgTable(\"machine_metrics_series\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n enrollmentId: uuid(\"enrollment_id\").notNull().references(() => enrollments.id, { onDelete: \"cascade\" }),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n cpuPercent: numeric(\"cpu_percent\").$type<number>(),\n load1: numeric(\"load1\").$type<number>(),\n load5: numeric(\"load5\").$type<number>(),\n load15: numeric(\"load15\").$type<number>(),\n memUsedBytes: bigint(\"mem_used_bytes\", { mode: \"number\" }),\n memTotalBytes: bigint(\"mem_total_bytes\", { mode: \"number\" }),\n diskUsedBytes: bigint(\"disk_used_bytes\", { mode: \"number\" }),\n diskTotalBytes: bigint(\"disk_total_bytes\", { mode: \"number\" }),\n gpuUtilPercent: numeric(\"gpu_util_percent\").$type<number>(),\n gpuMemUsedBytes: bigint(\"gpu_mem_used_bytes\", { mode: \"number\" }),\n gpuMemTotalBytes: bigint(\"gpu_mem_total_bytes\", { mode: \"number\" }),\n contention: numeric(\"contention\").$type<number>(),\n sampledAt: timestamp(\"sampled_at\", { withTimezone: true }).notNull(),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n enrollmentSampled: index(\"machine_metrics_series_enrollment_sampled_idx\").on(table.enrollmentId, table.sampledAt),\n sampled: index(\"machine_metrics_series_sampled_idx\").on(table.sampledAt),\n}));\n\nexport const scheduledTasks = pgTable(\"scheduled_tasks\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n name: text(\"name\").notNull(),\n status: text(\"status\").notNull().default(\"active\"),\n schedule: jsonb(\"schedule\").$type<unknown>().notNull(),\n temporalScheduleId: text(\"temporal_schedule_id\").notNull(),\n runMode: text(\"run_mode\").notNull().default(\"new_session_per_run\"),\n overlapPolicy: text(\"overlap_policy\").notNull().default(\"allow_concurrent\"),\n agentConfig: jsonb(\"agent_config\").$type<unknown>().notNull(),\n reusableSessionId: uuid(\"reusable_session_id\").references(() => sessions.id, { onDelete: \"set null\" }),\n environmentId: uuid(\"environment_id\").references(() => workspaceEnvironments.id, { onDelete: \"restrict\" }),\n metadata: jsonb(\"metadata\").$type<Record<string, unknown>>().notNull().default({}),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n temporalScheduleId: uniqueIndex(\"scheduled_tasks_workspace_temporal_schedule_id_idx\").on(table.workspaceId, table.temporalScheduleId),\n status: index(\"scheduled_tasks_workspace_status_idx\").on(table.workspaceId, table.status),\n environment: index(\"scheduled_tasks_environment_idx\").on(table.workspaceId, table.environmentId),\n}));\n\nexport const scheduledTaskRuns = pgTable(\"scheduled_task_runs\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n taskId: uuid(\"task_id\").notNull().references(() => scheduledTasks.id, { onDelete: \"cascade\" }),\n status: text(\"status\").notNull().default(\"queued\"),\n triggerType: text(\"trigger_type\").notNull(),\n scheduledAt: timestamp(\"scheduled_at\", { withTimezone: true }),\n firedAt: timestamp(\"fired_at\", { withTimezone: true }).notNull().defaultNow(),\n sessionId: uuid(\"session_id\").references(() => sessions.id, { onDelete: \"set null\" }),\n triggerEventId: uuid(\"trigger_event_id\"),\n error: text(\"error\"),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n taskCreated: index(\"scheduled_task_runs_workspace_task_created_idx\").on(table.workspaceId, table.taskId, table.createdAt),\n session: index(\"scheduled_task_runs_workspace_session_idx\").on(table.workspaceId, table.sessionId),\n}));\n\nexport const githubInstallations = pgTable(\"github_installations\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n installationId: integer(\"installation_id\").notNull(),\n accountLogin: text(\"account_login\"),\n accountType: text(\"account_type\"),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n workspaceInstallation: uniqueIndex(\"github_installations_workspace_installation_idx\").on(table.workspaceId, table.installationId),\n installation: index(\"github_installations_installation_idx\").on(table.installationId),\n workspace: index(\"github_installations_workspace_idx\").on(table.workspaceId),\n}));\n\nexport const usageEvents = pgTable(\"usage_events\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n subjectId: text(\"subject_id\"),\n eventType: text(\"event_type\").notNull(),\n quantity: bigint(\"quantity\", { mode: \"number\" }).notNull(),\n unit: text(\"unit\").notNull(),\n sourceResourceType: text(\"source_resource_type\"),\n sourceResourceId: text(\"source_resource_id\"),\n idempotencyKey: text(\"idempotency_key\").notNull(),\n occurredAt: timestamp(\"occurred_at\", { withTimezone: true }).notNull(),\n recordedAt: timestamp(\"recorded_at\", { withTimezone: true }).notNull().defaultNow(),\n exportedToBillingAt: timestamp(\"exported_to_billing_at\", { withTimezone: true }),\n billingProviderEventId: text(\"billing_provider_event_id\"),\n}, (table) => ({\n idempotency: uniqueIndex(\"usage_events_idempotency_idx\").on(table.idempotencyKey),\n workspaceMetric: index(\"usage_events_workspace_metric_idx\").on(table.workspaceId, table.eventType, table.occurredAt),\n accountMetric: index(\"usage_events_account_metric_idx\").on(table.accountId, table.eventType, table.occurredAt),\n}));\n\nexport const creditLedgerEntries = pgTable(\"credit_ledger_entries\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").references(() => workspaces.id, { onDelete: \"set null\" }),\n type: text(\"type\").notNull(),\n amountMicros: bigint(\"amount_micros\", { mode: \"number\" }).notNull(),\n currency: text(\"currency\").notNull().default(\"usd\"),\n sourceType: text(\"source_type\"),\n sourceId: text(\"source_id\"),\n idempotencyKey: text(\"idempotency_key\").notNull(),\n metadata: jsonb(\"metadata\").$type<Record<string, unknown>>().notNull().default({}),\n occurredAt: timestamp(\"occurred_at\", { withTimezone: true }).notNull().defaultNow(),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n idempotency: uniqueIndex(\"credit_ledger_entries_idempotency_idx\").on(table.idempotencyKey),\n accountCreated: index(\"credit_ledger_entries_account_created_idx\").on(table.accountId, table.createdAt),\n}));\n\nexport const billingCustomers = pgTable(\"billing_customers\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n provider: text(\"provider\").notNull().default(\"stripe\"),\n providerCustomerId: text(\"provider_customer_id\").notNull(),\n email: text(\"email\"),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n accountProvider: uniqueIndex(\"billing_customers_account_provider_idx\").on(table.accountId, table.provider),\n providerCustomer: uniqueIndex(\"billing_customers_provider_customer_idx\").on(table.provider, table.providerCustomerId),\n}));\n\nexport const stripeWebhookEvents = pgTable(\"stripe_webhook_events\", {\n id: text(\"id\").primaryKey(),\n type: text(\"type\").notNull(),\n livemode: text(\"livemode\").notNull().default(\"false\"),\n payload: jsonb(\"payload\").$type<unknown>().notNull(),\n processedAt: timestamp(\"processed_at\", { withTimezone: true }),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n});\n\nexport const auditEvents = pgTable(\"audit_events\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").references(() => managedAccounts.id, { onDelete: \"set null\" }),\n workspaceId: uuid(\"workspace_id\").references(() => workspaces.id, { onDelete: \"set null\" }),\n subjectId: text(\"subject_id\"),\n action: text(\"action\").notNull(),\n targetType: text(\"target_type\"),\n targetId: text(\"target_id\"),\n metadata: jsonb(\"metadata\").$type<Record<string, unknown>>().notNull().default({}),\n occurredAt: timestamp(\"occurred_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n accountCreated: index(\"audit_events_account_created_idx\").on(table.accountId, table.occurredAt),\n workspaceCreated: index(\"audit_events_workspace_created_idx\").on(table.workspaceId, table.occurredAt),\n}));\n\nexport const packInstallations = pgTable(\"pack_installations\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n packId: text(\"pack_id\").notNull(),\n status: text(\"status\").notNull().default(\"active\"),\n metadata: jsonb(\"metadata\").$type<Record<string, unknown>>().notNull().default({}),\n enabledAt: timestamp(\"enabled_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n workspacePack: uniqueIndex(\"pack_installations_workspace_pack_idx\").on(table.workspaceId, table.packId),\n status: index(\"pack_installations_workspace_status_idx\").on(table.workspaceId, table.status),\n}));\n\nexport const workspacePacks = pgTable(\"workspace_packs\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n packId: text(\"pack_id\").notNull(),\n manifest: jsonb(\"manifest\").$type<Record<string, unknown>>().notNull(),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n workspacePack: uniqueIndex(\"workspace_packs_workspace_pack_idx\").on(table.workspaceId, table.packId),\n}));\n\nexport const capabilityCatalogItems = pgTable(\"capability_catalog_items\", {\n id: text(\"id\").notNull(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n kind: text(\"kind\").notNull(),\n source: text(\"source\").notNull().default(\"manual\"),\n name: text(\"name\").notNull(),\n description: text(\"description\"),\n category: text(\"category\").notNull().default(\"custom\"),\n tags: jsonb(\"tags\").$type<string[]>().notNull().default([]),\n homepageUrl: text(\"homepage_url\"),\n endpointUrl: text(\"endpoint_url\"),\n installUrl: text(\"install_url\"),\n authModel: text(\"auth_model\"),\n metadata: jsonb(\"metadata\").$type<Record<string, unknown>>().notNull().default({}),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n workspaceCapability: uniqueIndex(\"capability_catalog_items_workspace_capability_idx\").on(table.workspaceId, table.id),\n kind: index(\"capability_catalog_items_workspace_kind_idx\").on(table.workspaceId, table.kind),\n category: index(\"capability_catalog_items_workspace_category_idx\").on(table.workspaceId, table.category),\n source: index(\"capability_catalog_items_workspace_source_idx\").on(table.workspaceId, table.source),\n}));\n\nexport const capabilityInstallations = pgTable(\"capability_installations\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n capabilityId: text(\"capability_id\").notNull(),\n kind: text(\"kind\").notNull(),\n status: text(\"status\").notNull().default(\"active\"),\n config: jsonb(\"config\").$type<Record<string, unknown>>().notNull().default({}),\n metadata: jsonb(\"metadata\").$type<Record<string, unknown>>().notNull().default({}),\n enabledAt: timestamp(\"enabled_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n workspaceCapability: uniqueIndex(\"capability_installations_workspace_capability_idx\").on(table.workspaceId, table.capabilityId),\n kind: index(\"capability_installations_workspace_kind_idx\").on(table.workspaceId, table.kind),\n status: index(\"capability_installations_workspace_status_idx\").on(table.workspaceId, table.status),\n}));\n\nexport const socialConnections = pgTable(\"social_connections\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n provider: text(\"provider\").notNull(),\n accountHandle: text(\"account_handle\").notNull(),\n accountName: text(\"account_name\"),\n externalAccountId: text(\"external_account_id\"),\n status: text(\"status\").notNull().default(\"connected\"),\n scopes: jsonb(\"scopes\").$type<string[]>().notNull().default([]),\n credentialRef: text(\"credential_ref\"),\n tokenMetadata: jsonb(\"token_metadata\").$type<Record<string, unknown>>().notNull().default({}),\n metadata: jsonb(\"metadata\").$type<Record<string, unknown>>().notNull().default({}),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n workspaceProviderHandle: uniqueIndex(\"social_connections_workspace_provider_handle_idx\").on(table.workspaceId, table.provider, table.accountHandle),\n providerStatus: index(\"social_connections_workspace_provider_status_idx\").on(table.workspaceId, table.provider, table.status),\n}));\n\nexport const socialPosts = pgTable(\"social_posts\", {\n id: uuid(\"id\").primaryKey().defaultRandom(),\n accountId: uuid(\"account_id\").notNull().references(() => managedAccounts.id, { onDelete: \"cascade\" }),\n workspaceId: uuid(\"workspace_id\").notNull().references(() => workspaces.id, { onDelete: \"cascade\" }),\n connectionId: uuid(\"connection_id\").notNull().references(() => socialConnections.id, { onDelete: \"cascade\" }),\n provider: text(\"provider\").notNull(),\n externalPostId: text(\"external_post_id\"),\n url: text(\"url\"),\n authorHandle: text(\"author_handle\"),\n text: text(\"text\").notNull(),\n publishedAt: timestamp(\"published_at\", { withTimezone: true }).notNull(),\n metrics: jsonb(\"metrics\").$type<Record<string, number>>().notNull().default({}),\n raw: jsonb(\"raw\").$type<Record<string, unknown>>().notNull().default({}),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n}, (table) => ({\n connectionExternalPost: uniqueIndex(\"social_posts_workspace_connection_external_post_idx\").on(table.workspaceId, table.connectionId, table.externalPostId),\n connectionPublished: index(\"social_posts_workspace_connection_published_idx\").on(table.workspaceId, table.connectionId, table.publishedAt),\n providerPublished: index(\"social_posts_workspace_provider_published_idx\").on(table.workspaceId, table.provider, table.publish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Ac,KAAK,eAAe;AAAA,EAClC,MAAM,KAAK,MAAM,EAAE,QAAQ;AAAA,EAC3B,aAAa,UAAU,gBAAgB,EAAE,cAAc,KAAK,CAAC,EAAE,QAAQ;AAAA,EACvE,SAAS,MAAM,SAAS,EAAE,MAA8B,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAAA,EAC9E,KAAK,MAAM,KAAK,EAAE,MAA+B,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAAA,EACvE,WAAW,UAAU,cAAc,EAAE,cAAc,KAAK,CAAC,EAAE,QAAQ,EAAE,WAAW;AAClF,GAAG,CAAC,WAAW;AAAA,EACb,wBAAwB,YAAY,qDAAqD,EAAE,GAAG,MAAM,aAAa,MAAM,cAAc,MAAM,cAAc;AAAA,EACzJ,qBAAqB,MAAM,iDAAiD,EAAE,GAAG,MAAM,aAAa,MAAM,cAAc,MAAM,WAAW;AAAA,EACzI,mBAAmB,MAAM,+CAA+C,EAAE,GAAG,MAAM,aAAa,MAAM,UAAU,MAAM,WAAW;AACnI,EAAE;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import '@opengeni/contracts';
|
|
|
2
2
|
import '@opengeni/config';
|
|
3
3
|
export { isCodexBilledModel } from '@opengeni/codex';
|
|
4
4
|
import 'drizzle-orm/pg-core';
|
|
5
|
-
import './schema-
|
|
5
|
+
import './schema-DuRsrmzD.js';
|
|
6
6
|
export { sql as dbSql } from 'drizzle-orm';
|
|
7
|
-
export { A as AccrueWarmSecondsResult, a as AcquireLeaseInput, b as AcquireLeaseResult, c as ActiveSandboxPointer, d as AppendEventInput, B as BootstrapWorkspaceInput, C as CLEARED_RUN_STATE, e as CODEX_ROTATION_STRATEGIES, f as ClearSessionContextResult, g as CodexAccountStatus, h as CodexAccountUsageSnapshot, i as CodexAuthDeps, j as CodexCredentialForRun, k as CodexCredentialTokens, l as CodexRotationSettings, m as CodexRotationStrategy, n as CreateCapabilityCatalogItemInput, o as CreateDbOptions, p as CreatePackInstallationInput, q as CreateScheduledTaskInput, r as CreateSessionGoalInput, s as CreateSessionMcpServerInput, t as CreateSocialConnectionInput, u as CreateSocialPostInput, D as Database, v as DbClient, w as DeviceEnrollmentRequestRecord, x as DeviceEnrollmentStatus, E as EnableCapabilityInstallationInput, y as EnabledMcpCapabilityServer, z as EnqueueSessionTurnInput, F as EnrollmentExposure, G as EnrollmentOs, H as EnrollmentRecord, I as EnrollmentStatus, J as ForceDrainResult, K as GitHubInstallation, L as GoalContinuationDecision, M as LeaseHolderKind, N as LeaseSnapshot, O as ListSessionEventsOptions, P as
|
|
7
|
+
export { A as AccrueWarmSecondsResult, a as AcquireLeaseInput, b as AcquireLeaseResult, c as ActiveSandboxPointer, d as AppendEventInput, B as BootstrapWorkspaceInput, C as CLEARED_RUN_STATE, e as CODEX_ROTATION_STRATEGIES, f as ClearSessionContextResult, g as CodexAccountStatus, h as CodexAccountUsageSnapshot, i as CodexAuthDeps, j as CodexCredentialForRun, k as CodexCredentialTokens, l as CodexRotationSettings, m as CodexRotationStrategy, n as CreateCapabilityCatalogItemInput, o as CreateDbOptions, p as CreatePackInstallationInput, q as CreateScheduledTaskInput, r as CreateSessionGoalInput, s as CreateSessionMcpServerInput, t as CreateSocialConnectionInput, u as CreateSocialPostInput, D as Database, v as DbClient, w as DeviceEnrollmentRequestRecord, x as DeviceEnrollmentStatus, E as EnableCapabilityInstallationInput, y as EnabledMcpCapabilityServer, z as EnqueueSessionTurnInput, F as EnrollmentExposure, G as EnrollmentOs, H as EnrollmentRecord, I as EnrollmentStatus, J as ForceDrainResult, K as GitHubInstallation, L as GoalContinuationDecision, M as LeaseHolderKind, N as LeaseSnapshot, O as ListSessionEventsOptions, P as LiveModalSandboxLeaseAttribution, Q as MACHINE_METRICS_SERIES_INTERVAL_MS, R as MachineMetricsRow, S as MachineMetricsSample, T as MeterableWarmLease, ProvisionResult, ProvisionRolesOptions, U as ReapDrainable, V as RegisterWorkspacePackInput, W as RlsContext, X as RlsStrategy, Y as SandboxImageConflictError, Z as SandboxKind, _ as SandboxLeaseLiveness, $ as SandboxLeaseSupersededError, a0 as SandboxPtySessionRow, a1 as SandboxRecord, a2 as SessionCodexState, a3 as SessionMcpServerForRun, a4 as SessionRecordingCodec, a5 as SessionRecordingMode, a6 as SessionRecordingRow, a7 as SessionRecordingState, a8 as StreamAcknowledgment, a9 as UpdateQueuedSessionTurnInput, aa as UpdateScheduledTaskInput, ab as UpdateSessionMcpServerCredentialsInput, ac as UpdateSessionMcpServerCredentialsResult, ad as UserLookup, ae as WakeParentForChildCompletionInput, af as WakeParentForChildCompletionResult, ag as WorkspaceEnvironmentForRun, ah as accrueWarmSeconds, ai as acquireLease, aj as allAccountPermissions, ak as allWorkspacePermissions, al as appendSessionEvents, am as appendSessionEventsAndUpdateSession, an as appendSessionEventsWithLockedSessionUpdate, ao as appendSessionHistoryItems, ap as applyContextCompaction, aq as applyCreditDebitUpToBalance, ar as applyCreditLedgerEntry, as as approveDeviceEnrollmentRequest, at as bootstrapWorkspace, au as buildCodexTokenResolver, av as cancelQueuedSessionTurn, aw as claimNextQueuedTurn, ax as clearSessionContext, ay as clearedContextMarkerItem, az as closePtySession, aA as commitWarmingToWarm, aB as completeFileUpload, aC as confirmDrainCold, aD as consumeDeviceEnrollmentRequest, aE as consumeSessionCompactionRequest, aF as countActiveApiKeysForWorkspace, aG as countActiveSessionHistoryItems, aH as countActiveSessionsForWorkspace, aI as countActiveSessionsUsingEnvironment, aJ as countConsecutiveReactiveRotations, aK as countScheduledTasksForWorkspace, aL as countScheduledTasksUsingEnvironment, aM as countSessionHistoryItems, aN as countTurnSessionHistoryItems, aO as countWorkspaceEnvironments, aP as countWorkspacesForAccount, aQ as createApiKey, aR as createDb, aS as createDeviceEnrollmentRequest, aT as createEnrollment, aU as createFileUpload, aV as createSandbox, aW as createScheduledTask, aX as createScheduledTaskRun, aY as createSession, aZ as createSessionGoal, a_ as createSessionMcpServers, a$ as createSessionWithIdempotencyKey, b0 as createSocialConnection, b1 as createSocialPost, b2 as createTurn, b3 as createWorkspace, b4 as createWorkspaceEnvironment, b5 as decryptEnvironmentValue, b6 as decryptedCapabilityHeaders, b7 as deleteRecording, b8 as deleteScheduledTask, b9 as deleteWorkspace, ba as deleteWorkspaceEnvironment, bb as deleteWorkspaceEnvironmentVariable, bc as deleteWorkspacePack, bd as denyDeviceEnrollmentRequest, be as disableCapabilityInstallation, bf as disconnectAllCodexAccounts, bg as disconnectCodexAccount, bh as enableCapabilityInstallation, bi as enablePackInstallation, bj as encryptEnvironmentValue, bk as enqueueSessionTurn, bl as ensureCodexRotationSettings, bm as ensureManagedAccessForUser, bn as evaluateGoalContinuation, bo as failWarmingToCold, bp as fetchCodexUsageForAccount, bq as finalizeEnrollmentByToken, br as findActiveApiKeyByHash, bs as finishTurn, bt as forceDrainOverLimitViewerOnlyBoxes, bu as getActiveSessionHistoryItems, bv as getAnySessionInGroup, bw as getBillingBalance, bx as getBillingCustomer, by as getCapabilityCatalogItem, bz as getCapabilityInstallation, bA as getCodexCredentialStatus, bB as getCodexRotationSettings, bC as getDeviceEnrollmentRequestByDeviceCode, bD as getEnrollment, bE as getFile, bF as getFileUpload, bG as getLatestRunState, bH as getManagedAccount, bI as getManagedUserByEmail, bJ as getOpenPtySession, bK as getPackInstallation, bL as getPendingDeviceEnrollmentRequestByUserCode, bM as getPendingDeviceEnrollmentRequestByUserCodeGlobal, bN as getRecording, bO as getSandbox, bP as getSandboxSessionEnvelope, bQ as getScheduledTask, bR as getSession, bS as getSessionByCreateIdempotencyKey, bT as getSessionCodexState, bU as getSessionEvent, bV as getSessionGoal, bW as getSessionHistoryItems, bX as getSessionTurn, bY as getSocialConnection, bZ as getStoredCapabilityHeaderCiphertext, b_ as getStreamAcknowledgment, b$ as getWorkspace, c0 as getWorkspaceEnvironment, c1 as getWorkspaceEnvironmentByName, c2 as getWorkspaceEnvironmentValuesForRun, c3 as getWorkspaceGrant, c4 as getWorkspacePack, c5 as grantWorkspaceAccess, c6 as hasCreditLedgerEntry, c7 as heartbeatLeaseHolder, c8 as incrementTurnWorkerDeathRedispatches, c9 as ingestMachineMetricsSample, ca as insertMachineMetricsSeries, cb as insertPtySession, cc as insertRecording, cd as isCodexBilledTurn, ce as isStripeWebhookProcessed, cf as listApiKeys, cg as listCapabilityCatalogItems, ch as listCapabilityInstallations, ci as listCodexAccountStatuses, cj as listDistinctEnvironmentIdsInGroup, ck as listEnabledMcpCapabilityServers, cl as listEnrollments, cm as listGitHubInstallationIdsForWorkspace, cn as listGitHubInstallationsForWorkspace, co as listLiveModalSandboxLeaseAttributions, cp as listMeterableWarmLeases, cq as listOpenPtySessions, cr as listPackInstallations, cs as listRecordings, ct as listSandboxes, cu as listScheduledTaskRuns, cv as listScheduledTasks, cw as listSessionEvents, cx as listSessionIdsInGroup, cy as listSessionMcpServerMetadata, cz as listSessionMcpServersForRun, cA as listSessionTurns, cB as listSessions, cC as listSocialConnections, cD as listSocialPosts, cE as listUsageEvents, cF as listWorkspaceEnvironments, cG as listWorkspaceMembers, cH as listWorkspacePacks, cI as listWorkspacesForSubject, cJ as loadCodexCredentialForRun, cK as loadWorkspaceEnvironmentForRun, cL as markFileUploadFailed, cM as markStripeWebhookProcessed, cN as mcpServerIdForCapability, cO as nextSessionHistoryPosition, cP as orphanedResultRowIndicesForRepair, cQ as persistDrainSnapshot, provisionRoles, cR as reArmDrainingLease, cS as readActiveSandbox, cT as readLease, cU as readMachineMetricsLatest, cV as readMachineMetricsLatestForWorkspace, cW as readMachineMetricsSeries, cX as reapStaleLeaseHolders, cY as reapStaleLeaseHoldersGlobal, cZ as recordAuditEvent, c_ as recordCodexAccountConnectors, c$ as recordCodexAccountUsage, d0 as recordCodexTokenRefresh, d1 as recordLeaseDataPlaneUrl, d2 as recordLeaseTerminalDataPlaneUrl, d3 as recordSessionActiveCodexCredential, d4 as recordStreamAcknowledgment, d5 as recordStripeWebhookEvent, d6 as recordUsageEvent, d7 as recordWarmingSandboxCreated, d8 as registerDbBinding, d9 as registerWorkspacePack, da as releaseLeaseHolder, db as removeWorkspaceMember, dc as renameCodexAccount, dd as reorderQueuedSessionTurns, de as requestSessionCompaction, df as requeuePreemptedTurn, dg as requireFile, dh as requireScheduledTask, di as requireSession, dj as requireSocialConnection, dk as requireWorkspace, dl as revokeApiKey, dm as revokeEnrollment, dn as revokeViewer, dp as rlsContextForWorkspace, dq as rlsStrategyFor, dr as sanitizeEventPayload, ds as sanitizeEventString, dt as saveRunState, du as sessionSubject, dv as setActiveCodexCredential, dw as setActiveSandbox, dx as setCodexCredentialExhausted, dy as setCodexCredentialStatus, dz as setEnrollmentHasDisplay, dA as setRlsContext, dB as setSessionCodexPin, dC as setSessionGoalLastContinuationTurn, dD as setSessionGoalStatus, dE as setSessionLastInputTokens, dF as setSessionStatus, dG as setTemporalWorkflowId, dH as setWorkspaceEnvironmentVariable, dI as sumUsageQuantity, dJ as touchEnrollmentLastSeen, dK as updateCodexRotationSettings, dL as updatePackInstallationStatus, dM as updatePtySessionActivity, dN as updateQueuedSessionTurn, dO as updateRecording, dP as updateScheduledTask, dQ as updateScheduledTaskRun, dR as updateSessionGoal, dS as updateSessionMcpServerCredentials, dT as updateSessionTitle, dU as updateWorkspace, dV as updateWorkspaceEnvironment, dW as upsertBillingCustomer, dX as upsertCapabilityCatalogItem, dY as upsertCodexSubscriptionCredential, dZ as upsertGitHubInstallation, d_ as upsertMachineMetricsLatest, d$ as upsertSandboxSessionEnvelope, e0 as upsertSessionGoal, e1 as wakeParentSessionForChildCompletion, e2 as withAccountRls, e3 as withRlsContext, e4 as withWorkspaceRls, e5 as withWorkspaceUsageLock, e6 as workspaceCodexSubscriptionActive } from './provision-roles.js';
|
|
8
8
|
export { migrate, runMigrations } from './migrate.js';
|
package/dist/index.js
CHANGED
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
workspaceMemberships,
|
|
40
40
|
workspacePacks,
|
|
41
41
|
workspaces
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-T2U4H4Z2.js";
|
|
43
43
|
import {
|
|
44
44
|
migrate,
|
|
45
45
|
runMigrations
|
|
@@ -2269,6 +2269,7 @@ async function createSession(db, input) {
|
|
|
2269
2269
|
sandboxGroupId: input.sandboxGroupId ?? id,
|
|
2270
2270
|
environmentId: input.environmentId ?? null,
|
|
2271
2271
|
firstPartyMcpPermissions: input.firstPartyMcpPermissions ?? null,
|
|
2272
|
+
instructions: input.instructions ?? null,
|
|
2272
2273
|
parentSessionId: input.parentSessionId ?? null,
|
|
2273
2274
|
createIdempotencyKey: input.createIdempotencyKey ?? null,
|
|
2274
2275
|
status: "queued"
|
|
@@ -2302,6 +2303,7 @@ async function createSessionWithIdempotencyKey(db, input) {
|
|
|
2302
2303
|
sandboxGroupId: input.sandboxGroupId ?? id,
|
|
2303
2304
|
environmentId: input.environmentId ?? null,
|
|
2304
2305
|
firstPartyMcpPermissions: input.firstPartyMcpPermissions ?? null,
|
|
2306
|
+
instructions: input.instructions ?? null,
|
|
2305
2307
|
parentSessionId: input.parentSessionId ?? null,
|
|
2306
2308
|
createIdempotencyKey: input.createIdempotencyKey,
|
|
2307
2309
|
status: "queued"
|
|
@@ -3033,6 +3035,28 @@ async function commitWarmingToWarm(db, input) {
|
|
|
3033
3035
|
}
|
|
3034
3036
|
);
|
|
3035
3037
|
}
|
|
3038
|
+
async function recordWarmingSandboxCreated(db, input) {
|
|
3039
|
+
return await withRlsContext(
|
|
3040
|
+
db,
|
|
3041
|
+
{ accountId: input.accountId, workspaceId: input.workspaceId },
|
|
3042
|
+
async (scopedDb) => {
|
|
3043
|
+
const resumeStateJson = input.resumeState == null ? null : JSON.stringify(input.resumeState);
|
|
3044
|
+
const rows = await scopedDb.execute(sql`
|
|
3045
|
+
update sandbox_leases set
|
|
3046
|
+
instance_id = ${input.instanceId},
|
|
3047
|
+
resume_backend_id = ${input.resumeBackendId ?? null},
|
|
3048
|
+
resume_state = ${resumeStateJson}::jsonb,
|
|
3049
|
+
expires_at = now() + (${String(input.leaseTtlMs)} || ' milliseconds')::interval,
|
|
3050
|
+
updated_at = now()
|
|
3051
|
+
where workspace_id = ${input.workspaceId} and sandbox_group_id = ${input.sandboxGroupId}
|
|
3052
|
+
and liveness = 'warming' and lease_epoch = ${input.expectedEpoch}
|
|
3053
|
+
returning *
|
|
3054
|
+
`);
|
|
3055
|
+
if (rows.length === 0) return { recorded: false, lease: null };
|
|
3056
|
+
return { recorded: true, lease: mapLeaseRow(rows[0]) };
|
|
3057
|
+
}
|
|
3058
|
+
);
|
|
3059
|
+
}
|
|
3036
3060
|
async function failWarmingToCold(db, input) {
|
|
3037
3061
|
await withRlsContext(
|
|
3038
3062
|
db,
|
|
@@ -3160,7 +3184,21 @@ async function reapStaleLeaseHolders(db, input) {
|
|
|
3160
3184
|
resume_backend_id = null, resume_state = null,
|
|
3161
3185
|
data_plane_url = null, terminal_data_plane_url = null, updated_at = now()
|
|
3162
3186
|
where workspace_id = ${input.workspaceId}
|
|
3163
|
-
and liveness = 'warming' and expires_at < now()
|
|
3187
|
+
and liveness = 'warming' and expires_at < now() and instance_id is null
|
|
3188
|
+
returning id
|
|
3189
|
+
`);
|
|
3190
|
+
const warmingDrain = await tx.execute(sql`
|
|
3191
|
+
update sandbox_leases set
|
|
3192
|
+
liveness = 'draining',
|
|
3193
|
+
refcount = 0,
|
|
3194
|
+
turn_holders = 0,
|
|
3195
|
+
viewer_holders = 0,
|
|
3196
|
+
data_plane_url = null,
|
|
3197
|
+
terminal_data_plane_url = null,
|
|
3198
|
+
expires_at = now() - interval '1 millisecond',
|
|
3199
|
+
updated_at = now()
|
|
3200
|
+
where workspace_id = ${input.workspaceId}
|
|
3201
|
+
and liveness = 'warming' and expires_at < now() and instance_id is not null
|
|
3164
3202
|
returning id
|
|
3165
3203
|
`);
|
|
3166
3204
|
const drainable = await rawRows(tx, sql`
|
|
@@ -3170,7 +3208,7 @@ async function reapStaleLeaseHolders(db, input) {
|
|
|
3170
3208
|
`);
|
|
3171
3209
|
return {
|
|
3172
3210
|
reapedViewers: reaped.length,
|
|
3173
|
-
warmingReset: warmingReset.length,
|
|
3211
|
+
warmingReset: warmingReset.length + warmingDrain.length,
|
|
3174
3212
|
drained: drainable.map((r) => ({
|
|
3175
3213
|
workspaceId: input.workspaceId,
|
|
3176
3214
|
sandboxGroupId: r.sandbox_group_id,
|
|
@@ -3205,6 +3243,19 @@ async function listMeterableWarmLeases(db) {
|
|
|
3205
3243
|
backend: r.backend
|
|
3206
3244
|
}));
|
|
3207
3245
|
}
|
|
3246
|
+
async function listLiveModalSandboxLeaseAttributions(db) {
|
|
3247
|
+
const rows = await rawRows(db, sql`
|
|
3248
|
+
select lease_id, workspace_id, sandbox_group_id, instance_id, liveness
|
|
3249
|
+
from opengeni_private.list_live_modal_sandbox_leases()
|
|
3250
|
+
`);
|
|
3251
|
+
return rows.map((r) => ({
|
|
3252
|
+
leaseId: r.lease_id,
|
|
3253
|
+
workspaceId: r.workspace_id,
|
|
3254
|
+
sandboxGroupId: r.sandbox_group_id,
|
|
3255
|
+
instanceId: r.instance_id,
|
|
3256
|
+
liveness: r.liveness
|
|
3257
|
+
}));
|
|
3258
|
+
}
|
|
3208
3259
|
async function reArmDrainingLease(db, input) {
|
|
3209
3260
|
return await withRlsContext(
|
|
3210
3261
|
db,
|
|
@@ -4747,6 +4798,7 @@ function mapSession(row, mcpServers = []) {
|
|
|
4747
4798
|
initialMessage: row.initialMessage,
|
|
4748
4799
|
title: row.title ?? null,
|
|
4749
4800
|
titleSource: row.titleSource ?? null,
|
|
4801
|
+
instructions: row.instructions ?? null,
|
|
4750
4802
|
resources: row.resources,
|
|
4751
4803
|
tools: row.tools,
|
|
4752
4804
|
metadata: row.metadata,
|
|
@@ -5274,6 +5326,7 @@ export {
|
|
|
5274
5326
|
listEnrollments,
|
|
5275
5327
|
listGitHubInstallationIdsForWorkspace,
|
|
5276
5328
|
listGitHubInstallationsForWorkspace,
|
|
5329
|
+
listLiveModalSandboxLeaseAttributions,
|
|
5277
5330
|
listMeterableWarmLeases,
|
|
5278
5331
|
listOpenPtySessions,
|
|
5279
5332
|
listPackInstallations,
|
|
@@ -5322,6 +5375,7 @@ export {
|
|
|
5322
5375
|
recordStreamAcknowledgment,
|
|
5323
5376
|
recordStripeWebhookEvent,
|
|
5324
5377
|
recordUsageEvent,
|
|
5378
|
+
recordWarmingSandboxCreated,
|
|
5325
5379
|
registerDbBinding,
|
|
5326
5380
|
registerWorkspacePack,
|
|
5327
5381
|
releaseLeaseHolder,
|