The open-source app everyone uses to manage agents at work
TypeScript acpxagent-orchestrationagent-skillsagentic-aiai-agentsai-engineeringai-governanceai-toolsautonomous-agentsclaudeclaude-codeclaude-skillscodexhermesllmmcpmulti-agentopenclawproject-managementworkflow-automation
feat(ui): integrate agent personas across the app (#13171)
Dotta1ef3b0871473
diff --git a/.github/scripts/publish-storybook.cjs b/.github/scripts/publish-storybook.cjsindex f4fdeb1c03..327df2a2bc 100644--- a/.github/scripts/publish-storybook.cjs+++ b/.github/scripts/publish-storybook.cjs@@ -24,7 +24,10 @@ for (const name of ['index.html', 'iframe.html', 'index.json']) {throw new Error(`Missing Storybook output: ${name}`);}}-fs.writeFileSync(path.join(source, 'deployment.json'), JSON.stringify(destination, null, 2) + '\n');+fs.writeFileSync(path.join(source, 'deployment.json'), JSON.stringify({ ...destination,+ ...(fs.existsSync(path.join(source, 'agent-avatar-images/manifest.json'))+ ? { avatarManifest: 'agent-avatar-images/manifest.json' } : {}),+}, null, 2) + '\n');const aws = (args) => execFileSync('aws', args, { stdio: 'inherit' });// Complete a unique build before changing the branch's entry point. No deletion// permissions, shared root writes or mixed-version branch assets are needed.diff --git a/.github/scripts/verify-storybook.cjs b/.github/scripts/verify-storybook.cjsindex fd70299f6a..d9dc9431e1 100644--- a/.github/scripts/verify-storybook.cjs+++ b/.github/scripts/verify-storybook.cjs@@ -1,4 +1,40 @@const { branchIndex } = require('./storybook-destination.cjs');+const { createHash } = require('node:crypto');++async function verifyAvatarImages({ buildUrl, fetch = globalThis.fetch }) {+ const response = await fetch(new URL('agent-avatar-images/manifest.json', buildUrl), { signal: AbortSignal.timeout(15000) });+ if (!response.ok) throw new Error(`Avatar manifest returned HTTP ${response.status}.`);+ const manifest = await response.json();+ if (manifest.schemaVersion !== 1 || !Array.isArray(manifest.images) || !manifest.images.length || manifest.images.length > 10000) {+ throw new Error('Invalid avatar image manifest.');+ }+ const paths = new Set();+ for (const image of manifest.images) {+ if (!/^agent-avatar-images\/[a-z0-9-]+\/[a-z0-9-]+\/[a-z0-9-]+\.png$/.test(image.path)+ || !/^[a-f0-9]{64}$/.test(image.sha256) || !Number.isInteger(image.pixels)+ || image.pixels < 16 || image.pixels > 1024 || paths.has(image.path)) {+ throw new Error('Invalid avatar image entry.');+ }+ paths.add(image.path);+ }+ let next = 0;+ await Promise.all(Array.from({ length: 8 }, async () => {+ while (next < manifest.images.length) {+ const image = manifest.images[next++];+ const result = await fetch(new URL(image.path, buildUrl), { signal: AbortSignal.timeout(15000) });+ if (!result.ok || !result.headers.get('content-type')?.startsWith('image/png')) {+ throw new Error(`Avatar ${image.path} returned HTTP ${result.status} or a non-PNG content type.`);+ }+ const png = Buffer.from(await result.arrayBuffer());+ if (png.length < 24 || png.subarray(0, 8).toString('hex') !== '89504e470d0a1a0a'+ || png.readUInt32BE(16) !== image.pixels || png.readUInt32BE(20) !== image.pixels+ || createHash('sha256').update(png).digest('hex') !== image.sha256) {+ throw new Error(`Avatar ${image.path} has incorrect PNG bytes or dimensions.`);+ }+ }+ }));+ console.log(`Verified ${manifest.images.length} public avatar PNGs.`);+}async function verifyStorybook({ branchUrl, buildUrl, sha, fetch = globalThis.fetch,sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)), attempts = 6 }) {@@ -9,8 +45,10 @@ async function verifyStorybook({ branchUrl, buildUrl, sha, fetch = globalThis.fefetch(branchUrl, { signal: AbortSignal.timeout(15000) }),]);if (!metadata.ok || !index.ok) throw new Error(`Public deployment returned HTTP ${metadata.status}/${index.status}.`);- if ((await metadata.json()).sha !== sha) throw new Error('Public build has the wrong source commit.');+ const build = await metadata.json();+ if (build.sha !== sha) throw new Error('Public build has the wrong source commit.');if ((await index.text()) !== branchIndex(buildUrl)) throw new Error('Public branch URL does not point to this build.');+ if (build.avatarManifest) await verifyAvatarImages({ buildUrl, fetch });return;} catch (error) {if (attempt === attempts) throw error;@@ -19,7 +57,7 @@ async function verifyStorybook({ branchUrl, buildUrl, sha, fetch = globalThis.fe}}-module.exports = { verifyStorybook };+module.exports = { verifyStorybook, verifyAvatarImages };if (require.main === module) {verifyStorybook({ branchUrl: process.env.BRANCH_URL, buildUrl: process.env.BUILD_URL,sha: process.env.SOURCE_SHA }).catch((error) => { console.error(error); process.exitCode = 1; });diff --git a/.github/workflows/storybook-deploy.yml b/.github/workflows/storybook-deploy.ymlindex a485d033b5..bb65d0d878 100644--- a/.github/workflows/storybook-deploy.yml+++ b/.github/workflows/storybook-deploy.yml@@ -88,6 +88,9 @@ jobs:with:node-version: 24package-manager-cache: false+ # Feature branches omit lockfile commits; resolve their manifests just as PR CI does.+ - name: Resolve branch dependency lock+ run: pnpm install --resolution-only --ignore-scripts --no-frozen-lockfile- run: pnpm install --frozen-lockfile --ignore-scripts- run: pnpm build-storybook- name: Record source and validate outputdiff --git a/doc/DEVELOPING.md b/doc/DEVELOPING.mdindex 65c8c956c5..9ed6efd1b9 100644--- a/doc/DEVELOPING.md+++ b/doc/DEVELOPING.md@@ -1501,6 +1501,12 @@ Networking behavior for this smoke script:See [execution GitHub identity](execution-github-identity.md) for the operation-time credential contract, continuation rules, runtime rollout, and acceptance-test requirements.+### Agent persona Storybook++See [agent-personas.md](agent-personas.md) for the dynamic avatar endpoint, cache,+and character stories. Set `PAPERCLIP_STORYBOOK_API_URL` to your isolated+Paperclip API URL when running dev Storybook. Published Storybook builds automatically+package avatar PNGs using the API renderer; static hosting needs no API proxy.### Investigating polling loaddiff --git a/doc/SPEC-implementation.md b/doc/SPEC-implementation.mdindex 1623e9e389..f60ec9ce59 100644--- a/doc/SPEC-implementation.md+++ b/doc/SPEC-implementation.md@@ -1576,6 +1576,12 @@ Export/import behavior in V1:- import preview reports skill-policy and legacy-grant mappings before apply and rejects unknown policy schema versions- GitHub imports warn on unpinned refs instead of blocking+## Agent visual identity++Agent appearances are stable, versioned ClipLab end-cap personas, separate from+behavioral instructions. Compact surfaces use on-demand cached PNG URLs; larger+placements may use a lazy live character. See [agent-personas.md](agent-personas.md)+for persistence, migration, rendering, and integration contracts.### Experimental task-backed agent chat (2026-09-10)`enableAgentChat` is an instance experimental flag, default false. Conversation containers remain issues, unique by `(company_id, conversation_agent_id, conversation_user_id)`. The authenticated board actor supplies ownership; local trusted mode uses `local-board`. Ordinary company task access applies. A conversation's agent assignment and identity are immutable through ordinary updates; terminal status mutations are rejected.diff --git a/doc/SPEC.md b/doc/SPEC.mdindex 967cd50145..02b993ae41 100644--- a/doc/SPEC.md+++ b/doc/SPEC.md@@ -551,6 +551,12 @@ Things Paperclip explicitly does **not** do:8. **Progressive deployment.** Trivial to start local, straightforward to scale to hosted.9. **Extensible core.** Clean boundaries so plugins can add capabilities (Adapters, knowledge base, revenue tracking) without modifying core.+## Agent visual identity++Agent appearances are stable, versioned ClipLab end-cap personas, separate from+behavioral instructions. Compact surfaces use on-demand cached PNG URLs; larger+placements may use a lazy live character. See [agent-personas.md](agent-personas.md)+for persistence, migration, rendering, and integration contracts.### Agent chat project handoff (2026-09-11)Chat supports research and full plan drafting/revision in its existing plan document. On handoff, each ordinary assigned task receives the relevant plan in its own `plan` document, committed with task creation before execution is scheduled. The source plan remains in the conversation. Plan acceptance hands off execution; it never switches the conversation into implementation.diff --git a/doc/agent-personas.md b/doc/agent-personas.mdnew file mode 100644index 0000000000..6a4120e739--- /dev/null+++ b/doc/agent-personas.md@@ -0,0 +1,178 @@+# Agent personas++Agents have a persisted visual identity independent of prompts and runtime+configuration: `{ schemaVersion: 1, characterVersion: "cap-v1", paletteId }`.+The cap-v1 library contains 17 permanent palettes and a presentation-only gray+Muted dream palette. New agents get one random assignment; existing rows are+backfilled with the same ID-based mapping used by legacy clients. Duplicating+an agent generates another assignment. Export/import preserves it.++## Rendering and URLs++`GET /api/agent-avatars/cap-v1/bubblegum-sky/rest.png?size=24&scale=2`++The endpoint is public preset artwork, contains no agent/company identifiers,+and works without the UI. `Agent.avatarUrl` is the 512px resting portrait URL.+Resolve relative URLs against the instance base URL for integrations.++Supported logical sizes: 16, 20, 24, 32, 40, 48, 64, 96, 128, 256, 512.+Density is 1 or 2. Poses: rest, idle, listening, thinking, working, success,+confused, sleepy, loading. Other inputs receive 400. Display size controls+face detail separately from raster dimensions: 24px at 2× remains eyes-only.++A cold request samples ClipLab's deterministic scene, exports SVG using the+same geometry and face code as the live renderer, and rasterizes it with sharp+in a worker thread. No Chromium, GPU, pre-rendering command, or per-agent asset+row is required. Two workers serve a bounded queue, coalesce identical requests+within the process, time out failed rendering, and stop after an idle interval.++The configured local-disk/S3 provider stores results in+`generated-agent-avatars/<version>/<palette>/<pose>-<size>-<scale>.png`.+This preset-only cache intentionally uses the storage provider directly;+company asset APIs retain their existing authorization boundary. Cache data+can be removed and regenerates on demand. Independent replicas can render the+same key safely; successful writes are complete objects. ETags hash PNG bytes.+A small `.png.json` sidecar stores the content digest and length; it is published+after the complete PNG. Warm requests stream stored PNG bytes without re-rendering+or buffering the image in the API process. Responses are immutable for one year.+Cold renders are limited per client IP (32 outstanding keys and 256 new keys+per minute per process); excess misses return 429 with Retry-After and no-store.+Warm cache hits and requests joining the same in-flight key bypass admission.+The route uses Express trust-proxy configuration, never an untrusted forwarded header. Render/storage failures return 503 with+Retry-After and no-store rather than caching a broken image.++cap-v1 is frozen: change the version when changing palette values, poses,+rendering, or dependencies in a way that changes pixels. Keep old versions+available. The SVG exporter approximates 3D gradients with a planar gradient;+front-facing identity portraits minimize the difference from WebGL.++## Components++- `AgentAvatar`: image only; pass the agent record or appearance and a semantic+ size. No per-agent queries, live-renderer imports, or circle cropping.+- `AgentIdentity`: agent avatar and name. Human identities keep `Identity`.+- `AgentCharacter`: lazy live hero with state and optional tracking-region+ props, plus an explicit `trackingScope="page"` for onboarding and agent headers. One live renderer per view; other instances keep their still image.+ Reduced motion, offscreen content, renderer failure, and static states do+ not run the animation loop. Pointer tracking defaults to its region and is off for touch.++Onboarding stores the eventual palette in its existing draft and presents gray+until verified connection/hiring succeeds. Reconnect never randomizes identity.+Names, explicit status badges, and status text remain authoritative.++## Development and verification++ClipLab provenance/licenses are under `packages/shared/src/cliplab/`.+Palette tokens originate in `ui/src/index.css`. After deliberately introducing+new versioned artwork, `node scripts/sync-agent-palette-tokens.mjs` synchronizes+the TS palette data; `--check` detects drift. This does not generate images.++Storybook: **Agents / Personas**. Run with+`PAPERCLIP_STORYBOOK_API_URL=http://localhost:<isolated-port> pnpm storybook`.+`pnpm build-storybook` automatically packages all finite avatar presets (17+palettes plus muted gray, nine poses, eleven logical sizes, both densities).+The build uses the same bounded Node worker pool, SVG renderer, and Sharp pipeline+as the API. Storybook-only URL resolution points to relative PNG paths under the+published build, including branch-prefixed deployments. Production Paperclip+continues to use its on-demand API; no image generation runs during agent creation.+The generated files are build output, never committed. A manifest records image+hashes and pixel dimensions; deployment verification fetches every image and checks+its content type, PNG signature, dimensions, and hash. Dev Storybook still uses the+API proxy for cold-cache and regeneration testing.++Focused checks:++```sh+pnpm exec vitest run packages/shared/src/agent-appearance.test.ts server/src/__tests__/agent-avatars.test.ts+node scripts/sync-agent-palette-tokens.mjs --check+pnpm check:token-gates+pnpm build-storybook+```++The 500-avatar story must create zero WebGL contexts and load no live runtime.+Use fixed poses/times for screenshots and Linux for authoritative visual+baselines. Verify cold and warm URLs, reduced motion, reconnect, and saved+appearance after refresh alongside normal typecheck/test/build checks.++Linux visual/performance checks (against the self-contained built Storybook):++```sh+pnpm exec playwright test --config tests/storybook-visual/agent-personas.config.ts+```++Use the Playwright 1.62.1 Noble image for authoritative Linux baselines. The suite+covers both themes, palette and size grids, every expression, fixed-pose SVG/WebGL+pixel comparisons, repeated mounts, context loss, delayed/failed images, and the+500-avatar no-WebGL/no-live-download/no-frame-loop contract. Baselines follow the+existing Storybook visual artifact workflow; they are not application assets.++## Acceptance record — 2026-09-10++Implemented in `codex/agent-personas`, based on `5cb4f061d`, with the original+checkout left unchanged. Verification used disposable embedded-Postgres data,+a local MinIO container, and Playwright's Linux Noble image.++| Check | Result |+| --- | --- |+| Repository typecheck and build | Passed |+| Token gates and palette-token synchronization | Passed |+| Storybook production build | Passed |+| Linux visual/performance suite | 30 passed; exact snapshot comparison passed |+| Static/live agreement | Rest at 16/24/48/256 logical pixels, both densities; all eight animated expression snapshots at 128px/2× |+| Avatar endpoint | Cold/warm requests, concurrency, deletion, retry, ETags and invalid parameters passed |+| Real local-disk and S3-compatible storage | Passed; persisted warm cache reused by a fresh service instance |+| Compiled API-only smoke | Passed with TypeScript stripping disabled, no UI and a native worker |+| Persistence and contracts | Creation, saved draft, SQL backfill, approvals, duplication, portability and revision restoration passed |+| UI/runtime lifecycle | Reduced motion, one live owner, scoped pointers, hidden/offscreen suspension, failures and disposal passed |+| Hands-on app | Stable rename/reload, fresh duplicate assignment, paused static portrait, matching task/list/configuration identities passed |++The broad `pnpm test:run` verification was completed in its groups/shards after+resource-contention retries. General server (8,347 tests), UI (5,619), CLI (484),+DB (133), and adapter/plugin source suites (2,235) passed. Remaining route suites+and the added persona/contract tests passed after the OpenAPI coverage update.+The queued-comment suite exposed a pre-existing fixture-cleanup failure: run+claims created dependent runtime rows, so swallowed foreign-key errors left the+`QUE` company behind. Its isolated-database cleanup now truncates the company+fixture graph with cascade; all 17 tests pass together. No production queued-comment+behavior changed. Verification completed across the repository runner's groups+and shards, with targeted reruns after fixes, rather than another monolithic run.++Actual provider sign-in was not completed: the disposable instance had no managed+sandbox available for sign-in. Onboarding gray/loading/success transitions were+covered in Storybook and the onboarding tests. The app is usable in local-trusted+mode; this standalone worktree has no managed issue identity or login handoff.++The reviewed Linux candidate archive is generated at+`tests/storybook-visual/baseline-review/snapshots.tgz`. It remains a local review+artifact; the existing baseline manifest was not repointed to an unpublished URL.++## Placement and sharpness refinement — 2026-09-10++The overview/configuration header owns the live character beside the agent name+and follows the pointer across the whole page; there is no second hero in the+overview body. The new-agent dialog and setup page+use a larger, padded character frame with page-wide mouse tracking. Other+placements retain region-scoped tracking. Touch, reduced motion, hidden views,+and unmount cleanup still disable tracking and frame scheduling.++Live canvases render at twice the display density (capped at 4×), with a 1024px+face texture and padded framing for rotations and expression props. This affects+only the live renderer: existing versioned PNG URLs retain their original pixels.+The Snapshot Agreement story provides explicit 1×/2× controls and labels the+actual PNG and WebGL pixel dimensions for a fair comparison.++`Agents / Personas / Full pages` includes the actual application shell and route+components for all agents, agent overview, task detail, dashboard, the new-agent+dialog, and the connection page. Fixtures stay in Storybook; these examples do+not read or mutate the running company's data. Dashboard activity rows now use+the same agent avatars as its active-agent and task placements.++Refinement verification: 38 Linux Playwright checks passed, including exact+comparison with the reviewed snapshots for all six full-page stories and+corner-pointer clipping checks at 1×/2× display density. The 500-avatar view+still loads no live renderer or WebGL contexts. All 18 targeted appearance,+component/runtime, and avatar endpoint tests passed, as did shared/UI typechecks,+token gates, UI build, and Storybook build. Hands-on inspection confirmed the+single animated header at `/PER/agents/persona-tester-renamed/overview` and the+larger onboarding character in the real route components. The repository-wide+checks above were not repeated for this UI refinement.diff --git a/package.json b/package.jsonindex 92b33a0d25..5532df2622 100644--- a/package.json+++ b/package.json@@ -41,7 +41,7 @@"release:rollback": "./scripts/rollback-latest.sh","release:bootstrap-package": "node scripts/bootstrap-npm-package.mjs","check:tokens": "node scripts/check-forbidden-tokens.mjs",- "check:token-gates": "node scripts/check-token-gates.mjs",+ "check:token-gates": "node scripts/check-token-gates.mjs && node scripts/sync-agent-palette-tokens.mjs --check","check:node-version": "node scripts/check-node-version-policy.mjs","check:no-git-push": "node scripts/check-no-git-push.mjs","check:module-boundaries": "node scripts/check-module-boundaries.mjs",diff --git a/packages/db/src/migrations/0280_unique_genesis.sql b/packages/db/src/migrations/0280_unique_genesis.sqlnew file mode 100644index 0000000000..a3fd132e7a--- /dev/null+++ b/packages/db/src/migrations/0280_unique_genesis.sql@@ -0,0 +1,11 @@+ALTER TABLE "agents" ADD COLUMN IF NOT EXISTS "appearance" jsonb;+--> statement-breakpoint+WITH RECURSIVE appearance_hash AS (+ SELECT id, id::text AS identity_text, 0 AS position, 0 AS hash FROM agents WHERE appearance IS NULL+ UNION ALL+ SELECT id, identity_text, position + 1, (hash * 31 + ascii(substr(identity_text, position + 1, 1))) % 17+ FROM appearance_hash WHERE position < length(identity_text)+)+UPDATE agents SET appearance = jsonb_build_object('schemaVersion', 1, 'characterVersion', 'cap-v1',+ 'paletteId', (ARRAY['bubblegum-sky','pink-lemonade','orchid-peach','coral-mint','lime-lagoon','arctic-blue','solar-flare','violet-ember','deep-tide','coral-current','golden-hour','tangerine-cobalt','electric-grove','flamingo-jade','cherry-pop','turquoise-cherry','ultraviolet-tide'])[appearance_hash.hash + 1])+FROM appearance_hash WHERE agents.id = appearance_hash.id AND appearance_hash.position = length(appearance_hash.identity_text) AND agents.appearance IS NULL;diff --git a/packages/db/src/migrations/meta/0280_snapshot.json b/packages/db/src/migrations/meta/0280_snapshot.jsonnew file mode 100644index 0000000000..ea3ae5e50d--- /dev/null+++ b/packages/db/src/migrations/meta/0280_snapshot.json@@ -0,0 +1,47808 @@+{+ "id": "861a2815-1418-4c71-a77b-d0e2e9566413",+ "prevId": "4770ad6d-2cdc-45c4-af89-c300fd134d91",+ "version": "7",+ "dialect": "postgresql",+ "tables": {+ "public.activity_log": {+ "name": "activity_log",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "actor_type": {+ "name": "actor_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'system'"+ },+ "actor_id": {+ "name": "actor_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "action": {+ "name": "action",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "entity_type": {+ "name": "entity_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "entity_id": {+ "name": "entity_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "responsible_user_id": {+ "name": "responsible_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "details": {+ "name": "details",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "activity_log_company_created_idx": {+ "name": "activity_log_company_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "activity_log_company_agent_created_idx": {+ "name": "activity_log_company_agent_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "activity_log_company_responsible_user_created_idx": {+ "name": "activity_log_company_responsible_user_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "responsible_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "activity_log_run_id_idx": {+ "name": "activity_log_run_id_idx",+ "columns": [+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "activity_log_entity_type_id_idx": {+ "name": "activity_log_entity_type_id_idx",+ "columns": [+ {+ "expression": "entity_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "entity_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "activity_log_company_id_companies_id_fk": {+ "name": "activity_log_company_id_companies_id_fk",+ "tableFrom": "activity_log",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "activity_log_agent_id_agents_id_fk": {+ "name": "activity_log_agent_id_agents_id_fk",+ "tableFrom": "activity_log",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "activity_log_run_id_heartbeat_runs_id_fk": {+ "name": "activity_log_run_id_heartbeat_runs_id_fk",+ "tableFrom": "activity_log",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.adapter_auth_sessions": {+ "name": "adapter_auth_sessions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "environment_id": {+ "name": "environment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "ai_connection": {+ "name": "ai_connection",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "connection_id": {+ "name": "connection_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "connection_grant_id": {+ "name": "connection_grant_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "connection_method": {+ "name": "connection_method",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "adapter_type": {+ "name": "adapter_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "started_by_user_id": {+ "name": "started_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "public_session_id": {+ "name": "public_session_id",+ "type": "varchar(128)",+ "primaryKey": false,+ "notNull": true+ },+ "provider_lease_id": {+ "name": "provider_lease_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'starting'"+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "promotion_expires_at": {+ "name": "promotion_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "bound_at": {+ "name": "bound_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "finished_at": {+ "name": "finished_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "failure_reason": {+ "name": "failure_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "result_claim": {+ "name": "result_claim",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "adapter_auth_sessions_company_status_idx": {+ "name": "adapter_auth_sessions_company_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "adapter_auth_sessions_company_owner_adapter_active_uq": {+ "name": "adapter_auth_sessions_company_owner_adapter_active_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "started_by_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "adapter_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"adapter_auth_sessions\".\"status\" IN ('starting', 'waiting_for_user', 'promoting', 'awaiting_code', 'submitting')",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "adapter_auth_sessions_public_session_id_uq": {+ "name": "adapter_auth_sessions_public_session_id_uq",+ "columns": [+ {+ "expression": "public_session_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "adapter_auth_sessions_environment_idx": {+ "name": "adapter_auth_sessions_environment_idx",+ "columns": [+ {+ "expression": "environment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "adapter_auth_sessions_expires_idx": {+ "name": "adapter_auth_sessions_expires_idx",+ "columns": [+ {+ "expression": "expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "adapter_auth_sessions_provider_lease_idx": {+ "name": "adapter_auth_sessions_provider_lease_idx",+ "columns": [+ {+ "expression": "provider_lease_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "adapter_auth_sessions_company_id_companies_id_fk": {+ "name": "adapter_auth_sessions_company_id_companies_id_fk",+ "tableFrom": "adapter_auth_sessions",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "adapter_auth_sessions_environment_id_environments_id_fk": {+ "name": "adapter_auth_sessions_environment_id_environments_id_fk",+ "tableFrom": "adapter_auth_sessions",+ "tableTo": "environments",+ "columnsFrom": [+ "environment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_api_keys": {+ "name": "agent_api_keys",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "key_hash": {+ "name": "key_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "responsible_user_id": {+ "name": "responsible_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "scope_config": {+ "name": "scope_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "last_used_at": {+ "name": "last_used_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "revoked_at": {+ "name": "revoked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_api_keys_key_hash_idx": {+ "name": "agent_api_keys_key_hash_idx",+ "columns": [+ {+ "expression": "key_hash",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_api_keys_company_agent_idx": {+ "name": "agent_api_keys_company_agent_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_api_keys_agent_id_agents_id_fk": {+ "name": "agent_api_keys_agent_id_agents_id_fk",+ "tableFrom": "agent_api_keys",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "agent_api_keys_company_id_companies_id_fk": {+ "name": "agent_api_keys_company_id_companies_id_fk",+ "tableFrom": "agent_api_keys",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_config_revisions": {+ "name": "agent_config_revisions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'patch'"+ },+ "rolled_back_from_revision_id": {+ "name": "rolled_back_from_revision_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "changed_keys": {+ "name": "changed_keys",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "before_config": {+ "name": "before_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "after_config": {+ "name": "after_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_config_revisions_company_agent_created_idx": {+ "name": "agent_config_revisions_company_agent_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_config_revisions_agent_created_idx": {+ "name": "agent_config_revisions_agent_created_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_config_revisions_company_id_companies_id_fk": {+ "name": "agent_config_revisions_company_id_companies_id_fk",+ "tableFrom": "agent_config_revisions",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "agent_config_revisions_agent_id_agents_id_fk": {+ "name": "agent_config_revisions_agent_id_agents_id_fk",+ "tableFrom": "agent_config_revisions",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_config_revisions_created_by_agent_id_agents_id_fk": {+ "name": "agent_config_revisions_created_by_agent_id_agents_id_fk",+ "tableFrom": "agent_config_revisions",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_memberships": {+ "name": "agent_memberships",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "state": {+ "name": "state",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'joined'"+ },+ "starred_at": {+ "name": "starred_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_memberships_company_user_idx": {+ "name": "agent_memberships_company_user_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_memberships_company_user_starred_idx": {+ "name": "agent_memberships_company_user_starred_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "starred_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_memberships_agent_idx": {+ "name": "agent_memberships_agent_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_memberships_company_user_agent_uq": {+ "name": "agent_memberships_company_user_agent_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_memberships_company_id_companies_id_fk": {+ "name": "agent_memberships_company_id_companies_id_fk",+ "tableFrom": "agent_memberships",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_memberships_agent_id_agents_id_fk": {+ "name": "agent_memberships_agent_id_agents_id_fk",+ "tableFrom": "agent_memberships",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_runtime_state": {+ "name": "agent_runtime_state",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "adapter_type": {+ "name": "adapter_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "state_json": {+ "name": "state_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "last_run_id": {+ "name": "last_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "last_run_status": {+ "name": "last_run_status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "total_input_tokens": {+ "name": "total_input_tokens",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "total_output_tokens": {+ "name": "total_output_tokens",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "total_cached_input_tokens": {+ "name": "total_cached_input_tokens",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "total_cost_cents": {+ "name": "total_cost_cents",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_runtime_state_company_agent_idx": {+ "name": "agent_runtime_state_company_agent_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_runtime_state_company_updated_idx": {+ "name": "agent_runtime_state_company_updated_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_runtime_state_agent_id_agents_id_fk": {+ "name": "agent_runtime_state_agent_id_agents_id_fk",+ "tableFrom": "agent_runtime_state",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "agent_runtime_state_company_id_companies_id_fk": {+ "name": "agent_runtime_state_company_id_companies_id_fk",+ "tableFrom": "agent_runtime_state",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_session_goal_actions": {+ "name": "agent_session_goal_actions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "session_id": {+ "name": "session_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "request_id": {+ "name": "request_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "action": {+ "name": "action",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "payload_json": {+ "name": "payload_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "result_json": {+ "name": "result_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "error": {+ "name": "error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "delivered_at": {+ "name": "delivered_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_session_goal_actions_session_request_uniq": {+ "name": "agent_session_goal_actions_session_request_uniq",+ "columns": [+ {+ "expression": "session_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "request_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_session_goal_actions_company_status_created_idx": {+ "name": "agent_session_goal_actions_company_status_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_session_goal_actions_session_created_idx": {+ "name": "agent_session_goal_actions_session_created_idx",+ "columns": [+ {+ "expression": "session_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_session_goal_actions_company_id_companies_id_fk": {+ "name": "agent_session_goal_actions_company_id_companies_id_fk",+ "tableFrom": "agent_session_goal_actions",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "agent_session_goal_actions_session_id_agent_task_sessions_id_fk": {+ "name": "agent_session_goal_actions_session_id_agent_task_sessions_id_fk",+ "tableFrom": "agent_session_goal_actions",+ "tableTo": "agent_task_sessions",+ "columnsFrom": [+ "session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_task_sessions": {+ "name": "agent_task_sessions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "adapter_type": {+ "name": "adapter_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "task_key": {+ "name": "task_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "session_params_json": {+ "name": "session_params_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "session_display_id": {+ "name": "session_display_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "last_run_id": {+ "name": "last_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "goal_capability_json": {+ "name": "goal_capability_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "goal_json": {+ "name": "goal_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "goal_status": {+ "name": "goal_status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "goal_desired_state": {+ "name": "goal_desired_state",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "goal_source_id": {+ "name": "goal_source_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "goal_source_cursor": {+ "name": "goal_source_cursor",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false+ },+ "goal_revision": {+ "name": "goal_revision",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "goal_observed_at": {+ "name": "goal_observed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_task_sessions_company_agent_adapter_task_uniq": {+ "name": "agent_task_sessions_company_agent_adapter_task_uniq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "adapter_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "task_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_task_sessions_company_agent_updated_idx": {+ "name": "agent_task_sessions_company_agent_updated_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_task_sessions_company_task_updated_idx": {+ "name": "agent_task_sessions_company_task_updated_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "task_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_task_sessions_company_id_companies_id_fk": {+ "name": "agent_task_sessions_company_id_companies_id_fk",+ "tableFrom": "agent_task_sessions",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "agent_task_sessions_agent_id_agents_id_fk": {+ "name": "agent_task_sessions_agent_id_agents_id_fk",+ "tableFrom": "agent_task_sessions",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "agent_task_sessions_last_run_id_heartbeat_runs_id_fk": {+ "name": "agent_task_sessions_last_run_id_heartbeat_runs_id_fk",+ "tableFrom": "agent_task_sessions",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "last_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_wakeup_requests": {+ "name": "agent_wakeup_requests",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "trigger_detail": {+ "name": "trigger_detail",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "reason": {+ "name": "reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'queued'"+ },+ "coalesced_count": {+ "name": "coalesced_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "requested_by_actor_type": {+ "name": "requested_by_actor_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "requested_by_actor_id": {+ "name": "requested_by_actor_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "idempotency_key": {+ "name": "idempotency_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "requested_at": {+ "name": "requested_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "claimed_at": {+ "name": "claimed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "finished_at": {+ "name": "finished_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "error": {+ "name": "error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_wakeup_requests_company_agent_status_idx": {+ "name": "agent_wakeup_requests_company_agent_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_wakeup_requests_company_requested_idx": {+ "name": "agent_wakeup_requests_company_requested_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "requested_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_wakeup_requests_agent_requested_idx": {+ "name": "agent_wakeup_requests_agent_requested_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "requested_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_wakeup_requests_review_path_recovery_idempotency_uq": {+ "name": "agent_wakeup_requests_review_path_recovery_idempotency_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "idempotency_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_wakeup_requests\".\"idempotency_key\" LIKE 'issue_review_path_lost:%' AND \"agent_wakeup_requests\".\"status\" <> 'skipped'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_wakeup_requests_disposition_repair_idempotency_uq": {+ "name": "agent_wakeup_requests_disposition_repair_idempotency_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "idempotency_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_wakeup_requests\".\"idempotency_key\" LIKE 'issue_disposition_repair:%' AND \"agent_wakeup_requests\".\"status\" <> 'skipped'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_wakeup_requests_question_response_delivery_idempotency_uq": {+ "name": "agent_wakeup_requests_question_response_delivery_idempotency_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "idempotency_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "(\"agent_wakeup_requests\".\"idempotency_key\" LIKE 'question-response:%' OR \"agent_wakeup_requests\".\"idempotency_key\" LIKE 'interaction:%') AND \"agent_wakeup_requests\".\"status\" NOT IN ('skipped', 'failed', 'cancelled')",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_wakeup_requests_connection_intent_delivery_idempotency_uq": {+ "name": "agent_wakeup_requests_connection_intent_delivery_idempotency_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "idempotency_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_wakeup_requests\".\"idempotency_key\" LIKE 'connection-intent:%' AND \"agent_wakeup_requests\".\"status\" NOT IN ('skipped', 'failed', 'cancelled')",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_wakeup_requests_tool_action_delivery_uq": {+ "name": "agent_wakeup_requests_tool_action_delivery_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "idempotency_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_wakeup_requests\".\"idempotency_key\" LIKE 'tool-action-response:%' AND \"agent_wakeup_requests\".\"status\" NOT IN ('skipped', 'failed', 'cancelled')",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_wakeup_requests_company_payload_issue_idx": {+ "name": "agent_wakeup_requests_company_payload_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "(\"payload\" ->> 'issueId')",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_wakeup_requests_company_id_companies_id_fk": {+ "name": "agent_wakeup_requests_company_id_companies_id_fk",+ "tableFrom": "agent_wakeup_requests",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "agent_wakeup_requests_agent_id_agents_id_fk": {+ "name": "agent_wakeup_requests_agent_id_agents_id_fk",+ "tableFrom": "agent_wakeup_requests",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agents": {+ "name": "agents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'general'"+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "appearance": {+ "name": "appearance",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'idle'"+ },+ "reports_to": {+ "name": "reports_to",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "capabilities": {+ "name": "capabilities",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "adapter_type": {+ "name": "adapter_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'process'"+ },+ "adapter_config": {+ "name": "adapter_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "runtime_config": {+ "name": "runtime_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "default_environment_id": {+ "name": "default_environment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "budget_monthly_cents": {+ "name": "budget_monthly_cents",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "spent_monthly_cents": {+ "name": "spent_monthly_cents",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "pause_reason": {+ "name": "pause_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "paused_at": {+ "name": "paused_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "error_reason": {+ "name": "error_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "permissions": {+ "name": "permissions",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "last_heartbeat_at": {+ "name": "last_heartbeat_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agents_company_status_idx": {+ "name": "agents_company_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_company_reports_to_idx": {+ "name": "agents_company_reports_to_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "reports_to",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_company_default_environment_idx": {+ "name": "agents_company_default_environment_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "default_environment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agents_company_id_companies_id_fk": {+ "name": "agents_company_id_companies_id_fk",+ "tableFrom": "agents",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "agents_reports_to_agents_id_fk": {+ "name": "agents_reports_to_agents_id_fk",+ "tableFrom": "agents",+ "tableTo": "agents",+ "columnsFrom": [+ "reports_to"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "agents_default_environment_id_environments_id_fk": {+ "name": "agents_default_environment_id_environments_id_fk",+ "tableFrom": "agents",+ "tableTo": "environments",+ "columnsFrom": [+ "default_environment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "agents_company_id_uq": {+ "name": "agents_company_id_uq",+ "nullsNotDistinct": false,+ "columns": [+ "company_id",+ "id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.ai_connection_defaults": {+ "name": "ai_connection_defaults",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "method": {+ "name": "method",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "grant_id": {+ "name": "grant_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "ai_connection_defaults_owner_method_uq": {+ "name": "ai_connection_defaults_owner_method_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "method",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "ai_connection_defaults_company_id_companies_id_fk": {+ "name": "ai_connection_defaults_company_id_companies_id_fk",+ "tableFrom": "ai_connection_defaults",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "ai_connection_defaults_company_grant_fk": {+ "name": "ai_connection_defaults_company_grant_fk",+ "tableFrom": "ai_connection_defaults",+ "tableTo": "connection_grants",+ "columnsFrom": [+ "company_id",+ "grant_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "ai_connection_defaults_provider_check": {+ "name": "ai_connection_defaults_provider_check",+ "value": "\"ai_connection_defaults\".\"provider\" in ('anthropic','openai','openrouter','xai')"+ },+ "ai_connection_defaults_method_check": {+ "name": "ai_connection_defaults_method_check",+ "value": "\"ai_connection_defaults\".\"method\" in ('subscription','api_key')"+ }+ },+ "isRLSEnabled": false+ },+ "public.ai_provider_defaults": {+ "name": "ai_provider_defaults",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "grant_id": {+ "name": "grant_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "ai_provider_defaults_owner_provider_uq": {+ "name": "ai_provider_defaults_owner_provider_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "ai_provider_defaults_company_id_companies_id_fk": {+ "name": "ai_provider_defaults_company_id_companies_id_fk",+ "tableFrom": "ai_provider_defaults",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "ai_provider_defaults_company_grant_fk": {+ "name": "ai_provider_defaults_company_grant_fk",+ "tableFrom": "ai_provider_defaults",+ "tableTo": "connection_grants",+ "columnsFrom": [+ "company_id",+ "grant_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "ai_provider_defaults_provider_check": {+ "name": "ai_provider_defaults_provider_check",+ "value": "\"ai_provider_defaults\".\"provider\" in ('anthropic','openai','openrouter','xai')"+ }+ },+ "isRLSEnabled": false+ },+ "public.announcement_dismissals": {+ "name": "announcement_dismissals",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "announcement_id": {+ "name": "announcement_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "dismissed_at": {+ "name": "dismissed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "announcement_dismissals_user_id_announcement_id_pk": {+ "name": "announcement_dismissals_user_id_announcement_id_pk",+ "columns": [+ "user_id",+ "announcement_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.announcement_publications": {+ "name": "announcement_publications",+ "schema": "",+ "columns": {+ "announcement_id": {+ "name": "announcement_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.approval_comments": {+ "name": "approval_comments",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "approval_id": {+ "name": "approval_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "author_agent_id": {+ "name": "author_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "author_user_id": {+ "name": "author_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "body": {+ "name": "body",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "approval_comments_company_idx": {+ "name": "approval_comments_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "approval_comments_approval_idx": {+ "name": "approval_comments_approval_idx",+ "columns": [+ {+ "expression": "approval_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "approval_comments_approval_created_idx": {+ "name": "approval_comments_approval_created_idx",+ "columns": [+ {+ "expression": "approval_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "approval_comments_company_id_companies_id_fk": {+ "name": "approval_comments_company_id_companies_id_fk",+ "tableFrom": "approval_comments",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "approval_comments_approval_id_approvals_id_fk": {+ "name": "approval_comments_approval_id_approvals_id_fk",+ "tableFrom": "approval_comments",+ "tableTo": "approvals",+ "columnsFrom": [+ "approval_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "approval_comments_author_agent_id_agents_id_fk": {+ "name": "approval_comments_author_agent_id_agents_id_fk",+ "tableFrom": "approval_comments",+ "tableTo": "agents",+ "columnsFrom": [+ "author_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.approvals": {+ "name": "approvals",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "requested_by_agent_id": {+ "name": "requested_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "requested_by_user_id": {+ "name": "requested_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "decision_note": {+ "name": "decision_note",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "decided_by_user_id": {+ "name": "decided_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "decided_at": {+ "name": "decided_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "approvals_company_status_type_idx": {+ "name": "approvals_company_status_type_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "approvals_company_id_companies_id_fk": {+ "name": "approvals_company_id_companies_id_fk",+ "tableFrom": "approvals",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "approvals_requested_by_agent_id_agents_id_fk": {+ "name": "approvals_requested_by_agent_id_agents_id_fk",+ "tableFrom": "approvals",+ "tableTo": "agents",+ "columnsFrom": [+ "requested_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.assets": {+ "name": "assets",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "object_key": {+ "name": "object_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content_type": {+ "name": "content_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "byte_size": {+ "name": "byte_size",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "sha256": {+ "name": "sha256",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "original_filename": {+ "name": "original_filename",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "assets_company_created_idx": {+ "name": "assets_company_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "assets_company_provider_idx": {+ "name": "assets_company_provider_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "assets_company_object_key_uq": {+ "name": "assets_company_object_key_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "object_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "assets_company_id_companies_id_fk": {+ "name": "assets_company_id_companies_id_fk",+ "tableFrom": "assets",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "assets_created_by_agent_id_agents_id_fk": {+ "name": "assets_created_by_agent_id_agents_id_fk",+ "tableFrom": "assets",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.account": {+ "name": "account",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "issuer": {+ "name": "issuer",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "account_id": {+ "name": "account_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider_id": {+ "name": "provider_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "access_token": {+ "name": "access_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "refresh_token": {+ "name": "refresh_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "id_token": {+ "name": "id_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "access_token_expires_at": {+ "name": "access_token_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "refresh_token_expires_at": {+ "name": "refresh_token_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "password": {+ "name": "password",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "account_issuer_account_id_uq": {+ "name": "account_issuer_account_id_uq",+ "columns": [+ {+ "expression": "issuer",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "account_user_id_user_id_fk": {+ "name": "account_user_id_user_id_fk",+ "tableFrom": "account",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.session": {+ "name": "session",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "ip_address": {+ "name": "ip_address",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_agent": {+ "name": "user_agent",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "session_user_id_user_id_fk": {+ "name": "session_user_id_user_id_fk",+ "tableFrom": "session",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user": {+ "name": "user",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "email_verified": {+ "name": "email_verified",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "image": {+ "name": "image",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.verification": {+ "name": "verification",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.board_api_keys": {+ "name": "board_api_keys",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "key_hash": {+ "name": "key_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "last_used_at": {+ "name": "last_used_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "revoked_at": {+ "name": "revoked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "board_api_keys_key_hash_idx": {+ "name": "board_api_keys_key_hash_idx",+ "columns": [+ {+ "expression": "key_hash",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "board_api_keys_user_idx": {+ "name": "board_api_keys_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "board_api_keys_user_id_user_id_fk": {+ "name": "board_api_keys_user_id_user_id_fk",+ "tableFrom": "board_api_keys",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.budget_incidents": {+ "name": "budget_incidents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "policy_id": {+ "name": "policy_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "scope_type": {+ "name": "scope_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope_id": {+ "name": "scope_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "metric": {+ "name": "metric",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "window_kind": {+ "name": "window_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "window_start": {+ "name": "window_start",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "window_end": {+ "name": "window_end",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "threshold_type": {+ "name": "threshold_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "amount_limit": {+ "name": "amount_limit",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "amount_observed": {+ "name": "amount_observed",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'open'"+ },+ "approval_id": {+ "name": "approval_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_at": {+ "name": "resolved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "budget_incidents_company_status_idx": {+ "name": "budget_incidents_company_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "budget_incidents_company_scope_idx": {+ "name": "budget_incidents_company_scope_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "scope_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "scope_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "budget_incidents_policy_window_threshold_idx": {+ "name": "budget_incidents_policy_window_threshold_idx",+ "columns": [+ {+ "expression": "policy_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "window_start",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "threshold_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"budget_incidents\".\"status\" <> 'dismissed'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "budget_incidents_company_id_companies_id_fk": {+ "name": "budget_incidents_company_id_companies_id_fk",+ "tableFrom": "budget_incidents",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "budget_incidents_policy_id_budget_policies_id_fk": {+ "name": "budget_incidents_policy_id_budget_policies_id_fk",+ "tableFrom": "budget_incidents",+ "tableTo": "budget_policies",+ "columnsFrom": [+ "policy_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "budget_incidents_approval_id_approvals_id_fk": {+ "name": "budget_incidents_approval_id_approvals_id_fk",+ "tableFrom": "budget_incidents",+ "tableTo": "approvals",+ "columnsFrom": [+ "approval_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.budget_policies": {+ "name": "budget_policies",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "scope_type": {+ "name": "scope_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope_id": {+ "name": "scope_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "metric": {+ "name": "metric",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'billed_cents'"+ },+ "window_kind": {+ "name": "window_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "amount": {+ "name": "amount",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "warn_percent": {+ "name": "warn_percent",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 80+ },+ "hard_stop_enabled": {+ "name": "hard_stop_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "notify_enabled": {+ "name": "notify_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "is_active": {+ "name": "is_active",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "updated_by_user_id": {+ "name": "updated_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "budget_policies_company_scope_active_idx": {+ "name": "budget_policies_company_scope_active_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "scope_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "scope_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "is_active",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "budget_policies_company_window_idx": {+ "name": "budget_policies_company_window_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "window_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "metric",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "budget_policies_company_scope_metric_unique_idx": {+ "name": "budget_policies_company_scope_metric_unique_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "scope_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "scope_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "metric",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "window_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "budget_policies_company_id_companies_id_fk": {+ "name": "budget_policies_company_id_companies_id_fk",+ "tableFrom": "budget_policies",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.built_in_managed_resources": {+ "name": "built_in_managed_resources",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "bundle_key": {+ "name": "bundle_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "resource_kind": {+ "name": "resource_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "resource_key": {+ "name": "resource_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "resource_id": {+ "name": "resource_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "stock_version": {+ "name": "stock_version",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "stock_hash": {+ "name": "stock_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "defaults_json": {+ "name": "defaults_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "built_in_managed_resources_company_idx": {+ "name": "built_in_managed_resources_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "built_in_managed_resources_resource_idx": {+ "name": "built_in_managed_resources_resource_idx",+ "columns": [+ {+ "expression": "resource_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "built_in_managed_resources_company_bundle_resource_uq": {+ "name": "built_in_managed_resources_company_bundle_resource_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "bundle_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "built_in_managed_resources_company_id_companies_id_fk": {+ "name": "built_in_managed_resources_company_id_companies_id_fk",+ "tableFrom": "built_in_managed_resources",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.case_attachments": {+ "name": "case_attachments",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "case_id": {+ "name": "case_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "asset_id": {+ "name": "asset_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "case_attachments_company_case_idx": {+ "name": "case_attachments_company_case_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "case_attachments_asset_uq": {+ "name": "case_attachments_asset_uq",+ "columns": [+ {+ "expression": "asset_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "case_attachments_company_id_companies_id_fk": {+ "name": "case_attachments_company_id_companies_id_fk",+ "tableFrom": "case_attachments",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "case_attachments_case_id_cases_id_fk": {+ "name": "case_attachments_case_id_cases_id_fk",+ "tableFrom": "case_attachments",+ "tableTo": "cases",+ "columnsFrom": [+ "case_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "case_attachments_asset_id_assets_id_fk": {+ "name": "case_attachments_asset_id_assets_id_fk",+ "tableFrom": "case_attachments",+ "tableTo": "assets",+ "columnsFrom": [+ "asset_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.case_documents": {+ "name": "case_documents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "case_id": {+ "name": "case_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "document_id": {+ "name": "document_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "case_documents_company_case_key_uq": {+ "name": "case_documents_company_case_key_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "case_documents_document_uq": {+ "name": "case_documents_document_uq",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "case_documents_company_case_updated_idx": {+ "name": "case_documents_company_case_updated_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "case_documents_company_id_companies_id_fk": {+ "name": "case_documents_company_id_companies_id_fk",+ "tableFrom": "case_documents",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "case_documents_case_id_cases_id_fk": {+ "name": "case_documents_case_id_cases_id_fk",+ "tableFrom": "case_documents",+ "tableTo": "cases",+ "columnsFrom": [+ "case_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "case_documents_document_id_documents_id_fk": {+ "name": "case_documents_document_id_documents_id_fk",+ "tableFrom": "case_documents",+ "tableTo": "documents",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.case_events": {+ "name": "case_events",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "case_id": {+ "name": "case_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "actor_type": {+ "name": "actor_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "actor_user_id": {+ "name": "actor_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "actor_agent_id": {+ "name": "actor_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "case_events_case_created_idx": {+ "name": "case_events_case_created_idx",+ "columns": [+ {+ "expression": "case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "case_events_company_case_idx": {+ "name": "case_events_company_case_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "case_events_company_id_companies_id_fk": {+ "name": "case_events_company_id_companies_id_fk",+ "tableFrom": "case_events",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "case_events_case_id_cases_id_fk": {+ "name": "case_events_case_id_cases_id_fk",+ "tableFrom": "case_events",+ "tableTo": "cases",+ "columnsFrom": [+ "case_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "case_events_actor_agent_id_agents_id_fk": {+ "name": "case_events_actor_agent_id_agents_id_fk",+ "tableFrom": "case_events",+ "tableTo": "agents",+ "columnsFrom": [+ "actor_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "case_events_kind_check": {+ "name": "case_events_kind_check",+ "value": "\"case_events\".\"kind\" in (\n 'created',\n 'updated',\n 'fields_changed',\n 'status_changed',\n 'issue_linked',\n 'issue_unlinked',\n 'document_revised',\n 'child_linked',\n 'attachment_added',\n 'label_added',\n 'label_removed'\n )"+ },+ "case_events_actor_type_check": {+ "name": "case_events_actor_type_check",+ "value": "\"case_events\".\"actor_type\" in ('user', 'agent', 'system')"+ }+ },+ "isRLSEnabled": false+ },+ "public.case_issue_links": {+ "name": "case_issue_links",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "case_id": {+ "name": "case_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_run_id": {+ "name": "created_by_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "case_issue_links_case_issue_uq": {+ "name": "case_issue_links_case_issue_uq",+ "columns": [+ {+ "expression": "case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "case_issue_links_company_case_idx": {+ "name": "case_issue_links_company_case_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "case_issue_links_issue_idx": {+ "name": "case_issue_links_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "case_issue_links_company_id_companies_id_fk": {+ "name": "case_issue_links_company_id_companies_id_fk",+ "tableFrom": "case_issue_links",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "case_issue_links_case_id_cases_id_fk": {+ "name": "case_issue_links_case_id_cases_id_fk",+ "tableFrom": "case_issue_links",+ "tableTo": "cases",+ "columnsFrom": [+ "case_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "case_issue_links_issue_id_issues_id_fk": {+ "name": "case_issue_links_issue_id_issues_id_fk",+ "tableFrom": "case_issue_links",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "case_issue_links_role_check": {+ "name": "case_issue_links_role_check",+ "value": "\"case_issue_links\".\"role\" in ('origin', 'work', 'reference')"+ }+ },+ "isRLSEnabled": false+ },+ "public.case_labels": {+ "name": "case_labels",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "case_id": {+ "name": "case_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "label_id": {+ "name": "label_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "case_labels_case_label_uq": {+ "name": "case_labels_case_label_uq",+ "columns": [+ {+ "expression": "case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "label_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "case_labels_company_case_idx": {+ "name": "case_labels_company_case_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "case_labels_label_idx": {+ "name": "case_labels_label_idx",+ "columns": [+ {+ "expression": "label_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "case_labels_company_id_companies_id_fk": {+ "name": "case_labels_company_id_companies_id_fk",+ "tableFrom": "case_labels",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "case_labels_case_id_cases_id_fk": {+ "name": "case_labels_case_id_cases_id_fk",+ "tableFrom": "case_labels",+ "tableTo": "cases",+ "columnsFrom": [+ "case_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "case_labels_label_id_labels_id_fk": {+ "name": "case_labels_label_id_labels_id_fk",+ "tableFrom": "case_labels",+ "tableTo": "labels",+ "columnsFrom": [+ "label_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.cases": {+ "name": "cases",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "case_number": {+ "name": "case_number",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "case_type": {+ "name": "case_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "summary": {+ "name": "summary",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'draft'"+ },+ "fields": {+ "name": "fields",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "parent_case_id": {+ "name": "parent_case_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "cases_company_case_number_uq": {+ "name": "cases_company_case_number_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "case_number",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "cases_identifier_uq": {+ "name": "cases_identifier_uq",+ "columns": [+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "cases_company_type_key_uq": {+ "name": "cases_company_type_key_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "case_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "cases_company_status_idx": {+ "name": "cases_company_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "cases_company_type_idx": {+ "name": "cases_company_type_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "case_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "cases_company_project_idx": {+ "name": "cases_company_project_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "cases_parent_idx": {+ "name": "cases_parent_idx",+ "columns": [+ {+ "expression": "parent_case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "cases_title_search_idx": {+ "name": "cases_title_search_idx",+ "columns": [+ {+ "expression": "title",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "gin_trgm_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "gin",+ "with": {}+ },+ "cases_identifier_search_idx": {+ "name": "cases_identifier_search_idx",+ "columns": [+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "gin_trgm_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "gin",+ "with": {}+ },+ "cases_summary_search_idx": {+ "name": "cases_summary_search_idx",+ "columns": [+ {+ "expression": "summary",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "gin_trgm_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "gin",+ "with": {}+ }+ },+ "foreignKeys": {+ "cases_company_id_companies_id_fk": {+ "name": "cases_company_id_companies_id_fk",+ "tableFrom": "cases",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "cases_project_id_projects_id_fk": {+ "name": "cases_project_id_projects_id_fk",+ "tableFrom": "cases",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "cases_parent_case_id_cases_id_fk": {+ "name": "cases_parent_case_id_cases_id_fk",+ "tableFrom": "cases",+ "tableTo": "cases",+ "columnsFrom": [+ "parent_case_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "cases_created_by_agent_id_agents_id_fk": {+ "name": "cases_created_by_agent_id_agents_id_fk",+ "tableFrom": "cases",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "cases_status_check": {+ "name": "cases_status_check",+ "value": "\"cases\".\"status\" in ('draft', 'in_progress', 'in_review', 'approved', 'done', 'cancelled')"+ }+ },+ "isRLSEnabled": false+ },+ "public.chat_actions": {+ "name": "chat_actions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "endpoint_id": {+ "name": "endpoint_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "delivery_id": {+ "name": "delivery_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "conversation_id": {+ "name": "conversation_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "principal_id": {+ "name": "principal_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider_action_id": {+ "name": "provider_action_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'received'"+ },+ "result": {+ "name": "result",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "chat_actions_provider_action_uq": {+ "name": "chat_actions_provider_action_uq",+ "columns": [+ {+ "expression": "endpoint_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider_action_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "chat_actions_company_id_companies_id_fk": {+ "name": "chat_actions_company_id_companies_id_fk",+ "tableFrom": "chat_actions",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_actions_delivery_id_chat_deliveries_id_fk": {+ "name": "chat_actions_delivery_id_chat_deliveries_id_fk",+ "tableFrom": "chat_actions",+ "tableTo": "chat_deliveries",+ "columnsFrom": [+ "delivery_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "chat_actions_company_delivery_fk": {+ "name": "chat_actions_company_delivery_fk",+ "tableFrom": "chat_actions",+ "tableTo": "chat_deliveries",+ "columnsFrom": [+ "company_id",+ "delivery_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "chat_actions_company_conversation_fk": {+ "name": "chat_actions_company_conversation_fk",+ "tableFrom": "chat_actions",+ "tableTo": "chat_conversations",+ "columnsFrom": [+ "company_id",+ "conversation_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "chat_actions_company_principal_fk": {+ "name": "chat_actions_company_principal_fk",+ "tableFrom": "chat_actions",+ "tableTo": "chat_external_principals",+ "columnsFrom": [+ "company_id",+ "principal_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "chat_actions_company_endpoint_fk": {+ "name": "chat_actions_company_endpoint_fk",+ "tableFrom": "chat_actions",+ "tableTo": "chat_endpoints",+ "columnsFrom": [+ "company_id",+ "endpoint_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.chat_agent_routes": {+ "name": "chat_agent_routes",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "source_endpoint_id": {+ "name": "source_endpoint_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "destination_endpoint_id": {+ "name": "destination_endpoint_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "trigger_mode": {+ "name": "trigger_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'explicit_mention'"+ },+ "max_hops": {+ "name": "max_hops",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "chat_agent_routes_pair_uq": {+ "name": "chat_agent_routes_pair_uq",+ "columns": [+ {+ "expression": "source_endpoint_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "destination_endpoint_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "chat_agent_routes_company_id_companies_id_fk": {+ "name": "chat_agent_routes_company_id_companies_id_fk",+ "tableFrom": "chat_agent_routes",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_agent_routes_company_source_fk": {+ "name": "chat_agent_routes_company_source_fk",+ "tableFrom": "chat_agent_routes",+ "tableTo": "chat_endpoints",+ "columnsFrom": [+ "company_id",+ "source_endpoint_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_agent_routes_company_destination_fk": {+ "name": "chat_agent_routes_company_destination_fk",+ "tableFrom": "chat_agent_routes",+ "tableTo": "chat_endpoints",+ "columnsFrom": [+ "company_id",+ "destination_endpoint_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "chat_agent_routes_hops_check": {+ "name": "chat_agent_routes_hops_check",+ "value": "\"chat_agent_routes\".\"max_hops\" between 1 and 8"+ }+ },+ "isRLSEnabled": false+ },+ "public.chat_conversations": {+ "name": "chat_conversations",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "endpoint_id": {+ "name": "endpoint_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "resource_id": {+ "name": "resource_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "external_conversation_id": {+ "name": "external_conversation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "external_thread_id": {+ "name": "external_thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "session_generation": {+ "name": "session_generation",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "external_label": {+ "name": "external_label",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider_url": {+ "name": "provider_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "is_direct_message": {+ "name": "is_direct_message",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "state": {+ "name": "state",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "last_activity_at": {+ "name": "last_activity_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "chat_conversations_issue_idx": {+ "name": "chat_conversations_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_conversations_thread_uq": {+ "name": "chat_conversations_thread_uq",+ "columns": [+ {+ "expression": "endpoint_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "external_conversation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "external_thread_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "session_generation",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "chat_conversations_company_id_companies_id_fk": {+ "name": "chat_conversations_company_id_companies_id_fk",+ "tableFrom": "chat_conversations",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_conversations_resource_id_chat_endpoint_resources_id_fk": {+ "name": "chat_conversations_resource_id_chat_endpoint_resources_id_fk",+ "tableFrom": "chat_conversations",+ "tableTo": "chat_endpoint_resources",+ "columnsFrom": [+ "resource_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "chat_conversations_issue_id_issues_id_fk": {+ "name": "chat_conversations_issue_id_issues_id_fk",+ "tableFrom": "chat_conversations",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "restrict",+ "onUpdate": "no action"+ },+ "chat_conversations_company_issue_fk": {+ "name": "chat_conversations_company_issue_fk",+ "tableFrom": "chat_conversations",+ "tableTo": "issues",+ "columnsFrom": [+ "company_id",+ "issue_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "chat_conversations_company_endpoint_fk": {+ "name": "chat_conversations_company_endpoint_fk",+ "tableFrom": "chat_conversations",+ "tableTo": "chat_endpoints",+ "columnsFrom": [+ "company_id",+ "endpoint_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_conversations_company_resource_fk": {+ "name": "chat_conversations_company_resource_fk",+ "tableFrom": "chat_conversations",+ "tableTo": "chat_endpoint_resources",+ "columnsFrom": [+ "company_id",+ "resource_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "chat_conversations_company_id_uq": {+ "name": "chat_conversations_company_id_uq",+ "nullsNotDistinct": false,+ "columns": [+ "company_id",+ "id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "chat_conversations_state_check": {+ "name": "chat_conversations_state_check",+ "value": "\"chat_conversations\".\"state\" in ('active', 'waiting', 'completed', 'unavailable', 'endpoint_removed')"+ }+ },+ "isRLSEnabled": false+ },+ "public.chat_deliveries": {+ "name": "chat_deliveries",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "endpoint_id": {+ "name": "endpoint_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "conversation_id": {+ "name": "conversation_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "principal_id": {+ "name": "principal_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "provider_event_id": {+ "name": "provider_event_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "deduplication_key": {+ "name": "deduplication_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "event_kind": {+ "name": "event_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "normalized_event": {+ "name": "normalized_event",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "state": {+ "name": "state",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'received'"+ },+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "redacted_error": {+ "name": "redacted_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "received_at": {+ "name": "received_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "processed_at": {+ "name": "processed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "chat_deliveries_work_idx": {+ "name": "chat_deliveries_work_idx",+ "columns": [+ {+ "expression": "state",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "next_attempt_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_deliveries_event_uq": {+ "name": "chat_deliveries_event_uq",+ "columns": [+ {+ "expression": "endpoint_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider_event_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_deliveries_dedupe_uq": {+ "name": "chat_deliveries_dedupe_uq",+ "columns": [+ {+ "expression": "endpoint_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "deduplication_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "chat_deliveries_company_id_companies_id_fk": {+ "name": "chat_deliveries_company_id_companies_id_fk",+ "tableFrom": "chat_deliveries",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_deliveries_conversation_id_chat_conversations_id_fk": {+ "name": "chat_deliveries_conversation_id_chat_conversations_id_fk",+ "tableFrom": "chat_deliveries",+ "tableTo": "chat_conversations",+ "columnsFrom": [+ "conversation_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "chat_deliveries_principal_id_chat_external_principals_id_fk": {+ "name": "chat_deliveries_principal_id_chat_external_principals_id_fk",+ "tableFrom": "chat_deliveries",+ "tableTo": "chat_external_principals",+ "columnsFrom": [+ "principal_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "chat_deliveries_company_endpoint_fk": {+ "name": "chat_deliveries_company_endpoint_fk",+ "tableFrom": "chat_deliveries",+ "tableTo": "chat_endpoints",+ "columnsFrom": [+ "company_id",+ "endpoint_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_deliveries_company_conversation_fk": {+ "name": "chat_deliveries_company_conversation_fk",+ "tableFrom": "chat_deliveries",+ "tableTo": "chat_conversations",+ "columnsFrom": [+ "company_id",+ "conversation_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "chat_deliveries_company_principal_fk": {+ "name": "chat_deliveries_company_principal_fk",+ "tableFrom": "chat_deliveries",+ "tableTo": "chat_external_principals",+ "columnsFrom": [+ "company_id",+ "principal_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "chat_deliveries_company_id_uq": {+ "name": "chat_deliveries_company_id_uq",+ "nullsNotDistinct": false,+ "columns": [+ "company_id",+ "id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "chat_deliveries_state_check": {+ "name": "chat_deliveries_state_check",+ "value": "\"chat_deliveries\".\"state\" in ('received', 'filtered', 'processing', 'processed', 'retry', 'failed')"+ }+ },+ "isRLSEnabled": false+ },+ "public.chat_endpoint_leases": {+ "name": "chat_endpoint_leases",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "endpoint_id": {+ "name": "endpoint_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "lease_key": {+ "name": "lease_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "chat_endpoint_leases_active_uq": {+ "name": "chat_endpoint_leases_active_uq",+ "columns": [+ {+ "expression": "endpoint_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "lease_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_endpoint_leases_expiry_idx": {+ "name": "chat_endpoint_leases_expiry_idx",+ "columns": [+ {+ "expression": "expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "chat_endpoint_leases_company_id_companies_id_fk": {+ "name": "chat_endpoint_leases_company_id_companies_id_fk",+ "tableFrom": "chat_endpoint_leases",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_endpoint_leases_company_endpoint_fk": {+ "name": "chat_endpoint_leases_company_endpoint_fk",+ "tableFrom": "chat_endpoint_leases",+ "tableTo": "chat_endpoints",+ "columnsFrom": [+ "company_id",+ "endpoint_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.chat_endpoint_resources": {+ "name": "chat_endpoint_resources",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "endpoint_id": {+ "name": "endpoint_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider_resource_id": {+ "name": "provider_resource_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "parent_provider_resource_id": {+ "name": "parent_provider_resource_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "label": {+ "name": "label",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "detail": {+ "name": "detail",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider_url": {+ "name": "provider_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "availability": {+ "name": "availability",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'available'"+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "chat_endpoint_resources_endpoint_idx": {+ "name": "chat_endpoint_resources_endpoint_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "endpoint_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_endpoint_resources_external_uq": {+ "name": "chat_endpoint_resources_external_uq",+ "columns": [+ {+ "expression": "endpoint_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider_resource_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "chat_endpoint_resources_company_id_companies_id_fk": {+ "name": "chat_endpoint_resources_company_id_companies_id_fk",+ "tableFrom": "chat_endpoint_resources",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_endpoint_resources_company_endpoint_fk": {+ "name": "chat_endpoint_resources_company_endpoint_fk",+ "tableFrom": "chat_endpoint_resources",+ "tableTo": "chat_endpoints",+ "columnsFrom": [+ "company_id",+ "endpoint_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "chat_endpoint_resources_company_id_uq": {+ "name": "chat_endpoint_resources_company_id_uq",+ "nullsNotDistinct": false,+ "columns": [+ "company_id",+ "id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "chat_endpoint_resources_availability_check": {+ "name": "chat_endpoint_resources_availability_check",+ "value": "\"chat_endpoint_resources\".\"availability\" in ('available', 'unavailable', 'removed')"+ }+ },+ "isRLSEnabled": false+ },+ "public.chat_endpoints": {+ "name": "chat_endpoints",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "connection_id": {+ "name": "connection_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "public_id": {+ "name": "public_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "publication_mode": {+ "name": "publication_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'automatic'"+ },+ "external_execution_policy": {+ "name": "external_execution_policy",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'restricted'"+ },+ "assigned_agent_id": {+ "name": "assigned_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "sponsor_user_id": {+ "name": "sponsor_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'draft'"+ },+ "deployment_mode": {+ "name": "deployment_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'direct'"+ },+ "provider_account_id": {+ "name": "provider_account_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider_account_label": {+ "name": "provider_account_label",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "bot_external_id": {+ "name": "bot_external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "bot_username": {+ "name": "bot_username",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "bot_display_name": {+ "name": "bot_display_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "bot_avatar_url": {+ "name": "bot_avatar_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "allow_direct_messages": {+ "name": "allow_direct_messages",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "allow_group_chats": {+ "name": "allow_group_chats",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "allow_unlinked_people": {+ "name": "allow_unlinked_people",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "concurrency_policy": {+ "name": "concurrency_policy",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'queue'"+ },+ "capabilities": {+ "name": "capabilities",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{\"threads\":false,\"directMessages\":false,\"nativeStreaming\":false,\"messageEdits\":false,\"messageDeletes\":false,\"reactions\":false,\"files\":false,\"cards\":false,\"actions\":false,\"modals\":false,\"slashCommands\":false,\"ephemeralMessages\":false,\"proactiveDirectMessages\":false}'::jsonb"+ },+ "setup": {+ "name": "setup",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{\"step\":\"provider_setup\"}'::jsonb"+ },+ "health_message": {+ "name": "health_message",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "last_event_at": {+ "name": "last_event_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_publication_at": {+ "name": "last_publication_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "activated_at": {+ "name": "activated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "archived_at": {+ "name": "archived_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "chat_endpoints_company_idx": {+ "name": "chat_endpoints_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_endpoints_agent_idx": {+ "name": "chat_endpoints_agent_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "assigned_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_endpoints_status_idx": {+ "name": "chat_endpoints_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_endpoints_public_id_uq": {+ "name": "chat_endpoints_public_id_uq",+ "columns": [+ {+ "expression": "public_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_endpoints_agentmail_inbox_uq": {+ "name": "chat_endpoints_agentmail_inbox_uq",+ "columns": [+ {+ "expression": "bot_external_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"chat_endpoints\".\"provider\" = 'agentmail' and \"chat_endpoints\".\"status\" != 'archived' and \"chat_endpoints\".\"bot_external_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_endpoints_connection_uq": {+ "name": "chat_endpoints_connection_uq",+ "columns": [+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_endpoints_live_bot_external_uq": {+ "name": "chat_endpoints_live_bot_external_uq",+ "columns": [+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider_account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "bot_external_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"chat_endpoints\".\"status\" in ('verifying', 'active', 'paused', 'attention')\n and \"chat_endpoints\".\"provider_account_id\" is not null\n and \"chat_endpoints\".\"bot_external_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_endpoints_photon_number_uq": {+ "name": "chat_endpoints_photon_number_uq",+ "columns": [+ {+ "expression": "bot_external_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"chat_endpoints\".\"provider\" = 'imessage-photon' and \"chat_endpoints\".\"status\" <> 'archived' and \"chat_endpoints\".\"bot_external_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_endpoints_live_discord_bot_external_uq": {+ "name": "chat_endpoints_live_discord_bot_external_uq",+ "columns": [+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "bot_external_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"chat_endpoints\".\"provider\" = 'discord'\n and \"chat_endpoints\".\"status\" in ('verifying', 'active', 'paused', 'attention')\n and \"chat_endpoints\".\"bot_external_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_endpoints_live_global_app_bot_external_uq": {+ "name": "chat_endpoints_live_global_app_bot_external_uq",+ "columns": [+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "bot_external_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"chat_endpoints\".\"provider\" in ('github', 'microsoft-teams')\n and \"chat_endpoints\".\"status\" in ('verifying', 'active', 'paused', 'attention')\n and \"chat_endpoints\".\"bot_external_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_endpoints_live_bot_username_uq": {+ "name": "chat_endpoints_live_bot_username_uq",+ "columns": [+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider_account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "bot_username",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"chat_endpoints\".\"status\" in ('verifying', 'active', 'paused', 'attention')\n and \"chat_endpoints\".\"provider_account_id\" is not null\n and \"chat_endpoints\".\"bot_username\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "chat_endpoints_company_id_companies_id_fk": {+ "name": "chat_endpoints_company_id_companies_id_fk",+ "tableFrom": "chat_endpoints",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_endpoints_assigned_agent_id_agents_id_fk": {+ "name": "chat_endpoints_assigned_agent_id_agents_id_fk",+ "tableFrom": "chat_endpoints",+ "tableTo": "agents",+ "columnsFrom": [+ "assigned_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "restrict",+ "onUpdate": "no action"+ },+ "chat_endpoints_company_agent_fk": {+ "name": "chat_endpoints_company_agent_fk",+ "tableFrom": "chat_endpoints",+ "tableTo": "agents",+ "columnsFrom": [+ "company_id",+ "assigned_agent_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "chat_endpoints_company_connection_fk": {+ "name": "chat_endpoints_company_connection_fk",+ "tableFrom": "chat_endpoints",+ "tableTo": "tool_connections",+ "columnsFrom": [+ "company_id",+ "connection_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "chat_endpoints_company_id_uq": {+ "name": "chat_endpoints_company_id_uq",+ "nullsNotDistinct": false,+ "columns": [+ "company_id",+ "id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "chat_endpoints_publication_mode_check": {+ "name": "chat_endpoints_publication_mode_check",+ "value": "\"chat_endpoints\".\"publication_mode\" in ('automatic', 'explicit')"+ },+ "chat_endpoints_execution_policy_check": {+ "name": "chat_endpoints_execution_policy_check",+ "value": "\"chat_endpoints\".\"external_execution_policy\" in ('restricted', 'agent')"+ },+ "chat_endpoints_email_policy_check": {+ "name": "chat_endpoints_email_policy_check",+ "value": "\"chat_endpoints\".\"provider\" <> 'agentmail' or (\"chat_endpoints\".\"publication_mode\" = 'explicit' and \"chat_endpoints\".\"external_execution_policy\" = 'agent')"+ },+ "chat_endpoints_provider_check": {+ "name": "chat_endpoints_provider_check",+ "value": "\"chat_endpoints\".\"provider\" in ('slack', 'github', 'discord', 'microsoft-teams', 'telegram', 'agentmail', 'imessage-photon')"+ },+ "chat_endpoints_status_check": {+ "name": "chat_endpoints_status_check",+ "value": "\"chat_endpoints\".\"status\" in ('draft', 'verifying', 'active', 'paused', 'attention', 'revoked', 'archived')"+ },+ "chat_endpoints_deployment_check": {+ "name": "chat_endpoints_deployment_check",+ "value": "\"chat_endpoints\".\"deployment_mode\" in ('direct', 'relay')"+ },+ "chat_endpoints_concurrency_check": {+ "name": "chat_endpoints_concurrency_check",+ "value": "\"chat_endpoints\".\"concurrency_policy\" in ('burst', 'queue', 'debounce', 'drop', 'concurrent')"+ }+ },+ "isRLSEnabled": false+ },+ "public.chat_external_principals": {+ "name": "chat_external_principals",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider_account_id": {+ "name": "provider_account_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "external_id": {+ "name": "external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'user'"+ },+ "display_name": {+ "name": "display_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "handle": {+ "name": "handle",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "avatar_url": {+ "name": "avatar_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "is_bot": {+ "name": "is_bot",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "last_seen_at": {+ "name": "last_seen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "chat_external_principals_company_idx": {+ "name": "chat_external_principals_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_external_principals_external_uq": {+ "name": "chat_external_principals_external_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider_account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "external_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "chat_external_principals_company_id_companies_id_fk": {+ "name": "chat_external_principals_company_id_companies_id_fk",+ "tableFrom": "chat_external_principals",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "chat_external_principals_company_id_uq": {+ "name": "chat_external_principals_company_id_uq",+ "nullsNotDistinct": false,+ "columns": [+ "company_id",+ "id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "chat_external_principals_provider_check": {+ "name": "chat_external_principals_provider_check",+ "value": "\"chat_external_principals\".\"provider\" in ('slack', 'github', 'discord', 'microsoft-teams', 'telegram', 'agentmail', 'imessage-photon')"+ },+ "chat_external_principals_kind_check": {+ "name": "chat_external_principals_kind_check",+ "value": "\"chat_external_principals\".\"kind\" in ('user', 'bot', 'app', 'system')"+ }+ },+ "isRLSEnabled": false+ },+ "public.chat_identity_links": {+ "name": "chat_identity_links",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "endpoint_id": {+ "name": "endpoint_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "principal_id": {+ "name": "principal_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "paperclip_user_id": {+ "name": "paperclip_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "confirmation_token_hash": {+ "name": "confirmation_token_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "confirmed_at": {+ "name": "confirmed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "revoked_at": {+ "name": "revoked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "chat_identity_links_user_idx": {+ "name": "chat_identity_links_user_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "paperclip_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_identity_links_endpoint_principal_uq": {+ "name": "chat_identity_links_endpoint_principal_uq",+ "columns": [+ {+ "expression": "endpoint_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "principal_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "chat_identity_links_company_id_companies_id_fk": {+ "name": "chat_identity_links_company_id_companies_id_fk",+ "tableFrom": "chat_identity_links",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_identity_links_company_endpoint_fk": {+ "name": "chat_identity_links_company_endpoint_fk",+ "tableFrom": "chat_identity_links",+ "tableTo": "chat_endpoints",+ "columnsFrom": [+ "company_id",+ "endpoint_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_identity_links_company_principal_fk": {+ "name": "chat_identity_links_company_principal_fk",+ "tableFrom": "chat_identity_links",+ "tableTo": "chat_external_principals",+ "columnsFrom": [+ "company_id",+ "principal_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "chat_identity_links_status_check": {+ "name": "chat_identity_links_status_check",+ "value": "\"chat_identity_links\".\"status\" in ('pending', 'linked', 'revoked', 'expired')"+ }+ },+ "isRLSEnabled": false+ },+ "public.chat_message_links": {+ "name": "chat_message_links",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "endpoint_id": {+ "name": "endpoint_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "conversation_id": {+ "name": "conversation_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "delivery_id": {+ "name": "delivery_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "publication_id": {+ "name": "publication_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "comment_id": {+ "name": "comment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "provider_message_id": {+ "name": "provider_message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "direction": {+ "name": "direction",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "chat_message_links_provider_message_uq": {+ "name": "chat_message_links_provider_message_uq",+ "columns": [+ {+ "expression": "endpoint_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "conversation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider_message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "chat_message_links_company_id_companies_id_fk": {+ "name": "chat_message_links_company_id_companies_id_fk",+ "tableFrom": "chat_message_links",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_message_links_delivery_id_chat_deliveries_id_fk": {+ "name": "chat_message_links_delivery_id_chat_deliveries_id_fk",+ "tableFrom": "chat_message_links",+ "tableTo": "chat_deliveries",+ "columnsFrom": [+ "delivery_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "chat_message_links_publication_id_chat_publications_id_fk": {+ "name": "chat_message_links_publication_id_chat_publications_id_fk",+ "tableFrom": "chat_message_links",+ "tableTo": "chat_publications",+ "columnsFrom": [+ "publication_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "chat_message_links_comment_id_issue_comments_id_fk": {+ "name": "chat_message_links_comment_id_issue_comments_id_fk",+ "tableFrom": "chat_message_links",+ "tableTo": "issue_comments",+ "columnsFrom": [+ "comment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "chat_message_links_company_endpoint_fk": {+ "name": "chat_message_links_company_endpoint_fk",+ "tableFrom": "chat_message_links",+ "tableTo": "chat_endpoints",+ "columnsFrom": [+ "company_id",+ "endpoint_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_message_links_company_delivery_fk": {+ "name": "chat_message_links_company_delivery_fk",+ "tableFrom": "chat_message_links",+ "tableTo": "chat_deliveries",+ "columnsFrom": [+ "company_id",+ "delivery_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "chat_message_links_company_publication_fk": {+ "name": "chat_message_links_company_publication_fk",+ "tableFrom": "chat_message_links",+ "tableTo": "chat_publications",+ "columnsFrom": [+ "company_id",+ "publication_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "chat_message_links_company_comment_fk": {+ "name": "chat_message_links_company_comment_fk",+ "tableFrom": "chat_message_links",+ "tableTo": "issue_comments",+ "columnsFrom": [+ "company_id",+ "comment_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "chat_message_links_company_conversation_fk": {+ "name": "chat_message_links_company_conversation_fk",+ "tableFrom": "chat_message_links",+ "tableTo": "chat_conversations",+ "columnsFrom": [+ "company_id",+ "conversation_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "chat_message_links_direction_check": {+ "name": "chat_message_links_direction_check",+ "value": "\"chat_message_links\".\"direction\" in ('inbound', 'outbound')"+ }+ },+ "isRLSEnabled": false+ },+ "public.chat_publications": {+ "name": "chat_publications",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "endpoint_id": {+ "name": "endpoint_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "conversation_id": {+ "name": "conversation_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "comment_id": {+ "name": "comment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "idempotency_key": {+ "name": "idempotency_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "state": {+ "name": "state",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "provider_message_id": {+ "name": "provider_message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider_url": {+ "name": "provider_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "redacted_error": {+ "name": "redacted_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "published_at": {+ "name": "published_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "chat_publications_company_id_uq": {+ "name": "chat_publications_company_id_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_publications_work_idx": {+ "name": "chat_publications_work_idx",+ "columns": [+ {+ "expression": "state",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "next_attempt_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_publications_idempotency_uq": {+ "name": "chat_publications_idempotency_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "idempotency_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "chat_publications_company_id_companies_id_fk": {+ "name": "chat_publications_company_id_companies_id_fk",+ "tableFrom": "chat_publications",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_publications_issue_id_issues_id_fk": {+ "name": "chat_publications_issue_id_issues_id_fk",+ "tableFrom": "chat_publications",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "restrict",+ "onUpdate": "no action"+ },+ "chat_publications_comment_id_issue_comments_id_fk": {+ "name": "chat_publications_comment_id_issue_comments_id_fk",+ "tableFrom": "chat_publications",+ "tableTo": "issue_comments",+ "columnsFrom": [+ "comment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "chat_publications_company_issue_fk": {+ "name": "chat_publications_company_issue_fk",+ "tableFrom": "chat_publications",+ "tableTo": "issues",+ "columnsFrom": [+ "company_id",+ "issue_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "chat_publications_company_comment_fk": {+ "name": "chat_publications_company_comment_fk",+ "tableFrom": "chat_publications",+ "tableTo": "issue_comments",+ "columnsFrom": [+ "company_id",+ "comment_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "chat_publications_company_endpoint_fk": {+ "name": "chat_publications_company_endpoint_fk",+ "tableFrom": "chat_publications",+ "tableTo": "chat_endpoints",+ "columnsFrom": [+ "company_id",+ "endpoint_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_publications_company_conversation_fk": {+ "name": "chat_publications_company_conversation_fk",+ "tableFrom": "chat_publications",+ "tableTo": "chat_conversations",+ "columnsFrom": [+ "company_id",+ "conversation_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "chat_publications_state_check": {+ "name": "chat_publications_state_check",+ "value": "\"chat_publications\".\"state\" in ('pending', 'streaming', 'published', 'retry', 'delivery_unknown', 'failed', 'cancelled', 'awaiting_consent')"+ }+ },+ "isRLSEnabled": false+ },+ "public.chat_sdk_state": {+ "name": "chat_sdk_state",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "endpoint_id": {+ "name": "endpoint_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "state_key": {+ "name": "state_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "value": {+ "name": "value",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "chat_sdk_state_key_uq": {+ "name": "chat_sdk_state_key_uq",+ "columns": [+ {+ "expression": "endpoint_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "state_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_sdk_state_expiry_idx": {+ "name": "chat_sdk_state_expiry_idx",+ "columns": [+ {+ "expression": "expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "chat_sdk_state_company_id_companies_id_fk": {+ "name": "chat_sdk_state_company_id_companies_id_fk",+ "tableFrom": "chat_sdk_state",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_sdk_state_company_endpoint_fk": {+ "name": "chat_sdk_state_company_endpoint_fk",+ "tableFrom": "chat_sdk_state",+ "tableTo": "chat_endpoints",+ "columnsFrom": [+ "company_id",+ "endpoint_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.chat_discord_command_owners": {+ "name": "chat_discord_command_owners",+ "schema": "",+ "columns": {+ "application_id": {+ "name": "application_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "endpoint_id": {+ "name": "endpoint_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "action_id": {+ "name": "action_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "chat_discord_command_owners_application_check": {+ "name": "chat_discord_command_owners_application_check",+ "value": "\"chat_discord_command_owners\".\"application_id\" ~ '^[1-9][0-9]{16,19}$'"+ }+ },+ "isRLSEnabled": false+ },+ "public.chat_teams_file_transfers": {+ "name": "chat_teams_file_transfers",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "endpoint_id": {+ "name": "endpoint_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "conversation_id": {+ "name": "conversation_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "publication_id": {+ "name": "publication_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "comment_id": {+ "name": "comment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "attachment_id": {+ "name": "attachment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "principal_id": {+ "name": "principal_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "authorized_user_id": {+ "name": "authorized_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "runtime_generation": {+ "name": "runtime_generation",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "credential_fingerprint": {+ "name": "credential_fingerprint",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "conversation_generation": {+ "name": "conversation_generation",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "source_digest": {+ "name": "source_digest",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "authority_digest": {+ "name": "authority_digest",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "tenant_id": {+ "name": "tenant_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "bot_app_id": {+ "name": "bot_app_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "aad_object_id": {+ "name": "aad_object_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "provider_conversation_id": {+ "name": "provider_conversation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider_user_id": {+ "name": "provider_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "sha256": {+ "name": "sha256",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "byte_size": {+ "name": "byte_size",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "filename": {+ "name": "filename",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "token_sha256": {+ "name": "token_sha256",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "phase": {+ "name": "phase",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'consent_pending'"+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "attempt_id": {+ "name": "attempt_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "attempt_expires_at": {+ "name": "attempt_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "consent_message_id": {+ "name": "consent_message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "file_info_message_id": {+ "name": "file_info_message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "response_activity_id": {+ "name": "response_activity_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "response_digest": {+ "name": "response_digest",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "private_state": {+ "name": "private_state",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "reason": {+ "name": "reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "chat_teams_file_transfers_publication_uq": {+ "name": "chat_teams_file_transfers_publication_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "publication_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_teams_file_transfers_token_uq": {+ "name": "chat_teams_file_transfers_token_uq",+ "columns": [+ {+ "expression": "endpoint_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "token_sha256",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_teams_file_transfers_work_idx": {+ "name": "chat_teams_file_transfers_work_idx",+ "columns": [+ {+ "expression": "phase",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "attempt_expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "chat_teams_file_transfers_company_id_companies_id_fk": {+ "name": "chat_teams_file_transfers_company_id_companies_id_fk",+ "tableFrom": "chat_teams_file_transfers",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_teams_file_transfers_issue_id_issues_id_fk": {+ "name": "chat_teams_file_transfers_issue_id_issues_id_fk",+ "tableFrom": "chat_teams_file_transfers",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "restrict",+ "onUpdate": "no action"+ },+ "chat_teams_file_transfers_company_id_endpoint_id_chat_endpoints_company_id_id_fk": {+ "name": "chat_teams_file_transfers_company_id_endpoint_id_chat_endpoints_company_id_id_fk",+ "tableFrom": "chat_teams_file_transfers",+ "tableTo": "chat_endpoints",+ "columnsFrom": [+ "company_id",+ "endpoint_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_teams_file_transfers_company_id_publication_id_chat_publications_company_id_id_fk": {+ "name": "chat_teams_file_transfers_company_id_publication_id_chat_publications_company_id_id_fk",+ "tableFrom": "chat_teams_file_transfers",+ "tableTo": "chat_publications",+ "columnsFrom": [+ "company_id",+ "publication_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_teams_file_transfers_company_id_conversation_id_chat_conversations_company_id_id_fk": {+ "name": "chat_teams_file_transfers_company_id_conversation_id_chat_conversations_company_id_id_fk",+ "tableFrom": "chat_teams_file_transfers",+ "tableTo": "chat_conversations",+ "columnsFrom": [+ "company_id",+ "conversation_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_teams_file_transfers_company_id_principal_id_chat_external_principals_company_id_id_fk": {+ "name": "chat_teams_file_transfers_company_id_principal_id_chat_external_principals_company_id_id_fk",+ "tableFrom": "chat_teams_file_transfers",+ "tableTo": "chat_external_principals",+ "columnsFrom": [+ "company_id",+ "principal_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "chat_teams_file_transfers_phase_check": {+ "name": "chat_teams_file_transfers_phase_check",+ "value": "\"chat_teams_file_transfers\".\"phase\" in ('consent_pending','consent_sending','consent_unknown','awaiting_consent','upload_pending','uploading','upload_unknown','file_info_pending','file_info_sending','file_info_unknown','delivered','declined','expired','cancelled','conflict')"+ },+ "chat_teams_file_transfers_bounds_check": {+ "name": "chat_teams_file_transfers_bounds_check",+ "value": "\"chat_teams_file_transfers\".\"version\" > 0 and \"chat_teams_file_transfers\".\"runtime_generation\" >= 0 and \"chat_teams_file_transfers\".\"conversation_generation\" > 0 and \"chat_teams_file_transfers\".\"byte_size\" > 0 and \"chat_teams_file_transfers\".\"byte_size\" < 62914560"+ },+ "chat_teams_file_transfers_hash_check": {+ "name": "chat_teams_file_transfers_hash_check",+ "value": "\"chat_teams_file_transfers\".\"source_digest\" ~ '^[a-f0-9]{64}$' and \"chat_teams_file_transfers\".\"authority_digest\" ~ '^[a-f0-9]{64}$' and \"chat_teams_file_transfers\".\"sha256\" ~ '^[a-f0-9]{64}$' and \"chat_teams_file_transfers\".\"token_sha256\" ~ '^[a-f0-9]{64}$'"+ },+ "chat_teams_file_transfers_attempt_check": {+ "name": "chat_teams_file_transfers_attempt_check",+ "value": "(\"chat_teams_file_transfers\".\"attempt_id\" is null) = (\"chat_teams_file_transfers\".\"attempt_expires_at\" is null)"+ }+ },+ "isRLSEnabled": false+ },+ "public.cli_auth_challenges": {+ "name": "cli_auth_challenges",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "secret_hash": {+ "name": "secret_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "command": {+ "name": "command",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_name": {+ "name": "client_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "requested_access": {+ "name": "requested_access",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'board'"+ },+ "requested_company_id": {+ "name": "requested_company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "pending_key_hash": {+ "name": "pending_key_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "pending_key_name": {+ "name": "pending_key_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "approved_by_user_id": {+ "name": "approved_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "board_api_key_id": {+ "name": "board_api_key_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "approved_at": {+ "name": "approved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "cancelled_at": {+ "name": "cancelled_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "cli_auth_challenges_secret_hash_idx": {+ "name": "cli_auth_challenges_secret_hash_idx",+ "columns": [+ {+ "expression": "secret_hash",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "cli_auth_challenges_approved_by_idx": {+ "name": "cli_auth_challenges_approved_by_idx",+ "columns": [+ {+ "expression": "approved_by_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "cli_auth_challenges_requested_company_idx": {+ "name": "cli_auth_challenges_requested_company_idx",+ "columns": [+ {+ "expression": "requested_company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "cli_auth_challenges_requested_company_id_companies_id_fk": {+ "name": "cli_auth_challenges_requested_company_id_companies_id_fk",+ "tableFrom": "cli_auth_challenges",+ "tableTo": "companies",+ "columnsFrom": [+ "requested_company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "cli_auth_challenges_approved_by_user_id_user_id_fk": {+ "name": "cli_auth_challenges_approved_by_user_id_user_id_fk",+ "tableFrom": "cli_auth_challenges",+ "tableTo": "user",+ "columnsFrom": [+ "approved_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "cli_auth_challenges_board_api_key_id_board_api_keys_id_fk": {+ "name": "cli_auth_challenges_board_api_key_id_board_api_keys_id_fk",+ "tableFrom": "cli_auth_challenges",+ "tableTo": "board_api_keys",+ "columnsFrom": [+ "board_api_key_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.companies": {+ "name": "companies",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "pause_reason": {+ "name": "pause_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "paused_at": {+ "name": "paused_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "issue_prefix": {+ "name": "issue_prefix",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'PAP'"+ },+ "issue_counter": {+ "name": "issue_counter",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "budget_monthly_cents": {+ "name": "budget_monthly_cents",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "spent_monthly_cents": {+ "name": "spent_monthly_cents",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "default_responsible_user_id": {+ "name": "default_responsible_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "require_board_approval_for_new_agents": {+ "name": "require_board_approval_for_new_agents",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "interaction_resolver_governance": {+ "name": "interaction_resolver_governance",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "feedback_data_sharing_enabled": {+ "name": "feedback_data_sharing_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "feedback_data_sharing_consent_at": {+ "name": "feedback_data_sharing_consent_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "feedback_data_sharing_consent_by_user_id": {+ "name": "feedback_data_sharing_consent_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "feedback_data_sharing_terms_version": {+ "name": "feedback_data_sharing_terms_version",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "companies_issue_prefix_idx": {+ "name": "companies_issue_prefix_idx",+ "columns": [+ {+ "expression": "issue_prefix",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.company_logos": {+ "name": "company_logos",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "asset_id": {+ "name": "asset_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "company_logos_company_uq": {+ "name": "company_logos_company_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_logos_asset_uq": {+ "name": "company_logos_asset_uq",+ "columns": [+ {+ "expression": "asset_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "company_logos_company_id_companies_id_fk": {+ "name": "company_logos_company_id_companies_id_fk",+ "tableFrom": "company_logos",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "company_logos_asset_id_assets_id_fk": {+ "name": "company_logos_asset_id_assets_id_fk",+ "tableFrom": "company_logos",+ "tableTo": "assets",+ "columnsFrom": [+ "asset_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.company_memberships": {+ "name": "company_memberships",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "principal_type": {+ "name": "principal_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "principal_id": {+ "name": "principal_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "membership_role": {+ "name": "membership_role",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "company_memberships_company_principal_unique_idx": {+ "name": "company_memberships_company_principal_unique_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "principal_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "principal_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_memberships_principal_status_idx": {+ "name": "company_memberships_principal_status_idx",+ "columns": [+ {+ "expression": "principal_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "principal_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_memberships_company_status_idx": {+ "name": "company_memberships_company_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "company_memberships_company_id_companies_id_fk": {+ "name": "company_memberships_company_id_companies_id_fk",+ "tableFrom": "company_memberships",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.company_onboarding_seeds": {+ "name": "company_onboarding_seeds",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "revision": {+ "name": "revision",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "mission": {+ "name": "mission",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_name": {+ "name": "agent_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_role": {+ "name": "agent_role",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "first_task_title": {+ "name": "first_task_title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "first_task_details": {+ "name": "first_task_details",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "goal_id": {+ "name": "goal_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "applied_at": {+ "name": "applied_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "company_onboarding_seeds_company_uq": {+ "name": "company_onboarding_seeds_company_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "company_onboarding_seeds_company_id_companies_id_fk": {+ "name": "company_onboarding_seeds_company_id_companies_id_fk",+ "tableFrom": "company_onboarding_seeds",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "company_onboarding_seeds_goal_id_goals_id_fk": {+ "name": "company_onboarding_seeds_goal_id_goals_id_fk",+ "tableFrom": "company_onboarding_seeds",+ "tableTo": "goals",+ "columnsFrom": [+ "goal_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "company_onboarding_seeds_agent_id_agents_id_fk": {+ "name": "company_onboarding_seeds_agent_id_agents_id_fk",+ "tableFrom": "company_onboarding_seeds",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "company_onboarding_seeds_issue_id_issues_id_fk": {+ "name": "company_onboarding_seeds_issue_id_issues_id_fk",+ "tableFrom": "company_onboarding_seeds",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.company_secret_bindings": {+ "name": "company_secret_bindings",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "secret_id": {+ "name": "secret_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "target_type": {+ "name": "target_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "target_id": {+ "name": "target_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "config_path": {+ "name": "config_path",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "version_selector": {+ "name": "version_selector",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'latest'"+ },+ "required": {+ "name": "required",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "label": {+ "name": "label",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "projection_class": {+ "name": "projection_class",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'unclassified'"+ },+ "projection_allowlist_key": {+ "name": "projection_allowlist_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "company_secret_bindings_company_idx": {+ "name": "company_secret_bindings_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secret_bindings_secret_idx": {+ "name": "company_secret_bindings_secret_idx",+ "columns": [+ {+ "expression": "secret_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secret_bindings_target_idx": {+ "name": "company_secret_bindings_target_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secret_bindings_target_path_uq": {+ "name": "company_secret_bindings_target_path_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "config_path",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "company_secret_bindings_company_id_companies_id_fk": {+ "name": "company_secret_bindings_company_id_companies_id_fk",+ "tableFrom": "company_secret_bindings",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "company_secret_bindings_secret_id_company_secrets_id_fk": {+ "name": "company_secret_bindings_secret_id_company_secrets_id_fk",+ "tableFrom": "company_secret_bindings",+ "tableTo": "company_secrets",+ "columnsFrom": [+ "secret_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.company_secret_proposals": {+ "name": "company_secret_proposals",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "proposed_name": {+ "name": "proposed_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "proposed_key": {+ "name": "proposed_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "proposed_description": {+ "name": "proposed_description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "justification": {+ "name": "justification",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "value_ciphertext": {+ "name": "value_ciphertext",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "value_fingerprint_sha256": {+ "name": "value_fingerprint_sha256",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "value_length": {+ "name": "value_length",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "secret_id": {+ "name": "secret_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "secret_proposal_id": {+ "name": "secret_proposal_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "target_type": {+ "name": "target_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "target_id": {+ "name": "target_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "config_path": {+ "name": "config_path",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "projection_class": {+ "name": "projection_class",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'unclassified'"+ },+ "binding_target_policy_snapshot": {+ "name": "binding_target_policy_snapshot",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "proposer_ancestor_ids_snapshot": {+ "name": "proposer_ancestor_ids_snapshot",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "target_ancestor_ids_snapshot": {+ "name": "target_ancestor_ids_snapshot",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "proposed_by_agent_id": {+ "name": "proposed_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "origin_issue_id": {+ "name": "origin_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "origin_run_id": {+ "name": "origin_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "interaction_id": {+ "name": "interaction_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_by_user_id": {+ "name": "resolved_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_at": {+ "name": "resolved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "resolution_reason": {+ "name": "resolution_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_secret_id": {+ "name": "created_secret_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "applied_binding_config_path": {+ "name": "applied_binding_config_path",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "ciphertext_scrubbed_at": {+ "name": "ciphertext_scrubbed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "company_secret_proposals_company_status_idx": {+ "name": "company_secret_proposals_company_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secret_proposals_proposer_status_idx": {+ "name": "company_secret_proposals_proposer_status_idx",+ "columns": [+ {+ "expression": "proposed_by_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secret_proposals_expiry_idx": {+ "name": "company_secret_proposals_expiry_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secret_proposals_secret_proposal_idx": {+ "name": "company_secret_proposals_secret_proposal_idx",+ "columns": [+ {+ "expression": "secret_proposal_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secret_proposals_interaction_idx": {+ "name": "company_secret_proposals_interaction_idx",+ "columns": [+ {+ "expression": "interaction_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "company_secret_proposals_company_id_companies_id_fk": {+ "name": "company_secret_proposals_company_id_companies_id_fk",+ "tableFrom": "company_secret_proposals",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "company_secret_proposals_secret_id_company_secrets_id_fk": {+ "name": "company_secret_proposals_secret_id_company_secrets_id_fk",+ "tableFrom": "company_secret_proposals",+ "tableTo": "company_secrets",+ "columnsFrom": [+ "secret_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "company_secret_proposals_secret_proposal_id_company_secret_proposals_id_fk": {+ "name": "company_secret_proposals_secret_proposal_id_company_secret_proposals_id_fk",+ "tableFrom": "company_secret_proposals",+ "tableTo": "company_secret_proposals",+ "columnsFrom": [+ "secret_proposal_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "company_secret_proposals_target_id_agents_id_fk": {+ "name": "company_secret_proposals_target_id_agents_id_fk",+ "tableFrom": "company_secret_proposals",+ "tableTo": "agents",+ "columnsFrom": [+ "target_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "company_secret_proposals_proposed_by_agent_id_agents_id_fk": {+ "name": "company_secret_proposals_proposed_by_agent_id_agents_id_fk",+ "tableFrom": "company_secret_proposals",+ "tableTo": "agents",+ "columnsFrom": [+ "proposed_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "company_secret_proposals_origin_issue_id_issues_id_fk": {+ "name": "company_secret_proposals_origin_issue_id_issues_id_fk",+ "tableFrom": "company_secret_proposals",+ "tableTo": "issues",+ "columnsFrom": [+ "origin_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "company_secret_proposals_origin_run_id_heartbeat_runs_id_fk": {+ "name": "company_secret_proposals_origin_run_id_heartbeat_runs_id_fk",+ "tableFrom": "company_secret_proposals",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "origin_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "company_secret_proposals_interaction_id_issue_thread_interactions_id_fk": {+ "name": "company_secret_proposals_interaction_id_issue_thread_interactions_id_fk",+ "tableFrom": "company_secret_proposals",+ "tableTo": "issue_thread_interactions",+ "columnsFrom": [+ "interaction_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "company_secret_proposals_created_secret_id_company_secrets_id_fk": {+ "name": "company_secret_proposals_created_secret_id_company_secrets_id_fk",+ "tableFrom": "company_secret_proposals",+ "tableTo": "company_secrets",+ "columnsFrom": [+ "created_secret_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "company_secret_proposals_kind_check": {+ "name": "company_secret_proposals_kind_check",+ "value": "\"company_secret_proposals\".\"kind\" in ('secret', 'binding')"+ },+ "company_secret_proposals_status_check": {+ "name": "company_secret_proposals_status_check",+ "value": "\"company_secret_proposals\".\"status\" in ('pending', 'approved', 'rejected', 'withdrawn', 'expired')"+ },+ "company_secret_proposals_projection_check": {+ "name": "company_secret_proposals_projection_check",+ "value": "\"company_secret_proposals\".\"projection_class\" = 'unclassified'"+ },+ "company_secret_proposals_shape_check": {+ "name": "company_secret_proposals_shape_check",+ "value": "(\n \"company_secret_proposals\".\"kind\" = 'secret'\n and \"company_secret_proposals\".\"proposed_name\" is not null\n and \"company_secret_proposals\".\"proposed_key\" is not null\n and \"company_secret_proposals\".\"secret_id\" is null\n and \"company_secret_proposals\".\"secret_proposal_id\" is null\n and \"company_secret_proposals\".\"target_type\" is null\n and \"company_secret_proposals\".\"target_id\" is null\n and \"company_secret_proposals\".\"config_path\" is null\n ) or (\n \"company_secret_proposals\".\"kind\" = 'binding'\n and ((\"company_secret_proposals\".\"secret_id\" is not null)::int + (\"company_secret_proposals\".\"secret_proposal_id\" is not null)::int) = 1\n and \"company_secret_proposals\".\"target_type\" = 'agent'\n and \"company_secret_proposals\".\"target_id\" is not null\n and \"company_secret_proposals\".\"config_path\" is not null\n )"+ }+ },+ "isRLSEnabled": false+ },+ "public.company_secret_provider_configs": {+ "name": "company_secret_provider_configs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "display_name": {+ "name": "display_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'ready'"+ },+ "is_default": {+ "name": "is_default",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "health_status": {+ "name": "health_status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "health_checked_at": {+ "name": "health_checked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "health_message": {+ "name": "health_message",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "health_details": {+ "name": "health_details",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "disabled_at": {+ "name": "disabled_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "company_secret_provider_configs_company_idx": {+ "name": "company_secret_provider_configs_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secret_provider_configs_company_provider_idx": {+ "name": "company_secret_provider_configs_company_provider_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secret_provider_configs_default_uq": {+ "name": "company_secret_provider_configs_default_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"company_secret_provider_configs\".\"is_default\" = true",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "company_secret_provider_configs_company_id_companies_id_fk": {+ "name": "company_secret_provider_configs_company_id_companies_id_fk",+ "tableFrom": "company_secret_provider_configs",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "company_secret_provider_configs_created_by_agent_id_agents_id_fk": {+ "name": "company_secret_provider_configs_created_by_agent_id_agents_id_fk",+ "tableFrom": "company_secret_provider_configs",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.company_secret_versions": {+ "name": "company_secret_versions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "secret_id": {+ "name": "secret_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "material": {+ "name": "material",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "value_sha256": {+ "name": "value_sha256",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider_version_ref": {+ "name": "provider_version_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'current'"+ },+ "fingerprint_sha256": {+ "name": "fingerprint_sha256",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "rotation_job_id": {+ "name": "rotation_job_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "revoked_at": {+ "name": "revoked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "company_secret_versions_secret_idx": {+ "name": "company_secret_versions_secret_idx",+ "columns": [+ {+ "expression": "secret_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secret_versions_value_sha256_idx": {+ "name": "company_secret_versions_value_sha256_idx",+ "columns": [+ {+ "expression": "value_sha256",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secret_versions_fingerprint_idx": {+ "name": "company_secret_versions_fingerprint_idx",+ "columns": [+ {+ "expression": "fingerprint_sha256",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secret_versions_secret_version_uq": {+ "name": "company_secret_versions_secret_version_uq",+ "columns": [+ {+ "expression": "secret_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "version",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "company_secret_versions_secret_id_company_secrets_id_fk": {+ "name": "company_secret_versions_secret_id_company_secrets_id_fk",+ "tableFrom": "company_secret_versions",+ "tableTo": "company_secrets",+ "columnsFrom": [+ "secret_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "company_secret_versions_created_by_agent_id_agents_id_fk": {+ "name": "company_secret_versions_created_by_agent_id_agents_id_fk",+ "tableFrom": "company_secret_versions",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.company_secrets": {+ "name": "company_secrets",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'company'"+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_secret_definition_id": {+ "name": "user_secret_definition_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'local_encrypted'"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "managed_mode": {+ "name": "managed_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'paperclip_managed'"+ },+ "external_ref": {+ "name": "external_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider_config_id": {+ "name": "provider_config_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "provider_metadata": {+ "name": "provider_metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "latest_version": {+ "name": "latest_version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "last_resolved_at": {+ "name": "last_resolved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_rotated_at": {+ "name": "last_rotated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "company_secrets_company_idx": {+ "name": "company_secrets_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secrets_company_scope_idx": {+ "name": "company_secrets_company_scope_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "scope",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secrets_company_owner_idx": {+ "name": "company_secrets_company_owner_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secrets_user_definition_owner_idx": {+ "name": "company_secrets_user_definition_owner_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_secret_definition_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secrets_company_provider_idx": {+ "name": "company_secrets_company_provider_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secrets_provider_config_idx": {+ "name": "company_secrets_provider_config_idx",+ "columns": [+ {+ "expression": "provider_config_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secrets_company_name_uq": {+ "name": "company_secrets_company_name_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"company_secrets\".\"scope\" = 'company' and \"company_secrets\".\"deleted_at\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secrets_company_key_uq": {+ "name": "company_secrets_company_key_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"company_secrets\".\"scope\" = 'company' and \"company_secrets\".\"deleted_at\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secrets_user_definition_owner_uq": {+ "name": "company_secrets_user_definition_owner_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_secret_definition_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"company_secrets\".\"scope\" = 'user' and \"company_secrets\".\"deleted_at\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "company_secrets_company_id_companies_id_fk": {+ "name": "company_secrets_company_id_companies_id_fk",+ "tableFrom": "company_secrets",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "company_secrets_user_secret_definition_id_user_secret_definitions_id_fk": {+ "name": "company_secrets_user_secret_definition_id_user_secret_definitions_id_fk",+ "tableFrom": "company_secrets",+ "tableTo": "user_secret_definitions",+ "columnsFrom": [+ "user_secret_definition_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "company_secrets_provider_config_id_company_secret_provider_configs_id_fk": {+ "name": "company_secrets_provider_config_id_company_secret_provider_configs_id_fk",+ "tableFrom": "company_secrets",+ "tableTo": "company_secret_provider_configs",+ "columnsFrom": [+ "provider_config_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "company_secrets_created_by_agent_id_agents_id_fk": {+ "name": "company_secrets_created_by_agent_id_agents_id_fk",+ "tableFrom": "company_secrets",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "company_secrets_scope_shape_check": {+ "name": "company_secrets_scope_shape_check",+ "value": "(\n \"company_secrets\".\"scope\" = 'company'\n and \"company_secrets\".\"owner_user_id\" is null\n and \"company_secrets\".\"user_secret_definition_id\" is null\n ) or (\n \"company_secrets\".\"scope\" = 'user'\n and \"company_secrets\".\"owner_user_id\" is not null\n and \"company_secrets\".\"user_secret_definition_id\" is not null\n )"+ }+ },+ "isRLSEnabled": false+ },+ "public.company_skill_policies": {+ "name": "company_skill_policies",+ "schema": "",+ "columns": {+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true+ },+ "schema_version": {+ "name": "schema_version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "revision": {+ "name": "revision",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "default_effect": {+ "name": "default_effect",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "rules": {+ "name": "rules",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "company_skill_policies_company_id_companies_id_fk": {+ "name": "company_skill_policies_company_id_companies_id_fk",+ "tableFrom": "company_skill_policies",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.company_skill_comments": {+ "name": "company_skill_comments",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "company_skill_id": {+ "name": "company_skill_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "parent_comment_id": {+ "name": "parent_comment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "author_agent_id": {+ "name": "author_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "author_user_id": {+ "name": "author_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "body": {+ "name": "body",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "company_skill_comments_company_skill_created_idx": {+ "name": "company_skill_comments_company_skill_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "company_skill_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_skill_comments_parent_idx": {+ "name": "company_skill_comments_parent_idx",+ "columns": [+ {+ "expression": "parent_comment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "company_skill_comments_company_id_companies_id_fk": {+ "name": "company_skill_comments_company_id_companies_id_fk",+ "tableFrom": "company_skill_comments",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "company_skill_comments_company_skill_id_company_skills_id_fk": {+ "name": "company_skill_comments_company_skill_id_company_skills_id_fk",+ "tableFrom": "company_skill_comments",+ "tableTo": "company_skills",+ "columnsFrom": [+ "company_skill_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "company_skill_comments_parent_comment_id_company_skill_comments_id_fk": {+ "name": "company_skill_comments_parent_comment_id_company_skill_comments_id_fk",+ "tableFrom": "company_skill_comments",+ "tableTo": "company_skill_comments",+ "columnsFrom": [+ "parent_comment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "company_skill_comments_author_agent_id_agents_id_fk": {+ "name": "company_skill_comments_author_agent_id_agents_id_fk",+ "tableFrom": "company_skill_comments",+ "tableTo": "agents",+ "columnsFrom": [+ "author_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.company_skill_stars": {+ "name": "company_skill_stars",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "company_skill_id": {+ "name": "company_skill_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "company_skill_stars_skill_agent_idx": {+ "name": "company_skill_stars_skill_agent_idx",+ "columns": [+ {+ "expression": "company_skill_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_skill_stars_skill_user_idx": {+ "name": "company_skill_stars_skill_user_idx",+ "columns": [+ {+ "expression": "company_skill_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_skill_stars_company_skill_created_idx": {+ "name": "company_skill_stars_company_skill_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "company_skill_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "company_skill_stars_company_id_companies_id_fk": {+ "name": "company_skill_stars_company_id_companies_id_fk",+ "tableFrom": "company_skill_stars",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "company_skill_stars_company_skill_id_company_skills_id_fk": {+ "name": "company_skill_stars_company_skill_id_company_skills_id_fk",+ "tableFrom": "company_skill_stars",+ "tableTo": "company_skills",+ "columnsFrom": [+ "company_skill_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "company_skill_stars_agent_id_agents_id_fk": {+ "name": "company_skill_stars_agent_id_agents_id_fk",+ "tableFrom": "company_skill_stars",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.company_skill_test_inputs": {+ "name": "company_skill_test_inputs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "skill_id": {+ "name": "skill_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_by": {+ "name": "created_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "company_skill_test_inputs_company_skill_name_idx": {+ "name": "company_skill_test_inputs_company_skill_name_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "skill_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_skill_test_inputs_company_skill_active_idx": {+ "name": "company_skill_test_inputs_company_skill_active_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "skill_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "deleted_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "company_skill_test_inputs_company_id_companies_id_fk": {+ "name": "company_skill_test_inputs_company_id_companies_id_fk",+ "tableFrom": "company_skill_test_inputs",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "company_skill_test_inputs_skill_id_company_skills_id_fk": {+ "name": "company_skill_test_inputs_skill_id_company_skills_id_fk",+ "tableFrom": "company_skill_test_inputs",+ "tableTo": "company_skills",+ "columnsFrom": [+ "skill_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.company_skill_test_run_templates": {+ "name": "company_skill_test_run_templates",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "body": {+ "name": "body",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "updated_by_agent_id": {+ "name": "updated_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "updated_by_user_id": {+ "name": "updated_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "company_skill_test_run_templates_company_active_idx": {+ "name": "company_skill_test_run_templates_company_active_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "deleted_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "company_skill_test_run_templates_company_id_companies_id_fk": {+ "name": "company_skill_test_run_templates_company_id_companies_id_fk",+ "tableFrom": "company_skill_test_run_templates",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "company_skill_test_run_templates_created_by_agent_id_agents_id_fk": {+ "name": "company_skill_test_run_templates_created_by_agent_id_agents_id_fk",+ "tableFrom": "company_skill_test_run_templates",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "company_skill_test_run_templates_updated_by_agent_id_agents_id_fk": {+ "name": "company_skill_test_run_templates_updated_by_agent_id_agents_id_fk",+ "tableFrom": "company_skill_test_run_templates",+ "tableTo": "agents",+ "columnsFrom": [+ "updated_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.company_skill_test_runs": {+ "name": "company_skill_test_runs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "skill_id": {+ "name": "skill_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "input_id": {+ "name": "input_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "input_snapshot": {+ "name": "input_snapshot",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "skill_version_id": {+ "name": "skill_version_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "agent_config_snapshot": {+ "name": "agent_config_snapshot",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "template_id": {+ "name": "template_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "template_name": {+ "name": "template_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "template_body": {+ "name": "template_body",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "rendered_template_body": {+ "name": "rendered_template_body",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "harness_issue_description": {+ "name": "harness_issue_description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'queued'"+ },+ "output_document_key": {+ "name": "output_document_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'output'"+ },+ "output_snapshot": {+ "name": "output_snapshot",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "error": {+ "name": "error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "superseded_at": {+ "name": "superseded_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "harness_issue_expires_at": {+ "name": "harness_issue_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "harness_issue_deleted_at": {+ "name": "harness_issue_deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "company_skill_test_runs_company_skill_created_idx": {+ "name": "company_skill_test_runs_company_skill_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "skill_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_skill_test_runs_company_issue_idx": {+ "name": "company_skill_test_runs_company_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_skill_test_runs_company_input_created_idx": {+ "name": "company_skill_test_runs_company_input_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "input_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_skill_test_runs_company_status_idx": {+ "name": "company_skill_test_runs_company_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_skill_test_runs_company_harness_expires_idx": {+ "name": "company_skill_test_runs_company_harness_expires_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "harness_issue_expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "company_skill_test_runs_company_id_companies_id_fk": {+ "name": "company_skill_test_runs_company_id_companies_id_fk",+ "tableFrom": "company_skill_test_runs",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "company_skill_test_runs_skill_id_company_skills_id_fk": {+ "name": "company_skill_test_runs_skill_id_company_skills_id_fk",+ "tableFrom": "company_skill_test_runs",+ "tableTo": "company_skills",+ "columnsFrom": [+ "skill_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "company_skill_test_runs_input_id_company_skill_test_inputs_id_fk": {+ "name": "company_skill_test_runs_input_id_company_skill_test_inputs_id_fk",+ "tableFrom": "company_skill_test_runs",+ "tableTo": "company_skill_test_inputs",+ "columnsFrom": [+ "input_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "company_skill_test_runs_skill_version_id_company_skill_versions_id_fk": {+ "name": "company_skill_test_runs_skill_version_id_company_skill_versions_id_fk",+ "tableFrom": "company_skill_test_runs",+ "tableTo": "company_skill_versions",+ "columnsFrom": [+ "skill_version_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "restrict",+ "onUpdate": "no action"+ },+ "company_skill_test_runs_agent_id_agents_id_fk": {+ "name": "company_skill_test_runs_agent_id_agents_id_fk",+ "tableFrom": "company_skill_test_runs",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "restrict",+ "onUpdate": "no action"+ },+ "company_skill_test_runs_issue_id_issues_id_fk": {+ "name": "company_skill_test_runs_issue_id_issues_id_fk",+ "tableFrom": "company_skill_test_runs",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "restrict",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.company_skill_versions": {+ "name": "company_skill_versions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "company_skill_id": {+ "name": "company_skill_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "revision_number": {+ "name": "revision_number",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "label": {+ "name": "label",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "release_id": {+ "name": "release_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "release_name": {+ "name": "release_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "released_at": {+ "name": "released_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "file_inventory": {+ "name": "file_inventory",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "author_agent_id": {+ "name": "author_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "author_user_id": {+ "name": "author_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "company_skill_versions_skill_revision_idx": {+ "name": "company_skill_versions_skill_revision_idx",+ "columns": [+ {+ "expression": "company_skill_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "revision_number",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_skill_versions_skill_release_idx": {+ "name": "company_skill_versions_skill_release_idx",+ "columns": [+ {+ "expression": "company_skill_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "release_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"company_skill_versions\".\"release_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_skill_versions_company_skill_created_idx": {+ "name": "company_skill_versions_company_skill_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "company_skill_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "company_skill_versions_company_id_companies_id_fk": {+ "name": "company_skill_versions_company_id_companies_id_fk",+ "tableFrom": "company_skill_versions",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "company_skill_versions_company_skill_id_company_skills_id_fk": {+ "name": "company_skill_versions_company_skill_id_company_skills_id_fk",+ "tableFrom": "company_skill_versions",+ "tableTo": "company_skills",+ "columnsFrom": [+ "company_skill_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "company_skill_versions_author_agent_id_agents_id_fk": {+ "name": "company_skill_versions_author_agent_id_agents_id_fk",+ "tableFrom": "company_skill_versions",+ "tableTo": "agents",+ "columnsFrom": [+ "author_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.company_skills": {+ "name": "company_skills",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "folder_id": {+ "name": "folder_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "slug": {+ "name": "slug",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "markdown": {+ "name": "markdown",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_type": {+ "name": "source_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'local_path'"+ },+ "source_locator": {+ "name": "source_locator",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source_ref": {+ "name": "source_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "trust_level": {+ "name": "trust_level",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'markdown_only'"+ },+ "compatibility": {+ "name": "compatibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'compatible'"+ },+ "file_inventory": {+ "name": "file_inventory",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "icon_url": {+ "name": "icon_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "tagline": {+ "name": "tagline",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "author_name": {+ "name": "author_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "homepage_url": {+ "name": "homepage_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "categories": {+ "name": "categories",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'"+ },+ "sharing_scope": {+ "name": "sharing_scope",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'company'"+ },+ "public_share_token": {+ "name": "public_share_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "forked_from_skill_id": {+ "name": "forked_from_skill_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "forked_from_company_id": {+ "name": "forked_from_company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "star_count": {+ "name": "star_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "install_count": {+ "name": "install_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "fork_count": {+ "name": "fork_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "current_version_id": {+ "name": "current_version_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "company_skills_company_key_idx": {+ "name": "company_skills_company_key_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_skills_company_name_idx": {+ "name": "company_skills_company_name_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_skills_company_folder_idx": {+ "name": "company_skills_company_folder_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "folder_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_skills_company_categories_idx": {+ "name": "company_skills_company_categories_idx",+ "columns": [+ {+ "expression": "categories",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "gin",+ "with": {}+ },+ "company_skills_company_sharing_scope_idx": {+ "name": "company_skills_company_sharing_scope_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "sharing_scope",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_skills_company_current_version_idx": {+ "name": "company_skills_company_current_version_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "current_version_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_skills_company_forked_from_idx": {+ "name": "company_skills_company_forked_from_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "forked_from_skill_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "company_skills_company_id_companies_id_fk": {+ "name": "company_skills_company_id_companies_id_fk",+ "tableFrom": "company_skills",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "company_skills_folder_id_folders_id_fk": {+ "name": "company_skills_folder_id_folders_id_fk",+ "tableFrom": "company_skills",+ "tableTo": "folders",+ "columnsFrom": [+ "folder_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "company_skills_forked_from_skill_id_company_skills_id_fk": {+ "name": "company_skills_forked_from_skill_id_company_skills_id_fk",+ "tableFrom": "company_skills",+ "tableTo": "company_skills",+ "columnsFrom": [+ "forked_from_skill_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "company_skills_forked_from_company_id_companies_id_fk": {+ "name": "company_skills_forked_from_company_id_companies_id_fk",+ "tableFrom": "company_skills",+ "tableTo": "companies",+ "columnsFrom": [+ "forked_from_company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "company_skills_current_version_id_company_skill_versions_id_fk": {+ "name": "company_skills_current_version_id_company_skill_versions_id_fk",+ "tableFrom": "company_skills",+ "tableTo": "company_skill_versions",+ "columnsFrom": [+ "current_version_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.company_transfer_runs": {+ "name": "company_transfer_runs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "direction": {+ "name": "direction",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "actor_key": {+ "name": "actor_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "container_ref": {+ "name": "container_ref",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "idempotency_key": {+ "name": "idempotency_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "manifest_sha256": {+ "name": "manifest_sha256",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "manifest": {+ "name": "manifest",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "chunk_count": {+ "name": "chunk_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "blob_count": {+ "name": "blob_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "completed_parts": {+ "name": "completed_parts",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "error": {+ "name": "error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "finished_at": {+ "name": "finished_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "company_transfer_runs_company_idx": {+ "name": "company_transfer_runs_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_transfer_runs_idempotency_direction_idx": {+ "name": "company_transfer_runs_idempotency_direction_idx",+ "columns": [+ {+ "expression": "idempotency_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "direction",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_transfer_runs_actor_status_idx": {+ "name": "company_transfer_runs_actor_status_idx",+ "columns": [+ {+ "expression": "actor_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "company_transfer_runs_company_id_companies_id_fk": {+ "name": "company_transfer_runs_company_id_companies_id_fk",+ "tableFrom": "company_transfer_runs",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.company_user_sidebar_preferences": {+ "name": "company_user_sidebar_preferences",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "project_order": {+ "name": "project_order",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "company_user_sidebar_preferences_company_idx": {+ "name": "company_user_sidebar_preferences_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_user_sidebar_preferences_user_idx": {+ "name": "company_user_sidebar_preferences_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_user_sidebar_preferences_company_user_uq": {+ "name": "company_user_sidebar_preferences_company_user_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "company_user_sidebar_preferences_company_id_companies_id_fk": {+ "name": "company_user_sidebar_preferences_company_id_companies_id_fk",+ "tableFrom": "company_user_sidebar_preferences",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.completion_contracts": {+ "name": "completion_contracts",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "revision": {+ "name": "revision",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "schema_version": {+ "name": "schema_version",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "policy_version": {+ "name": "policy_version",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "risk": {+ "name": "risk",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "completion_authority": {+ "name": "completion_authority",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "incomplete_criteria_policy": {+ "name": "incomplete_criteria_policy",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "contract_json": {+ "name": "contract_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "canonical_sha256": {+ "name": "canonical_sha256",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_actor_type": {+ "name": "created_by_actor_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_actor_id": {+ "name": "created_by_actor_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "supersedes_contract_id": {+ "name": "supersedes_contract_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "completion_contracts_issue_revision_uq": {+ "name": "completion_contracts_issue_revision_uq",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "revision",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "completion_contracts_issue_hash_uq": {+ "name": "completion_contracts_issue_hash_uq",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "canonical_sha256",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "completion_contracts_company_id_companies_id_fk": {+ "name": "completion_contracts_company_id_companies_id_fk",+ "tableFrom": "completion_contracts",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "completion_contracts_issue_company_fk": {+ "name": "completion_contracts_issue_company_fk",+ "tableFrom": "completion_contracts",+ "tableTo": "issues",+ "columnsFrom": [+ "company_id",+ "issue_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "completion_contracts_supersedes_owner_fk": {+ "name": "completion_contracts_supersedes_owner_fk",+ "tableFrom": "completion_contracts",+ "tableTo": "completion_contracts",+ "columnsFrom": [+ "company_id",+ "issue_id",+ "supersedes_contract_id"+ ],+ "columnsTo": [+ "company_id",+ "issue_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "completion_contracts_company_issue_id_uq": {+ "name": "completion_contracts_company_issue_id_uq",+ "nullsNotDistinct": false,+ "columns": [+ "company_id",+ "issue_id",+ "id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.connection_event_deliveries": {+ "name": "connection_event_deliveries",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider_delivery_id": {+ "name": "provider_delivery_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "event": {+ "name": "event",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "action": {+ "name": "action",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "installation_id": {+ "name": "installation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "repository_id": {+ "name": "repository_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "normalized_payload": {+ "name": "normalized_payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'received'"+ },+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider_created_at": {+ "name": "provider_created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "processed_at": {+ "name": "processed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "connection_event_deliveries_company_provider_id_uq": {+ "name": "connection_event_deliveries_company_provider_id_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider_delivery_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "connection_event_deliveries_company_status_idx": {+ "name": "connection_event_deliveries_company_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "connection_event_deliveries_company_id_companies_id_fk": {+ "name": "connection_event_deliveries_company_id_companies_id_fk",+ "tableFrom": "connection_event_deliveries",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.connection_intent_deliveries": {+ "name": "connection_intent_deliveries",+ "schema": "",+ "columns": {+ "interaction_id": {+ "name": "interaction_id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "delivered_at": {+ "name": "delivered_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "connection_intent_deliveries_pending_idx": {+ "name": "connection_intent_deliveries_pending_idx",+ "columns": [+ {+ "expression": "delivered_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "next_attempt_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "connection_intent_deliveries_interaction_id_issue_thread_interactions_id_fk": {+ "name": "connection_intent_deliveries_interaction_id_issue_thread_interactions_id_fk",+ "tableFrom": "connection_intent_deliveries",+ "tableTo": "issue_thread_interactions",+ "columnsFrom": [+ "interaction_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "connection_intent_deliveries_company_id_companies_id_fk": {+ "name": "connection_intent_deliveries_company_id_companies_id_fk",+ "tableFrom": "connection_intent_deliveries",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.cost_events": {+ "name": "cost_events",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "project_id": {+ "name": "project_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "goal_id": {+ "name": "goal_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "heartbeat_run_id": {+ "name": "heartbeat_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "billing_code": {+ "name": "billing_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "biller": {+ "name": "biller",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'unknown'"+ },+ "billing_type": {+ "name": "billing_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'unknown'"+ },+ "cost_status": {+ "name": "cost_status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'reported'"+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "input_tokens": {+ "name": "input_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "cached_input_tokens": {+ "name": "cached_input_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "output_tokens": {+ "name": "output_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "cost_cents": {+ "name": "cost_cents",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "occurred_at": {+ "name": "occurred_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "cost_events_company_occurred_idx": {+ "name": "cost_events_company_occurred_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "occurred_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "cost_events_company_agent_occurred_idx": {+ "name": "cost_events_company_agent_occurred_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "occurred_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "cost_events_company_provider_occurred_idx": {+ "name": "cost_events_company_provider_occurred_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "occurred_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "cost_events_company_biller_occurred_idx": {+ "name": "cost_events_company_biller_occurred_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "biller",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "occurred_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "cost_events_company_heartbeat_run_idx": {+ "name": "cost_events_company_heartbeat_run_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "heartbeat_run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "cost_events_company_id_companies_id_fk": {+ "name": "cost_events_company_id_companies_id_fk",+ "tableFrom": "cost_events",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "cost_events_agent_id_agents_id_fk": {+ "name": "cost_events_agent_id_agents_id_fk",+ "tableFrom": "cost_events",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "cost_events_issue_id_issues_id_fk": {+ "name": "cost_events_issue_id_issues_id_fk",+ "tableFrom": "cost_events",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "cost_events_project_id_projects_id_fk": {+ "name": "cost_events_project_id_projects_id_fk",+ "tableFrom": "cost_events",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "cost_events_goal_id_goals_id_fk": {+ "name": "cost_events_goal_id_goals_id_fk",+ "tableFrom": "cost_events",+ "tableTo": "goals",+ "columnsFrom": [+ "goal_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "cost_events_heartbeat_run_id_heartbeat_runs_id_fk": {+ "name": "cost_events_heartbeat_run_id_heartbeat_runs_id_fk",+ "tableFrom": "cost_events",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "heartbeat_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.decision_archive_notification_outbox": {+ "name": "decision_archive_notification_outbox",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "source_kind": {+ "name": "source_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_id": {+ "name": "source_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "archive_version": {+ "name": "archive_version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "origin_agent_id": {+ "name": "origin_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "origin_issue_id": {+ "name": "origin_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "attempt_count": {+ "name": "attempt_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "last_attempt_at": {+ "name": "last_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "delivered_at": {+ "name": "delivered_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "decision_archive_notification_outbox_uq": {+ "name": "decision_archive_notification_outbox_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "archive_version",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "origin_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "decision_archive_notification_outbox_pending_idx": {+ "name": "decision_archive_notification_outbox_pending_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "decision_archive_notification_outbox_company_id_companies_id_fk": {+ "name": "decision_archive_notification_outbox_company_id_companies_id_fk",+ "tableFrom": "decision_archive_notification_outbox",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "decision_archive_notification_outbox_origin_agent_id_agents_id_fk": {+ "name": "decision_archive_notification_outbox_origin_agent_id_agents_id_fk",+ "tableFrom": "decision_archive_notification_outbox",+ "tableTo": "agents",+ "columnsFrom": [+ "origin_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "decision_archive_notification_outbox_status_check": {+ "name": "decision_archive_notification_outbox_status_check",+ "value": "\"decision_archive_notification_outbox\".\"status\" IN ('pending', 'delivering', 'delivered')"+ }+ },+ "isRLSEnabled": false+ },+ "public.decision_queue_items": {+ "name": "decision_queue_items",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "queue_id": {+ "name": "queue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "source_kind": {+ "name": "source_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_id": {+ "name": "source_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "added_by_type": {+ "name": "added_by_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "added_by_agent_id": {+ "name": "added_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "added_by_user_id": {+ "name": "added_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "added_by_run_id": {+ "name": "added_by_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "added_by_agent_api_key_id": {+ "name": "added_by_agent_api_key_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "responsible_user_id": {+ "name": "responsible_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "decision_queue_items_queue_source_uq": {+ "name": "decision_queue_items_queue_source_uq",+ "columns": [+ {+ "expression": "queue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "decision_queue_items_company_source_idx": {+ "name": "decision_queue_items_company_source_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "decision_queue_items_company_id_companies_id_fk": {+ "name": "decision_queue_items_company_id_companies_id_fk",+ "tableFrom": "decision_queue_items",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "decision_queue_items_added_by_agent_id_agents_id_fk": {+ "name": "decision_queue_items_added_by_agent_id_agents_id_fk",+ "tableFrom": "decision_queue_items",+ "tableTo": "agents",+ "columnsFrom": [+ "added_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "decision_queue_items_added_by_run_id_heartbeat_runs_id_fk": {+ "name": "decision_queue_items_added_by_run_id_heartbeat_runs_id_fk",+ "tableFrom": "decision_queue_items",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "added_by_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "decision_queue_items_added_by_agent_api_key_id_agent_api_keys_id_fk": {+ "name": "decision_queue_items_added_by_agent_api_key_id_agent_api_keys_id_fk",+ "tableFrom": "decision_queue_items",+ "tableTo": "agent_api_keys",+ "columnsFrom": [+ "added_by_agent_api_key_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "decision_queue_items_queue_company_fk": {+ "name": "decision_queue_items_queue_company_fk",+ "tableFrom": "decision_queue_items",+ "tableTo": "decision_queues",+ "columnsFrom": [+ "queue_id",+ "company_id"+ ],+ "columnsTo": [+ "id",+ "company_id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "decision_queue_items_actor_check": {+ "name": "decision_queue_items_actor_check",+ "value": "(\n (\"decision_queue_items\".\"added_by_type\" = 'agent' AND \"decision_queue_items\".\"added_by_agent_id\" IS NOT NULL AND \"decision_queue_items\".\"added_by_user_id\" IS NULL)\n OR (\"decision_queue_items\".\"added_by_type\" = 'user' AND \"decision_queue_items\".\"added_by_agent_id\" IS NULL AND \"decision_queue_items\".\"added_by_user_id\" IS NOT NULL)\n OR (\"decision_queue_items\".\"added_by_type\" = 'system' AND \"decision_queue_items\".\"added_by_agent_id\" IS NULL AND \"decision_queue_items\".\"added_by_user_id\" IS NULL)\n )"+ }+ },+ "isRLSEnabled": false+ },+ "public.decision_queues": {+ "name": "decision_queues",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_type": {+ "name": "created_by_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_run_id": {+ "name": "created_by_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_api_key_id": {+ "name": "created_by_agent_api_key_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "retention_days": {+ "name": "retention_days",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "seed_rules": {+ "name": "seed_rules",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "seed_rules_enabled": {+ "name": "seed_rules_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "decision_queues_company_key_uq": {+ "name": "decision_queues_company_key_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "decision_queues_company_updated_idx": {+ "name": "decision_queues_company_updated_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "decision_queues_company_id_companies_id_fk": {+ "name": "decision_queues_company_id_companies_id_fk",+ "tableFrom": "decision_queues",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "decision_queues_created_by_agent_id_agents_id_fk": {+ "name": "decision_queues_created_by_agent_id_agents_id_fk",+ "tableFrom": "decision_queues",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "decision_queues_created_by_run_id_heartbeat_runs_id_fk": {+ "name": "decision_queues_created_by_run_id_heartbeat_runs_id_fk",+ "tableFrom": "decision_queues",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "created_by_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "decision_queues_created_by_agent_api_key_id_agent_api_keys_id_fk": {+ "name": "decision_queues_created_by_agent_api_key_id_agent_api_keys_id_fk",+ "tableFrom": "decision_queues",+ "tableTo": "agent_api_keys",+ "columnsFrom": [+ "created_by_agent_api_key_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "decision_queues_id_company_uq": {+ "name": "decision_queues_id_company_uq",+ "nullsNotDistinct": false,+ "columns": [+ "id",+ "company_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "decision_queues_creator_check": {+ "name": "decision_queues_creator_check",+ "value": "(\n (\"decision_queues\".\"created_by_type\" = 'agent' AND \"decision_queues\".\"created_by_agent_id\" IS NOT NULL AND \"decision_queues\".\"created_by_user_id\" IS NULL)\n OR (\"decision_queues\".\"created_by_type\" = 'user' AND \"decision_queues\".\"created_by_agent_id\" IS NULL AND \"decision_queues\".\"created_by_user_id\" IS NOT NULL)\n OR (\"decision_queues\".\"created_by_type\" = 'system' AND \"decision_queues\".\"created_by_agent_id\" IS NULL AND \"decision_queues\".\"created_by_user_id\" IS NULL)\n )"+ },+ "decision_queues_retention_days_check": {+ "name": "decision_queues_retention_days_check",+ "value": "\"decision_queues\".\"retention_days\" IS NULL OR (\"decision_queues\".\"retention_days\" >= 1 AND \"decision_queues\".\"retention_days\" <= 3650)"+ }+ },+ "isRLSEnabled": false+ },+ "public.decision_retention": {+ "name": "decision_retention",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "source_kind": {+ "name": "source_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_id": {+ "name": "source_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_activity_at": {+ "name": "source_activity_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "keep": {+ "name": "keep",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "archived_at": {+ "name": "archived_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "archived_reason": {+ "name": "archived_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "archived_by_type": {+ "name": "archived_by_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "archived_by_agent_id": {+ "name": "archived_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "archived_by_user_id": {+ "name": "archived_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "archived_by_run_id": {+ "name": "archived_by_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "archive_version": {+ "name": "archive_version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "decision_retention_company_source_uq": {+ "name": "decision_retention_company_source_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "decision_retention_company_archived_idx": {+ "name": "decision_retention_company_archived_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "archived_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "decision_retention_company_id_companies_id_fk": {+ "name": "decision_retention_company_id_companies_id_fk",+ "tableFrom": "decision_retention",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "decision_retention_archived_by_agent_id_agents_id_fk": {+ "name": "decision_retention_archived_by_agent_id_agents_id_fk",+ "tableFrom": "decision_retention",+ "tableTo": "agents",+ "columnsFrom": [+ "archived_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "decision_retention_archived_by_run_id_heartbeat_runs_id_fk": {+ "name": "decision_retention_archived_by_run_id_heartbeat_runs_id_fk",+ "tableFrom": "decision_retention",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "archived_by_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "decision_retention_archive_actor_check": {+ "name": "decision_retention_archive_actor_check",+ "value": "(\n (\"decision_retention\".\"archived_at\" IS NULL AND \"decision_retention\".\"archived_by_type\" IS NULL AND \"decision_retention\".\"archived_by_agent_id\" IS NULL AND \"decision_retention\".\"archived_by_user_id\" IS NULL)\n OR (\"decision_retention\".\"archived_at\" IS NOT NULL AND \"decision_retention\".\"archived_by_type\" = 'system' AND \"decision_retention\".\"archived_by_agent_id\" IS NULL AND \"decision_retention\".\"archived_by_user_id\" IS NULL)\n OR (\"decision_retention\".\"archived_at\" IS NOT NULL AND \"decision_retention\".\"archived_by_type\" = 'agent' AND \"decision_retention\".\"archived_by_agent_id\" IS NOT NULL AND \"decision_retention\".\"archived_by_user_id\" IS NULL)\n OR (\"decision_retention\".\"archived_at\" IS NOT NULL AND \"decision_retention\".\"archived_by_type\" = 'user' AND \"decision_retention\".\"archived_by_agent_id\" IS NULL AND \"decision_retention\".\"archived_by_user_id\" IS NOT NULL)\n )"+ }+ },+ "isRLSEnabled": false+ },+ "public.decision_triage": {+ "name": "decision_triage",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "source_kind": {+ "name": "source_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_id": {+ "name": "source_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "decide_by": {+ "name": "decide_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "decide_by_date": {+ "name": "decide_by_date",+ "type": "date",+ "primaryKey": false,+ "notNull": false+ },+ "snoozed_until": {+ "name": "snoozed_until",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "set_by_type": {+ "name": "set_by_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "set_by_agent_id": {+ "name": "set_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "set_by_user_id": {+ "name": "set_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "set_by_run_id": {+ "name": "set_by_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "set_by_agent_api_key_id": {+ "name": "set_by_agent_api_key_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "responsible_user_id": {+ "name": "responsible_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "decision_triage_company_source_uq": {+ "name": "decision_triage_company_source_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "decision_triage_company_decide_by_idx": {+ "name": "decision_triage_company_decide_by_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "decide_by",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "decision_triage_company_id_companies_id_fk": {+ "name": "decision_triage_company_id_companies_id_fk",+ "tableFrom": "decision_triage",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "decision_triage_set_by_agent_id_agents_id_fk": {+ "name": "decision_triage_set_by_agent_id_agents_id_fk",+ "tableFrom": "decision_triage",+ "tableTo": "agents",+ "columnsFrom": [+ "set_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "decision_triage_set_by_run_id_heartbeat_runs_id_fk": {+ "name": "decision_triage_set_by_run_id_heartbeat_runs_id_fk",+ "tableFrom": "decision_triage",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "set_by_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "decision_triage_set_by_agent_api_key_id_agent_api_keys_id_fk": {+ "name": "decision_triage_set_by_agent_api_key_id_agent_api_keys_id_fk",+ "tableFrom": "decision_triage",+ "tableTo": "agent_api_keys",+ "columnsFrom": [+ "set_by_agent_api_key_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "decision_triage_actor_check": {+ "name": "decision_triage_actor_check",+ "value": "(\n (\"decision_triage\".\"set_by_type\" = 'agent' AND \"decision_triage\".\"set_by_agent_id\" IS NOT NULL AND \"decision_triage\".\"set_by_user_id\" IS NULL)\n OR (\"decision_triage\".\"set_by_type\" = 'user' AND \"decision_triage\".\"set_by_agent_id\" IS NULL AND \"decision_triage\".\"set_by_user_id\" IS NOT NULL)\n )"+ },+ "decision_triage_decide_by_check": {+ "name": "decision_triage_decide_by_check",+ "value": "(\n (\"decision_triage\".\"decide_by\" IS NULL AND \"decision_triage\".\"decide_by_date\" IS NULL)\n OR (\"decision_triage\".\"decide_by\" IN ('today', 'this_week', 'whenever') AND \"decision_triage\".\"decide_by_date\" IS NULL)\n OR (\"decision_triage\".\"decide_by\" = 'date' AND \"decision_triage\".\"decide_by_date\" IS NOT NULL)\n )"+ }+ },+ "isRLSEnabled": false+ },+ "public.decision_triage_events": {+ "name": "decision_triage_events",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "queue_id": {+ "name": "queue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "source_kind": {+ "name": "source_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source_id": {+ "name": "source_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "action": {+ "name": "action",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "actor_type": {+ "name": "actor_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "actor_agent_id": {+ "name": "actor_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "actor_user_id": {+ "name": "actor_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "actor_run_id": {+ "name": "actor_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "agent_api_key_id": {+ "name": "agent_api_key_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "responsible_user_id": {+ "name": "responsible_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "details": {+ "name": "details",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "decision_triage_events_company_source_created_idx": {+ "name": "decision_triage_events_company_source_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "decision_triage_events_queue_created_idx": {+ "name": "decision_triage_events_queue_created_idx",+ "columns": [+ {+ "expression": "queue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "decision_triage_events_company_id_companies_id_fk": {+ "name": "decision_triage_events_company_id_companies_id_fk",+ "tableFrom": "decision_triage_events",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "decision_triage_events_queue_id_decision_queues_id_fk": {+ "name": "decision_triage_events_queue_id_decision_queues_id_fk",+ "tableFrom": "decision_triage_events",+ "tableTo": "decision_queues",+ "columnsFrom": [+ "queue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "decision_triage_events_actor_agent_id_agents_id_fk": {+ "name": "decision_triage_events_actor_agent_id_agents_id_fk",+ "tableFrom": "decision_triage_events",+ "tableTo": "agents",+ "columnsFrom": [+ "actor_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "decision_triage_events_actor_run_id_heartbeat_runs_id_fk": {+ "name": "decision_triage_events_actor_run_id_heartbeat_runs_id_fk",+ "tableFrom": "decision_triage_events",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "actor_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "decision_triage_events_agent_api_key_id_agent_api_keys_id_fk": {+ "name": "decision_triage_events_agent_api_key_id_agent_api_keys_id_fk",+ "tableFrom": "decision_triage_events",+ "tableTo": "agent_api_keys",+ "columnsFrom": [+ "agent_api_key_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "decision_triage_events_actor_check": {+ "name": "decision_triage_events_actor_check",+ "value": "(\n (\"decision_triage_events\".\"actor_type\" = 'agent' AND \"decision_triage_events\".\"actor_agent_id\" IS NOT NULL AND \"decision_triage_events\".\"actor_user_id\" IS NULL)\n OR (\"decision_triage_events\".\"actor_type\" = 'user' AND \"decision_triage_events\".\"actor_agent_id\" IS NULL AND \"decision_triage_events\".\"actor_user_id\" IS NOT NULL)\n OR (\"decision_triage_events\".\"actor_type\" = 'system' AND \"decision_triage_events\".\"actor_agent_id\" IS NULL AND \"decision_triage_events\".\"actor_user_id\" IS NULL)\n )"+ }+ },+ "isRLSEnabled": false+ },+ "public.decision_training_examples": {+ "name": "decision_training_examples",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "source_kind": {+ "name": "source_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_id": {+ "name": "source_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "cutoff_at": {+ "name": "cutoff_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "notes": {+ "name": "notes",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "notes_history": {+ "name": "notes_history",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "decision_outcome": {+ "name": "decision_outcome",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "retention_policy": {+ "name": "retention_policy",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'scrub_deleted_comments_v1'"+ },+ "snapshot": {+ "name": "snapshot",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "decision_training_examples_company_created_at_idx": {+ "name": "decision_training_examples_company_created_at_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "decision_training_examples_issue_idx": {+ "name": "decision_training_examples_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "decision_training_examples_source_author_uq": {+ "name": "decision_training_examples_source_author_uq",+ "columns": [+ {+ "expression": "source_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_by_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "decision_training_examples_company_id_companies_id_fk": {+ "name": "decision_training_examples_company_id_companies_id_fk",+ "tableFrom": "decision_training_examples",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "decision_training_examples_issue_id_issues_id_fk": {+ "name": "decision_training_examples_issue_id_issues_id_fk",+ "tableFrom": "decision_training_examples",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.decision_bundles": {+ "name": "decision_bundles",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "summary": {+ "name": "summary",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "origin_agent_id": {+ "name": "origin_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "origin_issue_id": {+ "name": "origin_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "origin_run_id": {+ "name": "origin_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "decision_bundles_company_created_at_idx": {+ "name": "decision_bundles_company_created_at_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "decision_bundles_company_id_companies_id_fk": {+ "name": "decision_bundles_company_id_companies_id_fk",+ "tableFrom": "decision_bundles",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "decision_bundles_origin_agent_id_agents_id_fk": {+ "name": "decision_bundles_origin_agent_id_agents_id_fk",+ "tableFrom": "decision_bundles",+ "tableTo": "agents",+ "columnsFrom": [+ "origin_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "decision_bundles_origin_issue_id_issues_id_fk": {+ "name": "decision_bundles_origin_issue_id_issues_id_fk",+ "tableFrom": "decision_bundles",+ "tableTo": "issues",+ "columnsFrom": [+ "origin_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "decision_bundles_origin_run_id_heartbeat_runs_id_fk": {+ "name": "decision_bundles_origin_run_id_heartbeat_runs_id_fk",+ "tableFrom": "decision_bundles",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "origin_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.decision_effect_executions": {+ "name": "decision_effect_executions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "decision_id": {+ "name": "decision_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "effect_index": {+ "name": "effect_index",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "effect_type": {+ "name": "effect_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "target_issue_id": {+ "name": "target_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'claimed'"+ },+ "result": {+ "name": "result",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "error": {+ "name": "error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "activity_log_id": {+ "name": "activity_log_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "executed_at": {+ "name": "executed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "decision_effect_executions_decision_effect_uq": {+ "name": "decision_effect_executions_decision_effect_uq",+ "columns": [+ {+ "expression": "decision_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "effect_index",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "decision_effect_executions_target_issue_idx": {+ "name": "decision_effect_executions_target_issue_idx",+ "columns": [+ {+ "expression": "target_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "decision_effect_executions_decision_id_decisions_id_fk": {+ "name": "decision_effect_executions_decision_id_decisions_id_fk",+ "tableFrom": "decision_effect_executions",+ "tableTo": "decisions",+ "columnsFrom": [+ "decision_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "decision_effect_executions_target_issue_id_issues_id_fk": {+ "name": "decision_effect_executions_target_issue_id_issues_id_fk",+ "tableFrom": "decision_effect_executions",+ "tableTo": "issues",+ "columnsFrom": [+ "target_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "decision_effect_executions_activity_log_id_activity_log_id_fk": {+ "name": "decision_effect_executions_activity_log_id_activity_log_id_fk",+ "tableFrom": "decision_effect_executions",+ "tableTo": "activity_log",+ "columnsFrom": [+ "activity_log_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.decision_target_issues": {+ "name": "decision_target_issues",+ "schema": "",+ "columns": {+ "decision_id": {+ "name": "decision_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "decision_target_issues_decision_idx": {+ "name": "decision_target_issues_decision_idx",+ "columns": [+ {+ "expression": "decision_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "decision_target_issues_issue_idx": {+ "name": "decision_target_issues_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "decision_target_issues_decision_id_decisions_id_fk": {+ "name": "decision_target_issues_decision_id_decisions_id_fk",+ "tableFrom": "decision_target_issues",+ "tableTo": "decisions",+ "columnsFrom": [+ "decision_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "decision_target_issues_issue_id_issues_id_fk": {+ "name": "decision_target_issues_issue_id_issues_id_fk",+ "tableFrom": "decision_target_issues",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "decision_target_issues_company_id_companies_id_fk": {+ "name": "decision_target_issues_company_id_companies_id_fk",+ "tableFrom": "decision_target_issues",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "decision_target_issues_decision_id_issue_id_pk": {+ "name": "decision_target_issues_decision_id_issue_id_pk",+ "columns": [+ "decision_id",+ "issue_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.decisions": {+ "name": "decisions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "bundle_id": {+ "name": "bundle_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "origin_agent_id": {+ "name": "origin_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "origin_issue_id": {+ "name": "origin_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "origin_run_id": {+ "name": "origin_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "rule_key": {+ "name": "rule_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "body": {+ "name": "body",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "options": {+ "name": "options",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "inputs": {+ "name": "inputs",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'open'"+ },+ "execution_status": {+ "name": "execution_status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "chosen_option_id": {+ "name": "chosen_option_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "input_values": {+ "name": "input_values",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "decided_by_user_id": {+ "name": "decided_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "decided_at": {+ "name": "decided_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "idempotency_key": {+ "name": "idempotency_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "signed_spec": {+ "name": "signed_spec",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "target_snapshots": {+ "name": "target_snapshots",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "continuation_policy": {+ "name": "continuation_policy",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'none'"+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "decisions_company_status_expires_at_idx": {+ "name": "decisions_company_status_expires_at_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "decisions_bundle_idx": {+ "name": "decisions_bundle_idx",+ "columns": [+ {+ "expression": "bundle_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "decisions_origin_issue_idx": {+ "name": "decisions_origin_issue_idx",+ "columns": [+ {+ "expression": "origin_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "decisions_company_idempotency_uq": {+ "name": "decisions_company_idempotency_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "idempotency_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"decisions\".\"idempotency_key\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "decisions_company_id_companies_id_fk": {+ "name": "decisions_company_id_companies_id_fk",+ "tableFrom": "decisions",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "decisions_bundle_id_decision_bundles_id_fk": {+ "name": "decisions_bundle_id_decision_bundles_id_fk",+ "tableFrom": "decisions",+ "tableTo": "decision_bundles",+ "columnsFrom": [+ "bundle_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "decisions_origin_agent_id_agents_id_fk": {+ "name": "decisions_origin_agent_id_agents_id_fk",+ "tableFrom": "decisions",+ "tableTo": "agents",+ "columnsFrom": [+ "origin_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "decisions_origin_issue_id_issues_id_fk": {+ "name": "decisions_origin_issue_id_issues_id_fk",+ "tableFrom": "decisions",+ "tableTo": "issues",+ "columnsFrom": [+ "origin_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "decisions_origin_run_id_heartbeat_runs_id_fk": {+ "name": "decisions_origin_run_id_heartbeat_runs_id_fk",+ "tableFrom": "decisions",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "origin_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.document_annotation_anchor_snapshots": {+ "name": "document_annotation_anchor_snapshots",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "thread_id": {+ "name": "thread_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "document_id": {+ "name": "document_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "from_revision_id": {+ "name": "from_revision_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "from_revision_number": {+ "name": "from_revision_number",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "to_revision_id": {+ "name": "to_revision_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "to_revision_number": {+ "name": "to_revision_number",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "previous_anchor": {+ "name": "previous_anchor",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "next_anchor": {+ "name": "next_anchor",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "anchor_state": {+ "name": "anchor_state",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "anchor_confidence": {+ "name": "anchor_confidence",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "failure_reason": {+ "name": "failure_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "document_annotation_anchor_snapshots_company_thread_created_at_idx": {+ "name": "document_annotation_anchor_snapshots_company_thread_created_at_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "thread_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_annotation_anchor_snapshots_company_document_revision_idx": {+ "name": "document_annotation_anchor_snapshots_company_document_revision_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "to_revision_number",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "document_annotation_anchor_snapshots_company_id_companies_id_fk": {+ "name": "document_annotation_anchor_snapshots_company_id_companies_id_fk",+ "tableFrom": "document_annotation_anchor_snapshots",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "document_annotation_anchor_snapshots_thread_id_document_annotation_threads_id_fk": {+ "name": "document_annotation_anchor_snapshots_thread_id_document_annotation_threads_id_fk",+ "tableFrom": "document_annotation_anchor_snapshots",+ "tableTo": "document_annotation_threads",+ "columnsFrom": [+ "thread_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_annotation_anchor_snapshots_document_id_documents_id_fk": {+ "name": "document_annotation_anchor_snapshots_document_id_documents_id_fk",+ "tableFrom": "document_annotation_anchor_snapshots",+ "tableTo": "documents",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_annotation_anchor_snapshots_from_revision_id_document_revisions_id_fk": {+ "name": "document_annotation_anchor_snapshots_from_revision_id_document_revisions_id_fk",+ "tableFrom": "document_annotation_anchor_snapshots",+ "tableTo": "document_revisions",+ "columnsFrom": [+ "from_revision_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "document_annotation_anchor_snapshots_to_revision_id_document_revisions_id_fk": {+ "name": "document_annotation_anchor_snapshots_to_revision_id_document_revisions_id_fk",+ "tableFrom": "document_annotation_anchor_snapshots",+ "tableTo": "document_revisions",+ "columnsFrom": [+ "to_revision_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.document_annotation_comments": {+ "name": "document_annotation_comments",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "thread_id": {+ "name": "thread_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "routine_id": {+ "name": "routine_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "case_id": {+ "name": "case_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "document_id": {+ "name": "document_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "body": {+ "name": "body",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "author_type": {+ "name": "author_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "author_agent_id": {+ "name": "author_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "author_user_id": {+ "name": "author_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_run_id": {+ "name": "created_by_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "issue_comment_id": {+ "name": "issue_comment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "source_trust": {+ "name": "source_trust",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "document_annotation_comments_company_thread_created_at_idx": {+ "name": "document_annotation_comments_company_thread_created_at_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "thread_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_annotation_comments_company_issue_created_at_idx": {+ "name": "document_annotation_comments_company_issue_created_at_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_annotation_comments_company_routine_created_at_idx": {+ "name": "document_annotation_comments_company_routine_created_at_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "routine_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_annotation_comments_company_case_created_at_idx": {+ "name": "document_annotation_comments_company_case_created_at_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_annotation_comments_company_document_created_at_idx": {+ "name": "document_annotation_comments_company_document_created_at_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_annotation_comments_issue_comment_idx": {+ "name": "document_annotation_comments_issue_comment_idx",+ "columns": [+ {+ "expression": "issue_comment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_annotation_comments_body_search_idx": {+ "name": "document_annotation_comments_body_search_idx",+ "columns": [+ {+ "expression": "body",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "gin_trgm_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "gin",+ "with": {}+ }+ },+ "foreignKeys": {+ "document_annotation_comments_company_id_companies_id_fk": {+ "name": "document_annotation_comments_company_id_companies_id_fk",+ "tableFrom": "document_annotation_comments",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "document_annotation_comments_thread_id_document_annotation_threads_id_fk": {+ "name": "document_annotation_comments_thread_id_document_annotation_threads_id_fk",+ "tableFrom": "document_annotation_comments",+ "tableTo": "document_annotation_threads",+ "columnsFrom": [+ "thread_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_annotation_comments_issue_id_issues_id_fk": {+ "name": "document_annotation_comments_issue_id_issues_id_fk",+ "tableFrom": "document_annotation_comments",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_annotation_comments_routine_id_routines_id_fk": {+ "name": "document_annotation_comments_routine_id_routines_id_fk",+ "tableFrom": "document_annotation_comments",+ "tableTo": "routines",+ "columnsFrom": [+ "routine_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_annotation_comments_case_id_cases_id_fk": {+ "name": "document_annotation_comments_case_id_cases_id_fk",+ "tableFrom": "document_annotation_comments",+ "tableTo": "cases",+ "columnsFrom": [+ "case_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_annotation_comments_document_id_documents_id_fk": {+ "name": "document_annotation_comments_document_id_documents_id_fk",+ "tableFrom": "document_annotation_comments",+ "tableTo": "documents",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_annotation_comments_author_agent_id_agents_id_fk": {+ "name": "document_annotation_comments_author_agent_id_agents_id_fk",+ "tableFrom": "document_annotation_comments",+ "tableTo": "agents",+ "columnsFrom": [+ "author_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "document_annotation_comments_created_by_run_id_heartbeat_runs_id_fk": {+ "name": "document_annotation_comments_created_by_run_id_heartbeat_runs_id_fk",+ "tableFrom": "document_annotation_comments",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "created_by_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "document_annotation_comments_issue_comment_id_issue_comments_id_fk": {+ "name": "document_annotation_comments_issue_comment_id_issue_comments_id_fk",+ "tableFrom": "document_annotation_comments",+ "tableTo": "issue_comments",+ "columnsFrom": [+ "issue_comment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "document_annotation_comments_exactly_one_owner_chk": {+ "name": "document_annotation_comments_exactly_one_owner_chk",+ "value": "num_nonnulls(\"document_annotation_comments\".\"issue_id\", \"document_annotation_comments\".\"routine_id\", \"document_annotation_comments\".\"case_id\") = 1"+ }+ },+ "isRLSEnabled": false+ },+ "public.document_annotation_threads": {+ "name": "document_annotation_threads",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "routine_id": {+ "name": "routine_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "case_id": {+ "name": "case_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "document_id": {+ "name": "document_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "document_key": {+ "name": "document_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'open'"+ },+ "anchor_state": {+ "name": "anchor_state",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "original_revision_id": {+ "name": "original_revision_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "original_revision_number": {+ "name": "original_revision_number",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "current_revision_id": {+ "name": "current_revision_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "current_revision_number": {+ "name": "current_revision_number",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "selected_text": {+ "name": "selected_text",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "prefix_text": {+ "name": "prefix_text",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "suffix_text": {+ "name": "suffix_text",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "normalized_start": {+ "name": "normalized_start",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "normalized_end": {+ "name": "normalized_end",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "markdown_start": {+ "name": "markdown_start",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "markdown_end": {+ "name": "markdown_end",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "anchor_confidence": {+ "name": "anchor_confidence",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'exact'"+ },+ "anchor_selector": {+ "name": "anchor_selector",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_by_agent_id": {+ "name": "resolved_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_by_user_id": {+ "name": "resolved_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_at": {+ "name": "resolved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "document_annotation_threads_company_document_status_idx": {+ "name": "document_annotation_threads_company_document_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_annotation_threads_company_issue_status_idx": {+ "name": "document_annotation_threads_company_issue_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_annotation_threads_company_routine_status_idx": {+ "name": "document_annotation_threads_company_routine_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "routine_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_annotation_threads_company_case_status_idx": {+ "name": "document_annotation_threads_company_case_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_annotation_threads_company_current_revision_open_idx": {+ "name": "document_annotation_threads_company_current_revision_open_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "current_revision_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_annotation_threads_company_anchor_state_idx": {+ "name": "document_annotation_threads_company_anchor_state_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "anchor_state",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "document_annotation_threads_company_id_companies_id_fk": {+ "name": "document_annotation_threads_company_id_companies_id_fk",+ "tableFrom": "document_annotation_threads",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "document_annotation_threads_issue_id_issues_id_fk": {+ "name": "document_annotation_threads_issue_id_issues_id_fk",+ "tableFrom": "document_annotation_threads",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_annotation_threads_routine_id_routines_id_fk": {+ "name": "document_annotation_threads_routine_id_routines_id_fk",+ "tableFrom": "document_annotation_threads",+ "tableTo": "routines",+ "columnsFrom": [+ "routine_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_annotation_threads_case_id_cases_id_fk": {+ "name": "document_annotation_threads_case_id_cases_id_fk",+ "tableFrom": "document_annotation_threads",+ "tableTo": "cases",+ "columnsFrom": [+ "case_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_annotation_threads_document_id_documents_id_fk": {+ "name": "document_annotation_threads_document_id_documents_id_fk",+ "tableFrom": "document_annotation_threads",+ "tableTo": "documents",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_annotation_threads_original_revision_id_document_revisions_id_fk": {+ "name": "document_annotation_threads_original_revision_id_document_revisions_id_fk",+ "tableFrom": "document_annotation_threads",+ "tableTo": "document_revisions",+ "columnsFrom": [+ "original_revision_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "document_annotation_threads_current_revision_id_document_revisions_id_fk": {+ "name": "document_annotation_threads_current_revision_id_document_revisions_id_fk",+ "tableFrom": "document_annotation_threads",+ "tableTo": "document_revisions",+ "columnsFrom": [+ "current_revision_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "document_annotation_threads_created_by_agent_id_agents_id_fk": {+ "name": "document_annotation_threads_created_by_agent_id_agents_id_fk",+ "tableFrom": "document_annotation_threads",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "document_annotation_threads_resolved_by_agent_id_agents_id_fk": {+ "name": "document_annotation_threads_resolved_by_agent_id_agents_id_fk",+ "tableFrom": "document_annotation_threads",+ "tableTo": "agents",+ "columnsFrom": [+ "resolved_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "document_annotation_threads_exactly_one_owner_chk": {+ "name": "document_annotation_threads_exactly_one_owner_chk",+ "value": "num_nonnulls(\"document_annotation_threads\".\"issue_id\", \"document_annotation_threads\".\"routine_id\", \"document_annotation_threads\".\"case_id\") = 1"+ }+ },+ "isRLSEnabled": false+ },+ "public.document_memberships": {+ "name": "document_memberships",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "document_id": {+ "name": "document_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "starred_at": {+ "name": "starred_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "document_memberships_company_user_starred_idx": {+ "name": "document_memberships_company_user_starred_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "starred_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_memberships_company_user_document_uq": {+ "name": "document_memberships_company_user_document_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "document_memberships_company_id_companies_id_fk": {+ "name": "document_memberships_company_id_companies_id_fk",+ "tableFrom": "document_memberships",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_memberships_document_id_documents_id_fk": {+ "name": "document_memberships_document_id_documents_id_fk",+ "tableFrom": "document_memberships",+ "tableTo": "documents",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.document_revisions": {+ "name": "document_revisions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "document_id": {+ "name": "document_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "revision_number": {+ "name": "revision_number",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "format": {+ "name": "format",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'markdown'"+ },+ "body": {+ "name": "body",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "change_summary": {+ "name": "change_summary",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_run_id": {+ "name": "created_by_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "document_revisions_document_revision_uq": {+ "name": "document_revisions_document_revision_uq",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "revision_number",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_revisions_company_document_created_idx": {+ "name": "document_revisions_company_document_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "document_revisions_company_id_companies_id_fk": {+ "name": "document_revisions_company_id_companies_id_fk",+ "tableFrom": "document_revisions",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_revisions_document_id_documents_id_fk": {+ "name": "document_revisions_document_id_documents_id_fk",+ "tableFrom": "document_revisions",+ "tableTo": "documents",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_revisions_created_by_agent_id_agents_id_fk": {+ "name": "document_revisions_created_by_agent_id_agents_id_fk",+ "tableFrom": "document_revisions",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "document_revisions_created_by_run_id_heartbeat_runs_id_fk": {+ "name": "document_revisions_created_by_run_id_heartbeat_runs_id_fk",+ "tableFrom": "document_revisions",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "created_by_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.documents": {+ "name": "documents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "format": {+ "name": "format",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'markdown'"+ },+ "latest_body": {+ "name": "latest_body",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "latest_revision_id": {+ "name": "latest_revision_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "latest_revision_number": {+ "name": "latest_revision_number",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "updated_by_agent_id": {+ "name": "updated_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "updated_by_user_id": {+ "name": "updated_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "locked_at": {+ "name": "locked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "locked_by_agent_id": {+ "name": "locked_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "locked_by_user_id": {+ "name": "locked_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source_trust": {+ "name": "source_trust",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "documents_company_updated_idx": {+ "name": "documents_company_updated_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_company_created_idx": {+ "name": "documents_company_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_title_search_idx": {+ "name": "documents_title_search_idx",+ "columns": [+ {+ "expression": "title",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "gin_trgm_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "gin",+ "with": {}+ },+ "documents_latest_body_search_idx": {+ "name": "documents_latest_body_search_idx",+ "columns": [+ {+ "expression": "latest_body",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "gin_trgm_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "gin",+ "with": {}+ }+ },+ "foreignKeys": {+ "documents_company_id_companies_id_fk": {+ "name": "documents_company_id_companies_id_fk",+ "tableFrom": "documents",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "documents_created_by_agent_id_agents_id_fk": {+ "name": "documents_created_by_agent_id_agents_id_fk",+ "tableFrom": "documents",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "documents_updated_by_agent_id_agents_id_fk": {+ "name": "documents_updated_by_agent_id_agents_id_fk",+ "tableFrom": "documents",+ "tableTo": "agents",+ "columnsFrom": [+ "updated_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "documents_locked_by_agent_id_agents_id_fk": {+ "name": "documents_locked_by_agent_id_agents_id_fk",+ "tableFrom": "documents",+ "tableTo": "agents",+ "columnsFrom": [+ "locked_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.email_endpoints": {+ "name": "email_endpoints",+ "schema": "",+ "columns": {+ "endpoint_id": {+ "name": "endpoint_id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "receive_mode": {+ "name": "receive_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "webhook_id": {+ "name": "webhook_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "owned_api_key_id": {+ "name": "owned_api_key_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "activation_at": {+ "name": "activation_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "sync_checkpoint": {+ "name": "sync_checkpoint",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_sync_at": {+ "name": "last_sync_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "email_endpoints_company_id_endpoint_id_chat_endpoints_company_id_id_fk": {+ "name": "email_endpoints_company_id_endpoint_id_chat_endpoints_company_id_id_fk",+ "tableFrom": "email_endpoints",+ "tableTo": "chat_endpoints",+ "columnsFrom": [+ "company_id",+ "endpoint_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "email_endpoints_receive_mode_check": {+ "name": "email_endpoints_receive_mode_check",+ "value": "\"email_endpoints\".\"receive_mode\" in ('websocket', 'webhook')"+ }+ },+ "isRLSEnabled": false+ },+ "public.email_messages": {+ "name": "email_messages",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "endpoint_id": {+ "name": "endpoint_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "conversation_id": {+ "name": "conversation_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "provider_message_id": {+ "name": "provider_message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "envelope": {+ "name": "envelope",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "text": {+ "name": "text",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "full_text": {+ "name": "full_text",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "direction": {+ "name": "direction",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "automatic": {+ "name": "automatic",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "attachment_ids": {+ "name": "attachment_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "timestamp": {+ "name": "timestamp",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "email_messages_provider_uq": {+ "name": "email_messages_provider_uq",+ "columns": [+ {+ "expression": "endpoint_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider_message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "email_messages_conversation_idx": {+ "name": "email_messages_conversation_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "conversation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "timestamp",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "email_messages_company_id_endpoint_id_chat_endpoints_company_id_id_fk": {+ "name": "email_messages_company_id_endpoint_id_chat_endpoints_company_id_id_fk",+ "tableFrom": "email_messages",+ "tableTo": "chat_endpoints",+ "columnsFrom": [+ "company_id",+ "endpoint_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "email_messages_company_id_conversation_id_chat_conversations_company_id_id_fk": {+ "name": "email_messages_company_id_conversation_id_chat_conversations_company_id_id_fk",+ "tableFrom": "email_messages",+ "tableTo": "chat_conversations",+ "columnsFrom": [+ "company_id",+ "conversation_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "email_messages_direction_check": {+ "name": "email_messages_direction_check",+ "value": "\"email_messages\".\"direction\" in ('inbound', 'outbound')"+ }+ },+ "isRLSEnabled": false+ },+ "public.email_sends": {+ "name": "email_sends",+ "schema": "",+ "columns": {+ "publication_id": {+ "name": "publication_id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "endpoint_id": {+ "name": "endpoint_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "request": {+ "name": "request",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "actor": {+ "name": "actor",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "digest": {+ "name": "digest",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "outcome": {+ "name": "outcome",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'queued'"+ },+ "first_attempt_at": {+ "name": "first_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "email_sends_pending_idx": {+ "name": "email_sends_pending_idx",+ "columns": [+ {+ "expression": "endpoint_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "outcome",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"email_sends\".\"outcome\" in ('queued', 'uncertain')",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "email_sends_company_id_endpoint_id_chat_endpoints_company_id_id_fk": {+ "name": "email_sends_company_id_endpoint_id_chat_endpoints_company_id_id_fk",+ "tableFrom": "email_sends",+ "tableTo": "chat_endpoints",+ "columnsFrom": [+ "company_id",+ "endpoint_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "email_sends_company_id_publication_id_chat_publications_company_id_id_fk": {+ "name": "email_sends_company_id_publication_id_chat_publications_company_id_id_fk",+ "tableFrom": "email_sends",+ "tableTo": "chat_publications",+ "columnsFrom": [+ "company_id",+ "publication_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "email_sends_outcome_check": {+ "name": "email_sends_outcome_check",+ "value": "\"email_sends\".\"outcome\" in ('queued', 'sent', 'delivered', 'failed', 'uncertain')"+ }+ },+ "isRLSEnabled": false+ },+ "public.environment_custom_image_setup_sessions": {+ "name": "environment_custom_image_setup_sessions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "environment_id": {+ "name": "environment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "template_id": {+ "name": "template_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "promoted_template_id": {+ "name": "promoted_template_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider_lease_id": {+ "name": "provider_lease_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "environment_lease_id": {+ "name": "environment_lease_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'starting'"+ },+ "started_by_user_id": {+ "name": "started_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "started_by_agent_id": {+ "name": "started_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "base_template_ref": {+ "name": "base_template_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "finished_at": {+ "name": "finished_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "failure_reason": {+ "name": "failure_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "connection_summary": {+ "name": "connection_summary",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "connection_secret_ref": {+ "name": "connection_secret_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "environment_custom_image_setup_sessions_environment_status_idx": {+ "name": "environment_custom_image_setup_sessions_environment_status_idx",+ "columns": [+ {+ "expression": "environment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "environment_custom_image_setup_sessions_environment_active_uq": {+ "name": "environment_custom_image_setup_sessions_environment_active_uq",+ "columns": [+ {+ "expression": "environment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"environment_custom_image_setup_sessions\".\"status\" IN ('starting', 'waiting_for_user', 'capturing')",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "environment_custom_image_setup_sessions_template_idx": {+ "name": "environment_custom_image_setup_sessions_template_idx",+ "columns": [+ {+ "expression": "template_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "environment_custom_image_setup_sessions_promoted_template_idx": {+ "name": "environment_custom_image_setup_sessions_promoted_template_idx",+ "columns": [+ {+ "expression": "promoted_template_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "environment_custom_image_setup_sessions_expires_idx": {+ "name": "environment_custom_image_setup_sessions_expires_idx",+ "columns": [+ {+ "expression": "expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "environment_custom_image_setup_sessions_provider_lease_idx": {+ "name": "environment_custom_image_setup_sessions_provider_lease_idx",+ "columns": [+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider_lease_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "environment_custom_image_setup_sessions_environment_id_environments_id_fk": {+ "name": "environment_custom_image_setup_sessions_environment_id_environments_id_fk",+ "tableFrom": "environment_custom_image_setup_sessions",+ "tableTo": "environments",+ "columnsFrom": [+ "environment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "environment_custom_image_setup_sessions_template_id_environment_custom_image_templates_id_fk": {+ "name": "environment_custom_image_setup_sessions_template_id_environment_custom_image_templates_id_fk",+ "tableFrom": "environment_custom_image_setup_sessions",+ "tableTo": "environment_custom_image_templates",+ "columnsFrom": [+ "template_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "environment_custom_image_setup_sessions_promoted_template_id_environment_custom_image_templates_id_fk": {+ "name": "environment_custom_image_setup_sessions_promoted_template_id_environment_custom_image_templates_id_fk",+ "tableFrom": "environment_custom_image_setup_sessions",+ "tableTo": "environment_custom_image_templates",+ "columnsFrom": [+ "promoted_template_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "environment_custom_image_setup_sessions_environment_lease_id_environment_leases_id_fk": {+ "name": "environment_custom_image_setup_sessions_environment_lease_id_environment_leases_id_fk",+ "tableFrom": "environment_custom_image_setup_sessions",+ "tableTo": "environment_leases",+ "columnsFrom": [+ "environment_lease_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "environment_custom_image_setup_sessions_started_by_agent_id_agents_id_fk": {+ "name": "environment_custom_image_setup_sessions_started_by_agent_id_agents_id_fk",+ "tableFrom": "environment_custom_image_setup_sessions",+ "tableTo": "agents",+ "columnsFrom": [+ "started_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.environment_custom_image_templates": {+ "name": "environment_custom_image_templates",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "environment_id": {+ "name": "environment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "template_kind": {+ "name": "template_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'unknown'"+ },+ "template_ref": {+ "name": "template_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_template_ref": {+ "name": "source_template_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source_environment_config_fingerprint": {+ "name": "source_environment_config_fingerprint",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_used_at": {+ "name": "last_used_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "superseded_by_template_id": {+ "name": "superseded_by_template_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "environment_custom_image_templates_environment_status_idx": {+ "name": "environment_custom_image_templates_environment_status_idx",+ "columns": [+ {+ "expression": "environment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "environment_custom_image_templates_environment_provider_status_idx": {+ "name": "environment_custom_image_templates_environment_provider_status_idx",+ "columns": [+ {+ "expression": "environment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "environment_custom_image_templates_environment_active_uq": {+ "name": "environment_custom_image_templates_environment_active_uq",+ "columns": [+ {+ "expression": "environment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"environment_custom_image_templates\".\"status\" = 'active'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "environment_custom_image_templates_superseded_by_idx": {+ "name": "environment_custom_image_templates_superseded_by_idx",+ "columns": [+ {+ "expression": "superseded_by_template_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "environment_custom_image_templates_last_used_idx": {+ "name": "environment_custom_image_templates_last_used_idx",+ "columns": [+ {+ "expression": "last_used_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "environment_custom_image_templates_environment_id_environments_id_fk": {+ "name": "environment_custom_image_templates_environment_id_environments_id_fk",+ "tableFrom": "environment_custom_image_templates",+ "tableTo": "environments",+ "columnsFrom": [+ "environment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "environment_custom_image_templates_created_by_agent_id_agents_id_fk": {+ "name": "environment_custom_image_templates_created_by_agent_id_agents_id_fk",+ "tableFrom": "environment_custom_image_templates",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "environment_custom_image_templates_superseded_by_template_id_environment_custom_image_templates_id_fk": {+ "name": "environment_custom_image_templates_superseded_by_template_id_environment_custom_image_templates_id_fk",+ "tableFrom": "environment_custom_image_templates",+ "tableTo": "environment_custom_image_templates",+ "columnsFrom": [+ "superseded_by_template_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.environment_leases": {+ "name": "environment_leases",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "environment_id": {+ "name": "environment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "execution_workspace_id": {+ "name": "execution_workspace_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "heartbeat_run_id": {+ "name": "heartbeat_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "lease_policy": {+ "name": "lease_policy",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'ephemeral'"+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider_lease_id": {+ "name": "provider_lease_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "acquired_at": {+ "name": "acquired_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_used_at": {+ "name": "last_used_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "released_at": {+ "name": "released_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "failure_reason": {+ "name": "failure_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "cleanup_status": {+ "name": "cleanup_status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "environment_leases_company_environment_status_idx": {+ "name": "environment_leases_company_environment_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "environment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "environment_leases_company_execution_workspace_idx": {+ "name": "environment_leases_company_execution_workspace_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "execution_workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "environment_leases_company_issue_idx": {+ "name": "environment_leases_company_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "environment_leases_heartbeat_run_idx": {+ "name": "environment_leases_heartbeat_run_idx",+ "columns": [+ {+ "expression": "heartbeat_run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "environment_leases_company_last_used_idx": {+ "name": "environment_leases_company_last_used_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "last_used_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "environment_leases_provider_lease_idx": {+ "name": "environment_leases_provider_lease_idx",+ "columns": [+ {+ "expression": "provider_lease_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "environment_leases_company_id_companies_id_fk": {+ "name": "environment_leases_company_id_companies_id_fk",+ "tableFrom": "environment_leases",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "environment_leases_environment_id_environments_id_fk": {+ "name": "environment_leases_environment_id_environments_id_fk",+ "tableFrom": "environment_leases",+ "tableTo": "environments",+ "columnsFrom": [+ "environment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "environment_leases_execution_workspace_id_execution_workspaces_id_fk": {+ "name": "environment_leases_execution_workspace_id_execution_workspaces_id_fk",+ "tableFrom": "environment_leases",+ "tableTo": "execution_workspaces",+ "columnsFrom": [+ "execution_workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "environment_leases_issue_id_issues_id_fk": {+ "name": "environment_leases_issue_id_issues_id_fk",+ "tableFrom": "environment_leases",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "environment_leases_heartbeat_run_id_heartbeat_runs_id_fk": {+ "name": "environment_leases_heartbeat_run_id_heartbeat_runs_id_fk",+ "tableFrom": "environment_leases",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "heartbeat_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.environments": {+ "name": "environments",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "driver": {+ "name": "driver",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'local'"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "env_vars": {+ "name": "env_vars",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "environments_status_idx": {+ "name": "environments_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "environments_local_driver_idx": {+ "name": "environments_local_driver_idx",+ "columns": [+ {+ "expression": "driver",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"environments\".\"driver\" = 'local'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "environments_managed_sandbox_idx": {+ "name": "environments_managed_sandbox_idx",+ "columns": [+ {+ "expression": "driver",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"environments\".\"driver\" = 'sandbox' AND (\"environments\".\"metadata\" ->> 'managedByPaperclip')::boolean = true",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "environments_name_idx": {+ "name": "environments_name_idx",+ "columns": [+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.execution_workspace_runtime_leases": {+ "name": "execution_workspace_runtime_leases",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "execution_workspace_id": {+ "name": "execution_workspace_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "owner_key": {+ "name": "owner_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "owner_issue_id": {+ "name": "owner_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "owner_run_id": {+ "name": "owner_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "owner_agent_id": {+ "name": "owner_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "last_action": {+ "name": "last_action",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "claimed_at": {+ "name": "claimed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "renewed_at": {+ "name": "renewed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "execution_workspace_runtime_leases_company_workspace_idx": {+ "name": "execution_workspace_runtime_leases_company_workspace_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "execution_workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "execution_workspace_runtime_leases_company_owner_idx": {+ "name": "execution_workspace_runtime_leases_company_owner_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "owner_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "execution_workspace_runtime_leases_expires_at_idx": {+ "name": "execution_workspace_runtime_leases_expires_at_idx",+ "columns": [+ {+ "expression": "expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "execution_workspace_runtime_leases_company_id_companies_id_fk": {+ "name": "execution_workspace_runtime_leases_company_id_companies_id_fk",+ "tableFrom": "execution_workspace_runtime_leases",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "execution_workspace_runtime_leases_execution_workspace_id_execution_workspaces_id_fk": {+ "name": "execution_workspace_runtime_leases_execution_workspace_id_execution_workspaces_id_fk",+ "tableFrom": "execution_workspace_runtime_leases",+ "tableTo": "execution_workspaces",+ "columnsFrom": [+ "execution_workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "execution_workspace_runtime_leases_owner_issue_id_issues_id_fk": {+ "name": "execution_workspace_runtime_leases_owner_issue_id_issues_id_fk",+ "tableFrom": "execution_workspace_runtime_leases",+ "tableTo": "issues",+ "columnsFrom": [+ "owner_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "execution_workspace_runtime_leases_owner_run_id_heartbeat_runs_id_fk": {+ "name": "execution_workspace_runtime_leases_owner_run_id_heartbeat_runs_id_fk",+ "tableFrom": "execution_workspace_runtime_leases",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "owner_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "execution_workspace_runtime_leases_owner_agent_id_agents_id_fk": {+ "name": "execution_workspace_runtime_leases_owner_agent_id_agents_id_fk",+ "tableFrom": "execution_workspace_runtime_leases",+ "tableTo": "agents",+ "columnsFrom": [+ "owner_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "execution_workspace_runtime_leases_execution_workspace_id_unique": {+ "name": "execution_workspace_runtime_leases_execution_workspace_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "execution_workspace_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.execution_workspaces": {+ "name": "execution_workspaces",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "project_workspace_id": {+ "name": "project_workspace_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "source_issue_id": {+ "name": "source_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "mode": {+ "name": "mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "strategy_type": {+ "name": "strategy_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "cwd": {+ "name": "cwd",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "repo_url": {+ "name": "repo_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "base_ref": {+ "name": "base_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "branch_name": {+ "name": "branch_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider_type": {+ "name": "provider_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'local_fs'"+ },+ "provider_ref": {+ "name": "provider_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "derived_from_execution_workspace_id": {+ "name": "derived_from_execution_workspace_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "last_used_at": {+ "name": "last_used_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "opened_at": {+ "name": "opened_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "closed_at": {+ "name": "closed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "cleanup_eligible_at": {+ "name": "cleanup_eligible_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "cleanup_reason": {+ "name": "cleanup_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "execution_workspaces_company_project_status_idx": {+ "name": "execution_workspaces_company_project_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "execution_workspaces_company_project_workspace_status_idx": {+ "name": "execution_workspaces_company_project_workspace_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "project_workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "execution_workspaces_company_source_issue_idx": {+ "name": "execution_workspaces_company_source_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "execution_workspaces_company_last_used_idx": {+ "name": "execution_workspaces_company_last_used_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "last_used_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "execution_workspaces_company_branch_idx": {+ "name": "execution_workspaces_company_branch_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "branch_name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "execution_workspaces_company_id_companies_id_fk": {+ "name": "execution_workspaces_company_id_companies_id_fk",+ "tableFrom": "execution_workspaces",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "execution_workspaces_project_id_projects_id_fk": {+ "name": "execution_workspaces_project_id_projects_id_fk",+ "tableFrom": "execution_workspaces",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "execution_workspaces_project_workspace_id_project_workspaces_id_fk": {+ "name": "execution_workspaces_project_workspace_id_project_workspaces_id_fk",+ "tableFrom": "execution_workspaces",+ "tableTo": "project_workspaces",+ "columnsFrom": [+ "project_workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "execution_workspaces_source_issue_id_issues_id_fk": {+ "name": "execution_workspaces_source_issue_id_issues_id_fk",+ "tableFrom": "execution_workspaces",+ "tableTo": "issues",+ "columnsFrom": [+ "source_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "execution_workspaces_derived_from_execution_workspace_id_execution_workspaces_id_fk": {+ "name": "execution_workspaces_derived_from_execution_workspace_id_execution_workspaces_id_fk",+ "tableFrom": "execution_workspaces",+ "tableTo": "execution_workspaces",+ "columnsFrom": [+ "derived_from_execution_workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.external_object_mentions": {+ "name": "external_object_mentions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "source_issue_id": {+ "name": "source_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "source_kind": {+ "name": "source_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_record_id": {+ "name": "source_record_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "document_key": {+ "name": "document_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "property_key": {+ "name": "property_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "matched_text_redacted": {+ "name": "matched_text_redacted",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "sanitized_display_url": {+ "name": "sanitized_display_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "canonical_identity_hash": {+ "name": "canonical_identity_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "canonical_identity": {+ "name": "canonical_identity",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "object_id": {+ "name": "object_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "provider_key": {+ "name": "provider_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "detector_key": {+ "name": "detector_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "object_type": {+ "name": "object_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "confidence": {+ "name": "confidence",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'exact'"+ },+ "created_by_plugin_id": {+ "name": "created_by_plugin_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "external_object_mentions_company_source_issue_idx": {+ "name": "external_object_mentions_company_source_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "external_object_mentions_company_object_idx": {+ "name": "external_object_mentions_company_object_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "object_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "external_object_mentions_company_provider_idx": {+ "name": "external_object_mentions_company_provider_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "object_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "external_object_mentions_company_source_record_uq": {+ "name": "external_object_mentions_company_source_record_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_record_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "document_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "property_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "canonical_identity_hash",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"external_object_mentions\".\"source_record_id\" is not null and \"external_object_mentions\".\"canonical_identity_hash\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "external_object_mentions_company_source_null_record_uq": {+ "name": "external_object_mentions_company_source_null_record_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "document_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "property_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "canonical_identity_hash",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"external_object_mentions\".\"source_record_id\" is null and \"external_object_mentions\".\"canonical_identity_hash\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "external_object_mentions_company_id_companies_id_fk": {+ "name": "external_object_mentions_company_id_companies_id_fk",+ "tableFrom": "external_object_mentions",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "external_object_mentions_source_issue_id_issues_id_fk": {+ "name": "external_object_mentions_source_issue_id_issues_id_fk",+ "tableFrom": "external_object_mentions",+ "tableTo": "issues",+ "columnsFrom": [+ "source_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "external_object_mentions_object_id_external_objects_id_fk": {+ "name": "external_object_mentions_object_id_external_objects_id_fk",+ "tableFrom": "external_object_mentions",+ "tableTo": "external_objects",+ "columnsFrom": [+ "object_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "external_object_mentions_created_by_plugin_id_plugins_id_fk": {+ "name": "external_object_mentions_created_by_plugin_id_plugins_id_fk",+ "tableFrom": "external_object_mentions",+ "tableTo": "plugins",+ "columnsFrom": [+ "created_by_plugin_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.external_objects": {+ "name": "external_objects",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "provider_key": {+ "name": "provider_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "plugin_id": {+ "name": "plugin_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "object_type": {+ "name": "object_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "external_id": {+ "name": "external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "sanitized_canonical_url": {+ "name": "sanitized_canonical_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "canonical_identity_hash": {+ "name": "canonical_identity_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "display_key": {+ "name": "display_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "icon_key": {+ "name": "icon_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "display_title": {+ "name": "display_title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status_key": {+ "name": "status_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status_label": {+ "name": "status_label",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status_icon_key": {+ "name": "status_icon_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status_category": {+ "name": "status_category",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'unknown'"+ },+ "status_tone": {+ "name": "status_tone",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'neutral'"+ },+ "liveness": {+ "name": "liveness",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'unknown'"+ },+ "is_terminal": {+ "name": "is_terminal",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "data": {+ "name": "data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "remote_version": {+ "name": "remote_version",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "etag": {+ "name": "etag",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "last_resolved_at": {+ "name": "last_resolved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_changed_at": {+ "name": "last_changed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_error_at": {+ "name": "last_error_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "next_refresh_at": {+ "name": "next_refresh_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "refresh_started_at": {+ "name": "refresh_started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "refresh_token": {+ "name": "refresh_token",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "last_error_code": {+ "name": "last_error_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "last_error_message": {+ "name": "last_error_message",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "external_objects_company_provider_object_idx": {+ "name": "external_objects_company_provider_object_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "object_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "external_objects_company_provider_status_idx": {+ "name": "external_objects_company_provider_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status_category",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "external_objects_company_refresh_idx": {+ "name": "external_objects_company_refresh_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "next_refresh_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "external_objects_company_external_id_uq": {+ "name": "external_objects_company_external_id_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "object_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "external_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "external_objects_company_identity_uq": {+ "name": "external_objects_company_identity_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "object_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "canonical_identity_hash",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "external_objects_company_id_companies_id_fk": {+ "name": "external_objects_company_id_companies_id_fk",+ "tableFrom": "external_objects",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "external_objects_plugin_id_plugins_id_fk": {+ "name": "external_objects_plugin_id_plugins_id_fk",+ "tableFrom": "external_objects",+ "tableTo": "plugins",+ "columnsFrom": [+ "plugin_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.feedback_exports": {+ "name": "feedback_exports",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "feedback_vote_id": {+ "name": "feedback_vote_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "author_user_id": {+ "name": "author_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "target_type": {+ "name": "target_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "target_id": {+ "name": "target_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "vote": {+ "name": "vote",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'local_only'"+ },+ "destination": {+ "name": "destination",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "export_id": {+ "name": "export_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "consent_version": {+ "name": "consent_version",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "schema_version": {+ "name": "schema_version",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'paperclip-feedback-envelope-v2'"+ },+ "bundle_version": {+ "name": "bundle_version",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'paperclip-feedback-bundle-v2'"+ },+ "payload_version": {+ "name": "payload_version",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'paperclip-feedback-v1'"+ },+ "payload_digest": {+ "name": "payload_digest",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "payload_snapshot": {+ "name": "payload_snapshot",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "target_summary": {+ "name": "target_summary",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "redaction_summary": {+ "name": "redaction_summary",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "attempt_count": {+ "name": "attempt_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "last_attempted_at": {+ "name": "last_attempted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "exported_at": {+ "name": "exported_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "failure_reason": {+ "name": "failure_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "feedback_exports_feedback_vote_idx": {+ "name": "feedback_exports_feedback_vote_idx",+ "columns": [+ {+ "expression": "feedback_vote_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "feedback_exports_company_created_idx": {+ "name": "feedback_exports_company_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "feedback_exports_company_status_idx": {+ "name": "feedback_exports_company_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "feedback_exports_company_issue_idx": {+ "name": "feedback_exports_company_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "feedback_exports_company_project_idx": {+ "name": "feedback_exports_company_project_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "feedback_exports_company_author_idx": {+ "name": "feedback_exports_company_author_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "author_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "feedback_exports_company_id_companies_id_fk": {+ "name": "feedback_exports_company_id_companies_id_fk",+ "tableFrom": "feedback_exports",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "feedback_exports_feedback_vote_id_feedback_votes_id_fk": {+ "name": "feedback_exports_feedback_vote_id_feedback_votes_id_fk",+ "tableFrom": "feedback_exports",+ "tableTo": "feedback_votes",+ "columnsFrom": [+ "feedback_vote_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "feedback_exports_issue_id_issues_id_fk": {+ "name": "feedback_exports_issue_id_issues_id_fk",+ "tableFrom": "feedback_exports",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "feedback_exports_project_id_projects_id_fk": {+ "name": "feedback_exports_project_id_projects_id_fk",+ "tableFrom": "feedback_exports",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.feedback_votes": {+ "name": "feedback_votes",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "target_type": {+ "name": "target_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "target_id": {+ "name": "target_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "author_user_id": {+ "name": "author_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "vote": {+ "name": "vote",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "reason": {+ "name": "reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "shared_with_labs": {+ "name": "shared_with_labs",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "shared_at": {+ "name": "shared_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "consent_version": {+ "name": "consent_version",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "redaction_summary": {+ "name": "redaction_summary",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "feedback_votes_company_issue_idx": {+ "name": "feedback_votes_company_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "feedback_votes_issue_target_idx": {+ "name": "feedback_votes_issue_target_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "feedback_votes_author_idx": {+ "name": "feedback_votes_author_idx",+ "columns": [+ {+ "expression": "author_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "feedback_votes_company_target_author_idx": {+ "name": "feedback_votes_company_target_author_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "author_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "feedback_votes_company_id_companies_id_fk": {+ "name": "feedback_votes_company_id_companies_id_fk",+ "tableFrom": "feedback_votes",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "feedback_votes_issue_id_issues_id_fk": {+ "name": "feedback_votes_issue_id_issues_id_fk",+ "tableFrom": "feedback_votes",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.finance_events": {+ "name": "finance_events",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "project_id": {+ "name": "project_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "goal_id": {+ "name": "goal_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "heartbeat_run_id": {+ "name": "heartbeat_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "cost_event_id": {+ "name": "cost_event_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "billing_code": {+ "name": "billing_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "event_kind": {+ "name": "event_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "direction": {+ "name": "direction",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'debit'"+ },+ "biller": {+ "name": "biller",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "execution_adapter_type": {+ "name": "execution_adapter_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "pricing_tier": {+ "name": "pricing_tier",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "region": {+ "name": "region",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "quantity": {+ "name": "quantity",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "unit": {+ "name": "unit",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "amount_cents": {+ "name": "amount_cents",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "currency": {+ "name": "currency",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'USD'"+ },+ "estimated": {+ "name": "estimated",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "external_invoice_id": {+ "name": "external_invoice_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata_json": {+ "name": "metadata_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "occurred_at": {+ "name": "occurred_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "finance_events_company_occurred_idx": {+ "name": "finance_events_company_occurred_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "occurred_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "finance_events_company_biller_occurred_idx": {+ "name": "finance_events_company_biller_occurred_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "biller",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "occurred_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "finance_events_company_kind_occurred_idx": {+ "name": "finance_events_company_kind_occurred_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "event_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "occurred_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "finance_events_company_direction_occurred_idx": {+ "name": "finance_events_company_direction_occurred_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "direction",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "occurred_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "finance_events_company_heartbeat_run_idx": {+ "name": "finance_events_company_heartbeat_run_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "heartbeat_run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "finance_events_company_cost_event_idx": {+ "name": "finance_events_company_cost_event_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "cost_event_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "finance_events_company_id_companies_id_fk": {+ "name": "finance_events_company_id_companies_id_fk",+ "tableFrom": "finance_events",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "finance_events_agent_id_agents_id_fk": {+ "name": "finance_events_agent_id_agents_id_fk",+ "tableFrom": "finance_events",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "finance_events_issue_id_issues_id_fk": {+ "name": "finance_events_issue_id_issues_id_fk",+ "tableFrom": "finance_events",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "finance_events_project_id_projects_id_fk": {+ "name": "finance_events_project_id_projects_id_fk",+ "tableFrom": "finance_events",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "finance_events_goal_id_goals_id_fk": {+ "name": "finance_events_goal_id_goals_id_fk",+ "tableFrom": "finance_events",+ "tableTo": "goals",+ "columnsFrom": [+ "goal_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "finance_events_heartbeat_run_id_heartbeat_runs_id_fk": {+ "name": "finance_events_heartbeat_run_id_heartbeat_runs_id_fk",+ "tableFrom": "finance_events",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "heartbeat_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "finance_events_cost_event_id_cost_events_id_fk": {+ "name": "finance_events_cost_event_id_cost_events_id_fk",+ "tableFrom": "finance_events",+ "tableTo": "cost_events",+ "columnsFrom": [+ "cost_event_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.folders": {+ "name": "folders",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "parent_id": {+ "name": "parent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "slug": {+ "name": "slug",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "system_key": {+ "name": "system_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "folders_company_kind_position_idx": {+ "name": "folders_company_kind_position_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "folders_company_kind_root_slug_uq": {+ "name": "folders_company_kind_root_slug_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"folders\".\"parent_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "folders_company_kind_parent_slug_uq": {+ "name": "folders_company_kind_parent_slug_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "parent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"folders\".\"parent_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "folders_company_kind_system_key_uq": {+ "name": "folders_company_kind_system_key_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "system_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"folders\".\"system_key\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "folders_company_kind_parent_position_idx": {+ "name": "folders_company_kind_parent_position_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "parent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "folders_company_id_companies_id_fk": {+ "name": "folders_company_id_companies_id_fk",+ "tableFrom": "folders",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "folders_parent_id_folders_id_fk": {+ "name": "folders_parent_id_folders_id_fk",+ "tableFrom": "folders",+ "tableTo": "folders",+ "columnsFrom": [+ "parent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "restrict",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.goals": {+ "name": "goals",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "level": {+ "name": "level",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'task'"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'planned'"+ },+ "parent_id": {+ "name": "parent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "owner_agent_id": {+ "name": "owner_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "goals_company_idx": {+ "name": "goals_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "goals_company_id_companies_id_fk": {+ "name": "goals_company_id_companies_id_fk",+ "tableFrom": "goals",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "goals_parent_id_goals_id_fk": {+ "name": "goals_parent_id_goals_id_fk",+ "tableFrom": "goals",+ "tableTo": "goals",+ "columnsFrom": [+ "parent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "goals_owner_agent_id_agents_id_fk": {+ "name": "goals_owner_agent_id_agents_id_fk",+ "tableFrom": "goals",+ "tableTo": "agents",+ "columnsFrom": [+ "owner_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.heartbeat_run_events": {+ "name": "heartbeat_run_events",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "bigserial",+ "primaryKey": true,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "seq": {+ "name": "seq",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true+ },+ "event_type": {+ "name": "event_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "stream": {+ "name": "stream",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "level": {+ "name": "level",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "message": {+ "name": "message",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "source_instance_id": {+ "name": "source_instance_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source_event_id": {+ "name": "source_event_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source_seq": {+ "name": "source_seq",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false+ },+ "source_payload_sha256": {+ "name": "source_payload_sha256",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "protocol_schema_version": {+ "name": "protocol_schema_version",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "heartbeat_run_events_run_seq_uq": {+ "name": "heartbeat_run_events_run_seq_uq",+ "columns": [+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "seq",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "heartbeat_run_events_run_source_event_uq": {+ "name": "heartbeat_run_events_run_source_event_uq",+ "columns": [+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_event_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"heartbeat_run_events\".\"source_event_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "heartbeat_run_events_run_source_seq_uq": {+ "name": "heartbeat_run_events_run_source_seq_uq",+ "columns": [+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_instance_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_seq",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"heartbeat_run_events\".\"source_instance_id\" is not null and \"heartbeat_run_events\".\"source_seq\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "heartbeat_run_events_company_run_idx": {+ "name": "heartbeat_run_events_company_run_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "heartbeat_run_events_company_created_idx": {+ "name": "heartbeat_run_events_company_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "heartbeat_run_events_company_id_companies_id_fk": {+ "name": "heartbeat_run_events_company_id_companies_id_fk",+ "tableFrom": "heartbeat_run_events",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "heartbeat_run_events_run_id_heartbeat_runs_id_fk": {+ "name": "heartbeat_run_events_run_id_heartbeat_runs_id_fk",+ "tableFrom": "heartbeat_run_events",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "heartbeat_run_events_agent_id_agents_id_fk": {+ "name": "heartbeat_run_events_agent_id_agents_id_fk",+ "tableFrom": "heartbeat_run_events",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.heartbeat_run_watchdog_decisions": {+ "name": "heartbeat_run_watchdog_decisions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "evaluation_issue_id": {+ "name": "evaluation_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "decision": {+ "name": "decision",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "snoozed_until": {+ "name": "snoozed_until",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "reason": {+ "name": "reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_run_id": {+ "name": "created_by_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "heartbeat_run_watchdog_decisions_company_run_created_idx": {+ "name": "heartbeat_run_watchdog_decisions_company_run_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "heartbeat_run_watchdog_decisions_company_run_snooze_idx": {+ "name": "heartbeat_run_watchdog_decisions_company_run_snooze_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "snoozed_until",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "heartbeat_run_watchdog_decisions_company_id_companies_id_fk": {+ "name": "heartbeat_run_watchdog_decisions_company_id_companies_id_fk",+ "tableFrom": "heartbeat_run_watchdog_decisions",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "heartbeat_run_watchdog_decisions_run_id_heartbeat_runs_id_fk": {+ "name": "heartbeat_run_watchdog_decisions_run_id_heartbeat_runs_id_fk",+ "tableFrom": "heartbeat_run_watchdog_decisions",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "heartbeat_run_watchdog_decisions_evaluation_issue_id_issues_id_fk": {+ "name": "heartbeat_run_watchdog_decisions_evaluation_issue_id_issues_id_fk",+ "tableFrom": "heartbeat_run_watchdog_decisions",+ "tableTo": "issues",+ "columnsFrom": [+ "evaluation_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "heartbeat_run_watchdog_decisions_created_by_agent_id_agents_id_fk": {+ "name": "heartbeat_run_watchdog_decisions_created_by_agent_id_agents_id_fk",+ "tableFrom": "heartbeat_run_watchdog_decisions",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "heartbeat_run_watchdog_decisions_created_by_run_id_heartbeat_runs_id_fk": {+ "name": "heartbeat_run_watchdog_decisions_created_by_run_id_heartbeat_runs_id_fk",+ "tableFrom": "heartbeat_run_watchdog_decisions",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "created_by_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.heartbeat_runs": {+ "name": "heartbeat_runs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "invocation_source": {+ "name": "invocation_source",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'on_demand'"+ },+ "trigger_detail": {+ "name": "trigger_detail",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'queued'"+ },+ "responsible_user_id": {+ "name": "responsible_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "active_identity_context_id": {+ "name": "active_identity_context_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "finished_at": {+ "name": "finished_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "execution_control_deadline_at": {+ "name": "execution_control_deadline_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "execution_status_delivery_id": {+ "name": "execution_status_delivery_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "error": {+ "name": "error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "wakeup_request_id": {+ "name": "wakeup_request_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "exit_code": {+ "name": "exit_code",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "signal": {+ "name": "signal",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "usage_json": {+ "name": "usage_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "result_json": {+ "name": "result_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "runtime_mode": {+ "name": "runtime_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'legacy'"+ },+ "runtime_mode_resolver_version": {+ "name": "runtime_mode_resolver_version",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "runtime_mode_reason": {+ "name": "runtime_mode_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "runtime_mode_resolved_at": {+ "name": "runtime_mode_resolved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "runner_profile_json": {+ "name": "runner_profile_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "runner_instance_id": {+ "name": "runner_instance_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "native_session_id": {+ "name": "native_session_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "native_issue_id": {+ "name": "native_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "driver_kind": {+ "name": "driver_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "driver_version": {+ "name": "driver_version",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "completion_contract_id": {+ "name": "completion_contract_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "completion_contract_sha256": {+ "name": "completion_contract_sha256",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "next_event_seq": {+ "name": "next_event_seq",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "native_phase": {+ "name": "native_phase",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "native_phase_updated_at": {+ "name": "native_phase_updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "session_id_before": {+ "name": "session_id_before",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "session_id_after": {+ "name": "session_id_after",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "log_store": {+ "name": "log_store",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "log_ref": {+ "name": "log_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "log_bytes": {+ "name": "log_bytes",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false+ },+ "log_sha256": {+ "name": "log_sha256",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "log_compressed": {+ "name": "log_compressed",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "stdout_excerpt": {+ "name": "stdout_excerpt",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "stderr_excerpt": {+ "name": "stderr_excerpt",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "error_code": {+ "name": "error_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "external_run_id": {+ "name": "external_run_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "controller_boot_id": {+ "name": "controller_boot_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "controller_lease_expires_at": {+ "name": "controller_lease_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "execution_stage": {+ "name": "execution_stage",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "process_pid": {+ "name": "process_pid",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "process_group_id": {+ "name": "process_group_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "process_started_at": {+ "name": "process_started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_output_at": {+ "name": "last_output_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_output_seq": {+ "name": "last_output_seq",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "last_output_stream": {+ "name": "last_output_stream",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "last_output_bytes": {+ "name": "last_output_bytes",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false+ },+ "retry_of_run_id": {+ "name": "retry_of_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "process_loss_retry_count": {+ "name": "process_loss_retry_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "scheduled_retry_at": {+ "name": "scheduled_retry_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "scheduled_retry_attempt": {+ "name": "scheduled_retry_attempt",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "scheduled_retry_reason": {+ "name": "scheduled_retry_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "issue_comment_status": {+ "name": "issue_comment_status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'not_applicable'"+ },+ "issue_comment_satisfied_by_comment_id": {+ "name": "issue_comment_satisfied_by_comment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "issue_comment_retry_queued_at": {+ "name": "issue_comment_retry_queued_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "liveness_state": {+ "name": "liveness_state",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "liveness_reason": {+ "name": "liveness_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "continuation_attempt": {+ "name": "continuation_attempt",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "last_useful_action_at": {+ "name": "last_useful_action_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "next_action": {+ "name": "next_action",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "context_snapshot": {+ "name": "context_snapshot",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "heartbeat_runs_execution_status_delivery_idx": {+ "name": "heartbeat_runs_execution_status_delivery_idx",+ "columns": [+ {+ "expression": "execution_status_delivery_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"heartbeat_runs\".\"execution_status_delivery_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "heartbeat_runs_execution_control_deadline_idx": {+ "name": "heartbeat_runs_execution_control_deadline_idx",+ "columns": [+ {+ "expression": "execution_control_deadline_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"heartbeat_runs\".\"execution_control_deadline_at\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "heartbeat_runs_native_replacement_predecessor_uq": {+ "name": "heartbeat_runs_native_replacement_predecessor_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "retry_of_run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"heartbeat_runs\".\"scheduled_retry_reason\" = 'native_safe_replacement'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "heartbeat_runs_company_agent_started_idx": {+ "name": "heartbeat_runs_company_agent_started_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "started_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "heartbeat_runs_company_responsible_user_idx": {+ "name": "heartbeat_runs_company_responsible_user_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "responsible_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "heartbeat_runs_company_liveness_idx": {+ "name": "heartbeat_runs_company_liveness_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "liveness_state",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "heartbeat_runs_company_status_last_output_idx": {+ "name": "heartbeat_runs_company_status_last_output_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "last_output_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "heartbeat_runs_company_status_process_started_idx": {+ "name": "heartbeat_runs_company_status_process_started_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "process_started_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "heartbeat_runs_company_created_at_desc_idx": {+ "name": "heartbeat_runs_company_created_at_desc_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "heartbeat_runs_company_ctx_issue_created_idx": {+ "name": "heartbeat_runs_company_ctx_issue_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "(\"context_snapshot\" ->> 'issueId')",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "heartbeat_runs_company_ctx_task_created_idx": {+ "name": "heartbeat_runs_company_ctx_task_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "(\"context_snapshot\" ->> 'taskId')",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "heartbeat_runs_company_ctx_taskkey_created_idx": {+ "name": "heartbeat_runs_company_ctx_taskkey_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "(\"context_snapshot\" ->> 'taskKey')",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "heartbeat_runs_company_id_companies_id_fk": {+ "name": "heartbeat_runs_company_id_companies_id_fk",+ "tableFrom": "heartbeat_runs",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "heartbeat_runs_agent_id_agents_id_fk": {+ "name": "heartbeat_runs_agent_id_agents_id_fk",+ "tableFrom": "heartbeat_runs",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "heartbeat_runs_wakeup_request_id_agent_wakeup_requests_id_fk": {+ "name": "heartbeat_runs_wakeup_request_id_agent_wakeup_requests_id_fk",+ "tableFrom": "heartbeat_runs",+ "tableTo": "agent_wakeup_requests",+ "columnsFrom": [+ "wakeup_request_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "heartbeat_runs_retry_of_run_id_heartbeat_runs_id_fk": {+ "name": "heartbeat_runs_retry_of_run_id_heartbeat_runs_id_fk",+ "tableFrom": "heartbeat_runs",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "retry_of_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "heartbeat_runs_company_native_issue_id_uq": {+ "name": "heartbeat_runs_company_native_issue_id_uq",+ "nullsNotDistinct": false,+ "columns": [+ "company_id",+ "native_issue_id",+ "id"+ ]+ },+ "heartbeat_runs_company_native_issue_contract_id_uq": {+ "name": "heartbeat_runs_company_native_issue_contract_id_uq",+ "nullsNotDistinct": false,+ "columns": [+ "company_id",+ "native_issue_id",+ "id",+ "completion_contract_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.inbox_dismissals": {+ "name": "inbox_dismissals",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "item_key": {+ "name": "item_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'dismiss'"+ },+ "dismissed_at": {+ "name": "dismissed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "snoozed_until": {+ "name": "snoozed_until",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "inbox_dismissals_company_user_idx": {+ "name": "inbox_dismissals_company_user_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "inbox_dismissals_company_item_idx": {+ "name": "inbox_dismissals_company_item_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "item_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "inbox_dismissals_company_user_item_idx": {+ "name": "inbox_dismissals_company_user_item_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "item_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "inbox_dismissals_company_id_companies_id_fk": {+ "name": "inbox_dismissals_company_id_companies_id_fk",+ "tableFrom": "inbox_dismissals",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.connection_grant_delegations": {+ "name": "connection_grant_delegations",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "grant_id": {+ "name": "grant_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "connection_grant_delegations_company_agent_idx": {+ "name": "connection_grant_delegations_company_agent_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "connection_grant_delegations_grant_agent_uq": {+ "name": "connection_grant_delegations_grant_agent_uq",+ "columns": [+ {+ "expression": "grant_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "connection_grant_delegations_company_id_companies_id_fk": {+ "name": "connection_grant_delegations_company_id_companies_id_fk",+ "tableFrom": "connection_grant_delegations",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "connection_grant_delegations_agent_id_agents_id_fk": {+ "name": "connection_grant_delegations_agent_id_agents_id_fk",+ "tableFrom": "connection_grant_delegations",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "connection_grant_delegations_company_grant_fk": {+ "name": "connection_grant_delegations_company_grant_fk",+ "tableFrom": "connection_grant_delegations",+ "tableTo": "connection_grants",+ "columnsFrom": [+ "company_id",+ "grant_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.connection_grant_members": {+ "name": "connection_grant_members",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "grant_id": {+ "name": "grant_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "subject_type": {+ "name": "subject_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "subject_id": {+ "name": "subject_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "connection_grant_members_company_subject_idx": {+ "name": "connection_grant_members_company_subject_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "connection_grant_members_grant_subject_uq": {+ "name": "connection_grant_members_grant_subject_uq",+ "columns": [+ {+ "expression": "grant_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "connection_grant_members_company_id_companies_id_fk": {+ "name": "connection_grant_members_company_id_companies_id_fk",+ "tableFrom": "connection_grant_members",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "connection_grant_members_company_grant_fk": {+ "name": "connection_grant_members_company_grant_fk",+ "tableFrom": "connection_grant_members",+ "tableTo": "connection_grants",+ "columnsFrom": [+ "company_id",+ "grant_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "connection_grant_members_subject_type_check": {+ "name": "connection_grant_members_subject_type_check",+ "value": "\"connection_grant_members\".\"subject_type\" in ('user')"+ }+ },+ "isRLSEnabled": false+ },+ "public.connection_grants": {+ "name": "connection_grants",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "connection_id": {+ "name": "connection_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "subject_user_id": {+ "name": "subject_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "subject_agent_id": {+ "name": "subject_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "provider_tenant": {+ "name": "provider_tenant",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "credential_secret_refs": {+ "name": "credential_secret_refs",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "external_credential": {+ "name": "external_credential",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "is_default": {+ "name": "is_default",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "revoked_at": {+ "name": "revoked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "revoked_by_agent_id": {+ "name": "revoked_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "revoked_by_user_id": {+ "name": "revoked_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "last_used_at": {+ "name": "last_used_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "connection_grants_company_connection_idx": {+ "name": "connection_grants_company_connection_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "connection_grants_subject_user_idx": {+ "name": "connection_grants_subject_user_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "connection_grants_subject_agent_idx": {+ "name": "connection_grants_subject_agent_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "connection_grants_user_uq": {+ "name": "connection_grants_user_uq",+ "columns": [+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "connection_grants_agent_uq": {+ "name": "connection_grants_agent_uq",+ "columns": [+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "connection_grants_default_uq": {+ "name": "connection_grants_default_uq",+ "columns": [+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"connection_grants\".\"is_default\" = true and \"connection_grants\".\"kind\" = 'organization'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "connection_grants_company_id_companies_id_fk": {+ "name": "connection_grants_company_id_companies_id_fk",+ "tableFrom": "connection_grants",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "connection_grants_subject_agent_id_agents_id_fk": {+ "name": "connection_grants_subject_agent_id_agents_id_fk",+ "tableFrom": "connection_grants",+ "tableTo": "agents",+ "columnsFrom": [+ "subject_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "connection_grants_created_by_agent_id_agents_id_fk": {+ "name": "connection_grants_created_by_agent_id_agents_id_fk",+ "tableFrom": "connection_grants",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "connection_grants_revoked_by_agent_id_agents_id_fk": {+ "name": "connection_grants_revoked_by_agent_id_agents_id_fk",+ "tableFrom": "connection_grants",+ "tableTo": "agents",+ "columnsFrom": [+ "revoked_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "connection_grants_company_connection_fk": {+ "name": "connection_grants_company_connection_fk",+ "tableFrom": "connection_grants",+ "tableTo": "tool_connections",+ "columnsFrom": [+ "company_id",+ "connection_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "connection_grants_company_id_uq": {+ "name": "connection_grants_company_id_uq",+ "nullsNotDistinct": false,+ "columns": [+ "company_id",+ "id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "connection_grants_kind_check": {+ "name": "connection_grants_kind_check",+ "value": "\"connection_grants\".\"kind\" in ('organization', 'user', 'agent')"+ },+ "connection_grants_status_check": {+ "name": "connection_grants_status_check",+ "value": "\"connection_grants\".\"status\" in ('active', 'revoked', 'expired', 'needs_reauthorization')"+ },+ "connection_grants_credential_source_one_of_check": {+ "name": "connection_grants_credential_source_one_of_check",+ "value": "\"connection_grants\".\"external_credential\" is null or jsonb_array_length(\"connection_grants\".\"credential_secret_refs\") = 0"+ },+ "connection_grants_subject_check": {+ "name": "connection_grants_subject_check",+ "value": "(\"connection_grants\".\"kind\" = 'user' and \"connection_grants\".\"subject_user_id\" is not null and \"connection_grants\".\"subject_agent_id\" is null) or (\"connection_grants\".\"kind\" = 'agent' and \"connection_grants\".\"subject_agent_id\" is not null and \"connection_grants\".\"subject_user_id\" is null) or (\"connection_grants\".\"kind\" = 'organization' and \"connection_grants\".\"subject_user_id\" is null and \"connection_grants\".\"subject_agent_id\" is null)"+ },+ "connection_grants_default_check": {+ "name": "connection_grants_default_check",+ "value": "\"connection_grants\".\"is_default\" = false or \"connection_grants\".\"kind\" = 'organization'"+ }+ },+ "isRLSEnabled": false+ },+ "public.connection_token_issuances": {+ "name": "connection_token_issuances",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "application_id": {+ "name": "application_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "connection_id": {+ "name": "connection_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "project_id": {+ "name": "project_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "responsible_user_id": {+ "name": "responsible_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "path": {+ "name": "path",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "requested_scope": {+ "name": "requested_scope",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "issued_scope": {+ "name": "issued_scope",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "ttl_seconds": {+ "name": "ttl_seconds",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "token_hash": {+ "name": "token_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "outcome": {+ "name": "outcome",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "error_code": {+ "name": "error_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "connection_token_issuances_company_created_idx": {+ "name": "connection_token_issuances_company_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "connection_token_issuances_connection_created_idx": {+ "name": "connection_token_issuances_connection_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "connection_token_issuances_agent_connection_idx": {+ "name": "connection_token_issuances_agent_connection_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "connection_token_issuances_run_idx": {+ "name": "connection_token_issuances_run_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "connection_token_issuances_company_id_companies_id_fk": {+ "name": "connection_token_issuances_company_id_companies_id_fk",+ "tableFrom": "connection_token_issuances",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "connection_token_issuances_application_id_tool_applications_id_fk": {+ "name": "connection_token_issuances_application_id_tool_applications_id_fk",+ "tableFrom": "connection_token_issuances",+ "tableTo": "tool_applications",+ "columnsFrom": [+ "application_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "connection_token_issuances_connection_id_tool_connections_id_fk": {+ "name": "connection_token_issuances_connection_id_tool_connections_id_fk",+ "tableFrom": "connection_token_issuances",+ "tableTo": "tool_connections",+ "columnsFrom": [+ "connection_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "connection_token_issuances_agent_id_agents_id_fk": {+ "name": "connection_token_issuances_agent_id_agents_id_fk",+ "tableFrom": "connection_token_issuances",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "connection_token_issuances_run_id_heartbeat_runs_id_fk": {+ "name": "connection_token_issuances_run_id_heartbeat_runs_id_fk",+ "tableFrom": "connection_token_issuances",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "connection_token_issuances_issue_id_issues_id_fk": {+ "name": "connection_token_issuances_issue_id_issues_id_fk",+ "tableFrom": "connection_token_issuances",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "connection_token_issuances_project_id_projects_id_fk": {+ "name": "connection_token_issuances_project_id_projects_id_fk",+ "tableFrom": "connection_token_issuances",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.instance_settings": {+ "name": "instance_settings",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "singleton_key": {+ "name": "singleton_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'default'"+ },+ "default_environment_id": {+ "name": "default_environment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "general": {+ "name": "general",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "experimental": {+ "name": "experimental",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "instance_settings_singleton_key_idx": {+ "name": "instance_settings_singleton_key_idx",+ "columns": [+ {+ "expression": "singleton_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "instance_settings_default_environment_id_environments_id_fk": {+ "name": "instance_settings_default_environment_id_environments_id_fk",+ "tableFrom": "instance_settings",+ "tableTo": "environments",+ "columnsFrom": [+ "default_environment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.instance_user_roles": {+ "name": "instance_user_roles",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'instance_admin'"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "instance_user_roles_user_role_unique_idx": {+ "name": "instance_user_roles_user_role_unique_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "role",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "instance_user_roles_role_idx": {+ "name": "instance_user_roles_role_idx",+ "columns": [+ {+ "expression": "role",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.invites": {+ "name": "invites",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "invite_type": {+ "name": "invite_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'company_join'"+ },+ "token_hash": {+ "name": "token_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "allowed_join_types": {+ "name": "allowed_join_types",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'both'"+ },+ "defaults_payload": {+ "name": "defaults_payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "invited_by_user_id": {+ "name": "invited_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "revoked_at": {+ "name": "revoked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accepted_at": {+ "name": "accepted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "invites_token_hash_unique_idx": {+ "name": "invites_token_hash_unique_idx",+ "columns": [+ {+ "expression": "token_hash",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "invites_company_invite_state_idx": {+ "name": "invites_company_invite_state_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "invite_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "revoked_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "invites_company_id_companies_id_fk": {+ "name": "invites_company_id_companies_id_fk",+ "tableFrom": "invites",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_approvals": {+ "name": "issue_approvals",+ "schema": "",+ "columns": {+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "approval_id": {+ "name": "approval_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "linked_by_agent_id": {+ "name": "linked_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "linked_by_user_id": {+ "name": "linked_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_approvals_issue_idx": {+ "name": "issue_approvals_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_approvals_approval_idx": {+ "name": "issue_approvals_approval_idx",+ "columns": [+ {+ "expression": "approval_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_approvals_company_idx": {+ "name": "issue_approvals_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_approvals_company_id_companies_id_fk": {+ "name": "issue_approvals_company_id_companies_id_fk",+ "tableFrom": "issue_approvals",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_approvals_issue_id_issues_id_fk": {+ "name": "issue_approvals_issue_id_issues_id_fk",+ "tableFrom": "issue_approvals",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_approvals_approval_id_approvals_id_fk": {+ "name": "issue_approvals_approval_id_approvals_id_fk",+ "tableFrom": "issue_approvals",+ "tableTo": "approvals",+ "columnsFrom": [+ "approval_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_approvals_linked_by_agent_id_agents_id_fk": {+ "name": "issue_approvals_linked_by_agent_id_agents_id_fk",+ "tableFrom": "issue_approvals",+ "tableTo": "agents",+ "columnsFrom": [+ "linked_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "issue_approvals_pk": {+ "name": "issue_approvals_pk",+ "columns": [+ "issue_id",+ "approval_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_attachments": {+ "name": "issue_attachments",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "asset_id": {+ "name": "asset_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_comment_id": {+ "name": "issue_comment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "originating_run_id": {+ "name": "originating_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_attachments_company_issue_idx": {+ "name": "issue_attachments_company_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_attachments_issue_comment_idx": {+ "name": "issue_attachments_issue_comment_idx",+ "columns": [+ {+ "expression": "issue_comment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_attachments_originating_run_idx": {+ "name": "issue_attachments_originating_run_idx",+ "columns": [+ {+ "expression": "originating_run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_attachments_asset_uq": {+ "name": "issue_attachments_asset_uq",+ "columns": [+ {+ "expression": "asset_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_attachments_company_id_companies_id_fk": {+ "name": "issue_attachments_company_id_companies_id_fk",+ "tableFrom": "issue_attachments",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_attachments_issue_id_issues_id_fk": {+ "name": "issue_attachments_issue_id_issues_id_fk",+ "tableFrom": "issue_attachments",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_attachments_asset_id_assets_id_fk": {+ "name": "issue_attachments_asset_id_assets_id_fk",+ "tableFrom": "issue_attachments",+ "tableTo": "assets",+ "columnsFrom": [+ "asset_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_attachments_issue_comment_id_issue_comments_id_fk": {+ "name": "issue_attachments_issue_comment_id_issue_comments_id_fk",+ "tableFrom": "issue_attachments",+ "tableTo": "issue_comments",+ "columnsFrom": [+ "issue_comment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_attachments_originating_run_id_heartbeat_runs_id_fk": {+ "name": "issue_attachments_originating_run_id_heartbeat_runs_id_fk",+ "tableFrom": "issue_attachments",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "originating_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_comments": {+ "name": "issue_comments",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "author_agent_id": {+ "name": "author_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "author_user_id": {+ "name": "author_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "on_behalf_of_user_id": {+ "name": "on_behalf_of_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "author_type": {+ "name": "author_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_run_id": {+ "name": "created_by_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "derived_author_agent_id": {+ "name": "derived_author_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "derived_created_by_run_id": {+ "name": "derived_created_by_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "derived_author_source": {+ "name": "derived_author_source",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_request_id": {+ "name": "client_request_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "conversation_session_generation": {+ "name": "conversation_session_generation",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "body": {+ "name": "body",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "presentation": {+ "name": "presentation",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_by_type": {+ "name": "deleted_by_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_by_agent_id": {+ "name": "deleted_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_by_user_id": {+ "name": "deleted_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_by_run_id": {+ "name": "deleted_by_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "source_trust": {+ "name": "source_trust",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_comments_issue_idx": {+ "name": "issue_comments_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_comments_company_idx": {+ "name": "issue_comments_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_comments_company_issue_created_at_idx": {+ "name": "issue_comments_company_issue_created_at_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_comments_company_author_issue_created_at_idx": {+ "name": "issue_comments_company_author_issue_created_at_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "author_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_comments_body_search_idx": {+ "name": "issue_comments_body_search_idx",+ "columns": [+ {+ "expression": "body",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "gin_trgm_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "gin",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_comments_company_id_companies_id_fk": {+ "name": "issue_comments_company_id_companies_id_fk",+ "tableFrom": "issue_comments",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_comments_issue_id_issues_id_fk": {+ "name": "issue_comments_issue_id_issues_id_fk",+ "tableFrom": "issue_comments",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_comments_author_agent_id_agents_id_fk": {+ "name": "issue_comments_author_agent_id_agents_id_fk",+ "tableFrom": "issue_comments",+ "tableTo": "agents",+ "columnsFrom": [+ "author_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_comments_on_behalf_of_user_id_user_id_fk": {+ "name": "issue_comments_on_behalf_of_user_id_user_id_fk",+ "tableFrom": "issue_comments",+ "tableTo": "user",+ "columnsFrom": [+ "on_behalf_of_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_comments_created_by_run_id_heartbeat_runs_id_fk": {+ "name": "issue_comments_created_by_run_id_heartbeat_runs_id_fk",+ "tableFrom": "issue_comments",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "created_by_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_comments_derived_author_agent_id_agents_id_fk": {+ "name": "issue_comments_derived_author_agent_id_agents_id_fk",+ "tableFrom": "issue_comments",+ "tableTo": "agents",+ "columnsFrom": [+ "derived_author_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_comments_derived_created_by_run_id_heartbeat_runs_id_fk": {+ "name": "issue_comments_derived_created_by_run_id_heartbeat_runs_id_fk",+ "tableFrom": "issue_comments",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "derived_created_by_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_comments_deleted_by_agent_id_agents_id_fk": {+ "name": "issue_comments_deleted_by_agent_id_agents_id_fk",+ "tableFrom": "issue_comments",+ "tableTo": "agents",+ "columnsFrom": [+ "deleted_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_comments_deleted_by_run_id_heartbeat_runs_id_fk": {+ "name": "issue_comments_deleted_by_run_id_heartbeat_runs_id_fk",+ "tableFrom": "issue_comments",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "deleted_by_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_comments_client_request_uq": {+ "name": "issue_comments_client_request_uq",+ "nullsNotDistinct": false,+ "columns": [+ "issue_id",+ "author_user_id",+ "client_request_id"+ ]+ },+ "issue_comments_company_id_uq": {+ "name": "issue_comments_company_id_uq",+ "nullsNotDistinct": false,+ "columns": [+ "company_id",+ "id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_create_idempotency_keys": {+ "name": "issue_create_idempotency_keys",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "idempotency_key": {+ "name": "idempotency_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_create_idempotency_keys_company_key_uq": {+ "name": "issue_create_idempotency_keys_company_key_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "idempotency_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_create_idempotency_keys_issue_idx": {+ "name": "issue_create_idempotency_keys_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_create_idempotency_keys_company_created_at_idx": {+ "name": "issue_create_idempotency_keys_company_created_at_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_create_idempotency_keys_company_id_companies_id_fk": {+ "name": "issue_create_idempotency_keys_company_id_companies_id_fk",+ "tableFrom": "issue_create_idempotency_keys",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_create_idempotency_keys_issue_id_issues_id_fk": {+ "name": "issue_create_idempotency_keys_issue_id_issues_id_fk",+ "tableFrom": "issue_create_idempotency_keys",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_documents": {+ "name": "issue_documents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "document_id": {+ "name": "document_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_documents_company_issue_key_uq": {+ "name": "issue_documents_company_issue_key_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_documents_document_uq": {+ "name": "issue_documents_document_uq",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_documents_company_issue_updated_idx": {+ "name": "issue_documents_company_issue_updated_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_documents_company_id_companies_id_fk": {+ "name": "issue_documents_company_id_companies_id_fk",+ "tableFrom": "issue_documents",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_documents_issue_id_issues_id_fk": {+ "name": "issue_documents_issue_id_issues_id_fk",+ "tableFrom": "issue_documents",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_documents_document_id_documents_id_fk": {+ "name": "issue_documents_document_id_documents_id_fk",+ "tableFrom": "issue_documents",+ "tableTo": "documents",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_execution_decisions": {+ "name": "issue_execution_decisions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "stage_id": {+ "name": "stage_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "stage_type": {+ "name": "stage_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "actor_agent_id": {+ "name": "actor_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "actor_user_id": {+ "name": "actor_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "outcome": {+ "name": "outcome",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "body": {+ "name": "body",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_run_id": {+ "name": "created_by_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_execution_decisions_company_issue_idx": {+ "name": "issue_execution_decisions_company_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_execution_decisions_stage_idx": {+ "name": "issue_execution_decisions_stage_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "stage_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_execution_decisions_company_id_companies_id_fk": {+ "name": "issue_execution_decisions_company_id_companies_id_fk",+ "tableFrom": "issue_execution_decisions",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_execution_decisions_issue_id_issues_id_fk": {+ "name": "issue_execution_decisions_issue_id_issues_id_fk",+ "tableFrom": "issue_execution_decisions",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_execution_decisions_actor_agent_id_agents_id_fk": {+ "name": "issue_execution_decisions_actor_agent_id_agents_id_fk",+ "tableFrom": "issue_execution_decisions",+ "tableTo": "agents",+ "columnsFrom": [+ "actor_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_execution_decisions_created_by_run_id_heartbeat_runs_id_fk": {+ "name": "issue_execution_decisions_created_by_run_id_heartbeat_runs_id_fk",+ "tableFrom": "issue_execution_decisions",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "created_by_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_inbox_archives": {+ "name": "issue_inbox_archives",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "archived_by_actor_type": {+ "name": "archived_by_actor_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'user'"+ },+ "archived_by_agent_id": {+ "name": "archived_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "archived_by_run_id": {+ "name": "archived_by_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "archived_at": {+ "name": "archived_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_inbox_archives_company_issue_idx": {+ "name": "issue_inbox_archives_company_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_inbox_archives_company_user_idx": {+ "name": "issue_inbox_archives_company_user_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_inbox_archives_company_issue_user_idx": {+ "name": "issue_inbox_archives_company_issue_user_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_inbox_archives_company_id_companies_id_fk": {+ "name": "issue_inbox_archives_company_id_companies_id_fk",+ "tableFrom": "issue_inbox_archives",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_inbox_archives_issue_id_issues_id_fk": {+ "name": "issue_inbox_archives_issue_id_issues_id_fk",+ "tableFrom": "issue_inbox_archives",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_inbox_archives_archived_by_agent_id_agents_id_fk": {+ "name": "issue_inbox_archives_archived_by_agent_id_agents_id_fk",+ "tableFrom": "issue_inbox_archives",+ "tableTo": "agents",+ "columnsFrom": [+ "archived_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_inbox_archives_archived_by_run_id_heartbeat_runs_id_fk": {+ "name": "issue_inbox_archives_archived_by_run_id_heartbeat_runs_id_fk",+ "tableFrom": "issue_inbox_archives",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "archived_by_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "issue_inbox_archives_archived_by_actor_type_check": {+ "name": "issue_inbox_archives_archived_by_actor_type_check",+ "value": "\"issue_inbox_archives\".\"archived_by_actor_type\" in ('user', 'agent')"+ }+ },+ "isRLSEnabled": false+ },+ "public.issue_labels": {+ "name": "issue_labels",+ "schema": "",+ "columns": {+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "label_id": {+ "name": "label_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_labels_issue_idx": {+ "name": "issue_labels_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_labels_label_idx": {+ "name": "issue_labels_label_idx",+ "columns": [+ {+ "expression": "label_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_labels_company_idx": {+ "name": "issue_labels_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_labels_issue_id_issues_id_fk": {+ "name": "issue_labels_issue_id_issues_id_fk",+ "tableFrom": "issue_labels",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_labels_label_id_labels_id_fk": {+ "name": "issue_labels_label_id_labels_id_fk",+ "tableFrom": "issue_labels",+ "tableTo": "labels",+ "columnsFrom": [+ "label_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_labels_company_id_companies_id_fk": {+ "name": "issue_labels_company_id_companies_id_fk",+ "tableFrom": "issue_labels",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "issue_labels_pk": {+ "name": "issue_labels_pk",+ "columns": [+ "issue_id",+ "label_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_plan_decompositions": {+ "name": "issue_plan_decompositions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "source_issue_id": {+ "name": "source_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "accepted_plan_revision_id": {+ "name": "accepted_plan_revision_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "accepted_interaction_id": {+ "name": "accepted_interaction_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'in_flight'"+ },+ "request_fingerprint": {+ "name": "request_fingerprint",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "requested_child_count": {+ "name": "requested_child_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "requested_children": {+ "name": "requested_children",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "child_issue_ids": {+ "name": "child_issue_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "owner_agent_id": {+ "name": "owner_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "owner_run_id": {+ "name": "owner_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_plan_decompositions_company_source_status_idx": {+ "name": "issue_plan_decompositions_company_source_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_plan_decompositions_active_owner_idx": {+ "name": "issue_plan_decompositions_active_owner_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "owner_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"issue_plan_decompositions\".\"status\" = 'in_flight'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_plan_decompositions_source_revision_uq": {+ "name": "issue_plan_decompositions_source_revision_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "accepted_plan_revision_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_plan_decompositions_company_id_companies_id_fk": {+ "name": "issue_plan_decompositions_company_id_companies_id_fk",+ "tableFrom": "issue_plan_decompositions",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_plan_decompositions_source_issue_id_issues_id_fk": {+ "name": "issue_plan_decompositions_source_issue_id_issues_id_fk",+ "tableFrom": "issue_plan_decompositions",+ "tableTo": "issues",+ "columnsFrom": [+ "source_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_plan_decompositions_accepted_plan_revision_id_document_revisions_id_fk": {+ "name": "issue_plan_decompositions_accepted_plan_revision_id_document_revisions_id_fk",+ "tableFrom": "issue_plan_decompositions",+ "tableTo": "document_revisions",+ "columnsFrom": [+ "accepted_plan_revision_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_plan_decompositions_accepted_interaction_id_issue_thread_interactions_id_fk": {+ "name": "issue_plan_decompositions_accepted_interaction_id_issue_thread_interactions_id_fk",+ "tableFrom": "issue_plan_decompositions",+ "tableTo": "issue_thread_interactions",+ "columnsFrom": [+ "accepted_interaction_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_plan_decompositions_owner_agent_id_agents_id_fk": {+ "name": "issue_plan_decompositions_owner_agent_id_agents_id_fk",+ "tableFrom": "issue_plan_decompositions",+ "tableTo": "agents",+ "columnsFrom": [+ "owner_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_plan_decompositions_owner_run_id_heartbeat_runs_id_fk": {+ "name": "issue_plan_decompositions_owner_run_id_heartbeat_runs_id_fk",+ "tableFrom": "issue_plan_decompositions",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "owner_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_question_response_deliveries": {+ "name": "issue_question_response_deliveries",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "interaction_id": {+ "name": "interaction_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "source_run_id": {+ "name": "source_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "target_run_id": {+ "name": "target_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "target_turn_id": {+ "name": "target_turn_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "correlation_id": {+ "name": "correlation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "payload_sha256": {+ "name": "payload_sha256",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "delivery_mode": {+ "name": "delivery_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "attempt_count": {+ "name": "attempt_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "error_count": {+ "name": "error_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "last_attempt_at": {+ "name": "last_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "acknowledged_at": {+ "name": "acknowledged_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_error_code": {+ "name": "last_error_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_question_response_deliveries_interaction_uq": {+ "name": "issue_question_response_deliveries_interaction_uq",+ "columns": [+ {+ "expression": "interaction_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_question_response_deliveries_correlation_uq": {+ "name": "issue_question_response_deliveries_correlation_uq",+ "columns": [+ {+ "expression": "correlation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_question_response_deliveries_pending_idx": {+ "name": "issue_question_response_deliveries_pending_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_question_response_deliveries_company_issue_idx": {+ "name": "issue_question_response_deliveries_company_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_question_response_deliveries_company_id_companies_id_fk": {+ "name": "issue_question_response_deliveries_company_id_companies_id_fk",+ "tableFrom": "issue_question_response_deliveries",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_question_response_deliveries_issue_id_issues_id_fk": {+ "name": "issue_question_response_deliveries_issue_id_issues_id_fk",+ "tableFrom": "issue_question_response_deliveries",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_question_response_deliveries_interaction_id_issue_thread_interactions_id_fk": {+ "name": "issue_question_response_deliveries_interaction_id_issue_thread_interactions_id_fk",+ "tableFrom": "issue_question_response_deliveries",+ "tableTo": "issue_thread_interactions",+ "columnsFrom": [+ "interaction_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_question_response_deliveries_source_run_id_heartbeat_runs_id_fk": {+ "name": "issue_question_response_deliveries_source_run_id_heartbeat_runs_id_fk",+ "tableFrom": "issue_question_response_deliveries",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "source_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_question_response_deliveries_target_run_id_heartbeat_runs_id_fk": {+ "name": "issue_question_response_deliveries_target_run_id_heartbeat_runs_id_fk",+ "tableFrom": "issue_question_response_deliveries",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "target_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "issue_question_response_deliveries_status_check": {+ "name": "issue_question_response_deliveries_status_check",+ "value": "\"issue_question_response_deliveries\".\"status\" IN ('pending', 'delivering', 'delivered', 'fallback_queued', 'failed')"+ },+ "issue_question_response_deliveries_mode_check": {+ "name": "issue_question_response_deliveries_mode_check",+ "value": "\"issue_question_response_deliveries\".\"delivery_mode\" IS NULL OR \"issue_question_response_deliveries\".\"delivery_mode\" IN ('steered', 'coalesced', 'wake_fallback')"+ }+ },+ "isRLSEnabled": false+ },+ "public.issue_read_states": {+ "name": "issue_read_states",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "last_read_at": {+ "name": "last_read_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_read_states_company_issue_idx": {+ "name": "issue_read_states_company_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_read_states_company_user_idx": {+ "name": "issue_read_states_company_user_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_read_states_company_issue_user_idx": {+ "name": "issue_read_states_company_issue_user_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_read_states_company_id_companies_id_fk": {+ "name": "issue_read_states_company_id_companies_id_fk",+ "tableFrom": "issue_read_states",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_read_states_issue_id_issues_id_fk": {+ "name": "issue_read_states_issue_id_issues_id_fk",+ "tableFrom": "issue_read_states",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_recovery_actions": {+ "name": "issue_recovery_actions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "source_issue_id": {+ "name": "source_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "recovery_issue_id": {+ "name": "recovery_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "owner_type": {+ "name": "owner_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'agent'"+ },+ "owner_agent_id": {+ "name": "owner_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "previous_owner_agent_id": {+ "name": "previous_owner_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "return_owner_agent_id": {+ "name": "return_owner_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "cause": {+ "name": "cause",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "fingerprint": {+ "name": "fingerprint",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "evidence": {+ "name": "evidence",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "next_action": {+ "name": "next_action",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "wake_policy": {+ "name": "wake_policy",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "monitor_policy": {+ "name": "monitor_policy",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "attempt_count": {+ "name": "attempt_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "max_attempts": {+ "name": "max_attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "timeout_at": {+ "name": "timeout_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_attempt_at": {+ "name": "last_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "outcome": {+ "name": "outcome",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resolution_note": {+ "name": "resolution_note",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_at": {+ "name": "resolved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_recovery_actions_company_source_status_idx": {+ "name": "issue_recovery_actions_company_source_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_recovery_actions_company_owner_status_idx": {+ "name": "issue_recovery_actions_company_owner_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "owner_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_recovery_actions_company_recovery_issue_idx": {+ "name": "issue_recovery_actions_company_recovery_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "recovery_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_recovery_actions_active_source_uq": {+ "name": "issue_recovery_actions_active_source_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"issue_recovery_actions\".\"status\" in ('active', 'escalated')",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_recovery_actions_active_fingerprint_uq": {+ "name": "issue_recovery_actions_active_fingerprint_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "cause",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "fingerprint",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"issue_recovery_actions\".\"status\" in ('active', 'escalated')",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_recovery_actions_company_id_companies_id_fk": {+ "name": "issue_recovery_actions_company_id_companies_id_fk",+ "tableFrom": "issue_recovery_actions",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_recovery_actions_source_issue_id_issues_id_fk": {+ "name": "issue_recovery_actions_source_issue_id_issues_id_fk",+ "tableFrom": "issue_recovery_actions",+ "tableTo": "issues",+ "columnsFrom": [+ "source_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_recovery_actions_recovery_issue_id_issues_id_fk": {+ "name": "issue_recovery_actions_recovery_issue_id_issues_id_fk",+ "tableFrom": "issue_recovery_actions",+ "tableTo": "issues",+ "columnsFrom": [+ "recovery_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_recovery_actions_owner_agent_id_agents_id_fk": {+ "name": "issue_recovery_actions_owner_agent_id_agents_id_fk",+ "tableFrom": "issue_recovery_actions",+ "tableTo": "agents",+ "columnsFrom": [+ "owner_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_recovery_actions_previous_owner_agent_id_agents_id_fk": {+ "name": "issue_recovery_actions_previous_owner_agent_id_agents_id_fk",+ "tableFrom": "issue_recovery_actions",+ "tableTo": "agents",+ "columnsFrom": [+ "previous_owner_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_recovery_actions_return_owner_agent_id_agents_id_fk": {+ "name": "issue_recovery_actions_return_owner_agent_id_agents_id_fk",+ "tableFrom": "issue_recovery_actions",+ "tableTo": "agents",+ "columnsFrom": [+ "return_owner_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_reference_mentions": {+ "name": "issue_reference_mentions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "source_issue_id": {+ "name": "source_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "target_issue_id": {+ "name": "target_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "source_kind": {+ "name": "source_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_record_id": {+ "name": "source_record_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "document_key": {+ "name": "document_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "matched_text": {+ "name": "matched_text",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_reference_mentions_company_source_issue_idx": {+ "name": "issue_reference_mentions_company_source_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_reference_mentions_company_target_issue_idx": {+ "name": "issue_reference_mentions_company_target_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_reference_mentions_company_issue_pair_idx": {+ "name": "issue_reference_mentions_company_issue_pair_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_reference_mentions_company_source_mention_record_uq": {+ "name": "issue_reference_mentions_company_source_mention_record_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_record_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"issue_reference_mentions\".\"source_record_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_reference_mentions_company_source_mention_null_record_uq": {+ "name": "issue_reference_mentions_company_source_mention_null_record_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"issue_reference_mentions\".\"source_record_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_reference_mentions_company_id_companies_id_fk": {+ "name": "issue_reference_mentions_company_id_companies_id_fk",+ "tableFrom": "issue_reference_mentions",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_reference_mentions_source_issue_id_issues_id_fk": {+ "name": "issue_reference_mentions_source_issue_id_issues_id_fk",+ "tableFrom": "issue_reference_mentions",+ "tableTo": "issues",+ "columnsFrom": [+ "source_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_reference_mentions_target_issue_id_issues_id_fk": {+ "name": "issue_reference_mentions_target_issue_id_issues_id_fk",+ "tableFrom": "issue_reference_mentions",+ "tableTo": "issues",+ "columnsFrom": [+ "target_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_relations": {+ "name": "issue_relations",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "related_issue_id": {+ "name": "related_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_relations_company_issue_idx": {+ "name": "issue_relations_company_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_relations_company_related_issue_idx": {+ "name": "issue_relations_company_related_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "related_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_relations_company_type_idx": {+ "name": "issue_relations_company_type_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_relations_company_edge_uq": {+ "name": "issue_relations_company_edge_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "related_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_relations_company_id_companies_id_fk": {+ "name": "issue_relations_company_id_companies_id_fk",+ "tableFrom": "issue_relations",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_relations_issue_id_issues_id_fk": {+ "name": "issue_relations_issue_id_issues_id_fk",+ "tableFrom": "issue_relations",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_relations_related_issue_id_issues_id_fk": {+ "name": "issue_relations_related_issue_id_issues_id_fk",+ "tableFrom": "issue_relations",+ "tableTo": "issues",+ "columnsFrom": [+ "related_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_relations_created_by_agent_id_agents_id_fk": {+ "name": "issue_relations_created_by_agent_id_agents_id_fk",+ "tableFrom": "issue_relations",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_thread_interactions": {+ "name": "issue_thread_interactions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "continuation_policy": {+ "name": "continuation_policy",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'wake_assignee'"+ },+ "requested_resolver_policy": {+ "name": "requested_resolver_policy",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'anyone'"+ },+ "effective_resolver_policy": {+ "name": "effective_resolver_policy",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'anyone'"+ },+ "resolver_policy_provenance": {+ "name": "resolver_policy_provenance",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'inherited'"+ },+ "effective_resolver_policy_source": {+ "name": "effective_resolver_policy_source",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'requested'"+ },+ "idempotency_key": {+ "name": "idempotency_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "origin_comment_ids": {+ "name": "origin_comment_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "source_comment_id": {+ "name": "source_comment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "source_identity_context_id": {+ "name": "source_identity_context_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "source_run_id": {+ "name": "source_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "summary": {+ "name": "summary",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "addressee_agent_id": {+ "name": "addressee_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "addressee_user_id": {+ "name": "addressee_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_by_agent_id": {+ "name": "resolved_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_by_run_id": {+ "name": "resolved_by_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_by_user_id": {+ "name": "resolved_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "result": {+ "name": "result",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_at": {+ "name": "resolved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_thread_interactions_issue_idx": {+ "name": "issue_thread_interactions_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_thread_interactions_company_issue_created_at_idx": {+ "name": "issue_thread_interactions_company_issue_created_at_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_thread_interactions_company_issue_status_idx": {+ "name": "issue_thread_interactions_company_issue_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_thread_interactions_company_issue_idempotency_uq": {+ "name": "issue_thread_interactions_company_issue_idempotency_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "idempotency_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"issue_thread_interactions\".\"idempotency_key\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_thread_interactions_source_comment_idx": {+ "name": "issue_thread_interactions_source_comment_idx",+ "columns": [+ {+ "expression": "source_comment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_thread_interactions_addressee_agent_idx": {+ "name": "issue_thread_interactions_addressee_agent_idx",+ "columns": [+ {+ "expression": "addressee_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_thread_interactions_addressee_user_idx": {+ "name": "issue_thread_interactions_addressee_user_idx",+ "columns": [+ {+ "expression": "addressee_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_thread_interactions_company_id_companies_id_fk": {+ "name": "issue_thread_interactions_company_id_companies_id_fk",+ "tableFrom": "issue_thread_interactions",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_thread_interactions_issue_id_issues_id_fk": {+ "name": "issue_thread_interactions_issue_id_issues_id_fk",+ "tableFrom": "issue_thread_interactions",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_thread_interactions_source_comment_id_issue_comments_id_fk": {+ "name": "issue_thread_interactions_source_comment_id_issue_comments_id_fk",+ "tableFrom": "issue_thread_interactions",+ "tableTo": "issue_comments",+ "columnsFrom": [+ "source_comment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_thread_interactions_source_run_id_heartbeat_runs_id_fk": {+ "name": "issue_thread_interactions_source_run_id_heartbeat_runs_id_fk",+ "tableFrom": "issue_thread_interactions",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "source_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_thread_interactions_created_by_agent_id_agents_id_fk": {+ "name": "issue_thread_interactions_created_by_agent_id_agents_id_fk",+ "tableFrom": "issue_thread_interactions",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_thread_interactions_addressee_agent_id_agents_id_fk": {+ "name": "issue_thread_interactions_addressee_agent_id_agents_id_fk",+ "tableFrom": "issue_thread_interactions",+ "tableTo": "agents",+ "columnsFrom": [+ "addressee_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_thread_interactions_resolved_by_agent_id_agents_id_fk": {+ "name": "issue_thread_interactions_resolved_by_agent_id_agents_id_fk",+ "tableFrom": "issue_thread_interactions",+ "tableTo": "agents",+ "columnsFrom": [+ "resolved_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_thread_interactions_resolved_by_run_id_heartbeat_runs_id_fk": {+ "name": "issue_thread_interactions_resolved_by_run_id_heartbeat_runs_id_fk",+ "tableFrom": "issue_thread_interactions",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "resolved_by_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_tree_hold_members": {+ "name": "issue_tree_hold_members",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "hold_id": {+ "name": "hold_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "parent_issue_id": {+ "name": "parent_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "depth": {+ "name": "depth",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "issue_identifier": {+ "name": "issue_identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "issue_title": {+ "name": "issue_title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "issue_status": {+ "name": "issue_status",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "assignee_agent_id": {+ "name": "assignee_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "assignee_user_id": {+ "name": "assignee_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "active_run_id": {+ "name": "active_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "active_run_status": {+ "name": "active_run_status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "skipped": {+ "name": "skipped",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "skip_reason": {+ "name": "skip_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_tree_hold_members_hold_issue_uq": {+ "name": "issue_tree_hold_members_hold_issue_uq",+ "columns": [+ {+ "expression": "hold_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_tree_hold_members_company_issue_idx": {+ "name": "issue_tree_hold_members_company_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_tree_hold_members_hold_depth_idx": {+ "name": "issue_tree_hold_members_hold_depth_idx",+ "columns": [+ {+ "expression": "hold_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "depth",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_tree_hold_members_company_id_companies_id_fk": {+ "name": "issue_tree_hold_members_company_id_companies_id_fk",+ "tableFrom": "issue_tree_hold_members",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_tree_hold_members_hold_id_issue_tree_holds_id_fk": {+ "name": "issue_tree_hold_members_hold_id_issue_tree_holds_id_fk",+ "tableFrom": "issue_tree_hold_members",+ "tableTo": "issue_tree_holds",+ "columnsFrom": [+ "hold_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_tree_hold_members_issue_id_issues_id_fk": {+ "name": "issue_tree_hold_members_issue_id_issues_id_fk",+ "tableFrom": "issue_tree_hold_members",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_tree_hold_members_parent_issue_id_issues_id_fk": {+ "name": "issue_tree_hold_members_parent_issue_id_issues_id_fk",+ "tableFrom": "issue_tree_hold_members",+ "tableTo": "issues",+ "columnsFrom": [+ "parent_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_tree_hold_members_assignee_agent_id_agents_id_fk": {+ "name": "issue_tree_hold_members_assignee_agent_id_agents_id_fk",+ "tableFrom": "issue_tree_hold_members",+ "tableTo": "agents",+ "columnsFrom": [+ "assignee_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_tree_hold_members_active_run_id_heartbeat_runs_id_fk": {+ "name": "issue_tree_hold_members_active_run_id_heartbeat_runs_id_fk",+ "tableFrom": "issue_tree_hold_members",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "active_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_tree_holds": {+ "name": "issue_tree_holds",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "root_issue_id": {+ "name": "root_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "mode": {+ "name": "mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "reason": {+ "name": "reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "release_policy": {+ "name": "release_policy",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_actor_type": {+ "name": "created_by_actor_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'system'"+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_run_id": {+ "name": "created_by_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "released_at": {+ "name": "released_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "released_by_actor_type": {+ "name": "released_by_actor_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "released_by_agent_id": {+ "name": "released_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "released_by_user_id": {+ "name": "released_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "released_by_run_id": {+ "name": "released_by_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "release_reason": {+ "name": "release_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "release_metadata": {+ "name": "release_metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_tree_holds_company_root_status_idx": {+ "name": "issue_tree_holds_company_root_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "root_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_tree_holds_company_status_mode_idx": {+ "name": "issue_tree_holds_company_status_mode_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "mode",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_tree_holds_company_id_companies_id_fk": {+ "name": "issue_tree_holds_company_id_companies_id_fk",+ "tableFrom": "issue_tree_holds",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_tree_holds_root_issue_id_issues_id_fk": {+ "name": "issue_tree_holds_root_issue_id_issues_id_fk",+ "tableFrom": "issue_tree_holds",+ "tableTo": "issues",+ "columnsFrom": [+ "root_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_tree_holds_created_by_agent_id_agents_id_fk": {+ "name": "issue_tree_holds_created_by_agent_id_agents_id_fk",+ "tableFrom": "issue_tree_holds",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_tree_holds_created_by_run_id_heartbeat_runs_id_fk": {+ "name": "issue_tree_holds_created_by_run_id_heartbeat_runs_id_fk",+ "tableFrom": "issue_tree_holds",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "created_by_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_tree_holds_released_by_agent_id_agents_id_fk": {+ "name": "issue_tree_holds_released_by_agent_id_agents_id_fk",+ "tableFrom": "issue_tree_holds",+ "tableTo": "agents",+ "columnsFrom": [+ "released_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_tree_holds_released_by_run_id_heartbeat_runs_id_fk": {+ "name": "issue_tree_holds_released_by_run_id_heartbeat_runs_id_fk",+ "tableFrom": "issue_tree_holds",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "released_by_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_watchdogs": {+ "name": "issue_watchdogs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "watchdog_agent_id": {+ "name": "watchdog_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "instructions": {+ "name": "instructions",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "watchdog_issue_id": {+ "name": "watchdog_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "last_observed_fingerprint": {+ "name": "last_observed_fingerprint",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "last_reviewed_fingerprint": {+ "name": "last_reviewed_fingerprint",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "last_observed_stop_snapshot": {+ "name": "last_observed_stop_snapshot",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "last_reviewed_stop_snapshot": {+ "name": "last_reviewed_stop_snapshot",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "last_triggered_at": {+ "name": "last_triggered_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_completed_at": {+ "name": "last_completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "trigger_count": {+ "name": "trigger_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_run_id": {+ "name": "created_by_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "updated_by_agent_id": {+ "name": "updated_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "updated_by_user_id": {+ "name": "updated_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "updated_by_run_id": {+ "name": "updated_by_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_watchdogs_company_issue_uq": {+ "name": "issue_watchdogs_company_issue_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_watchdogs_company_status_idx": {+ "name": "issue_watchdogs_company_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_watchdogs_company_agent_idx": {+ "name": "issue_watchdogs_company_agent_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "watchdog_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_watchdogs_company_watchdog_issue_uq": {+ "name": "issue_watchdogs_company_watchdog_issue_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "watchdog_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"issue_watchdogs\".\"watchdog_issue_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_watchdogs_company_id_companies_id_fk": {+ "name": "issue_watchdogs_company_id_companies_id_fk",+ "tableFrom": "issue_watchdogs",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_watchdogs_issue_id_issues_id_fk": {+ "name": "issue_watchdogs_issue_id_issues_id_fk",+ "tableFrom": "issue_watchdogs",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_watchdogs_watchdog_agent_id_agents_id_fk": {+ "name": "issue_watchdogs_watchdog_agent_id_agents_id_fk",+ "tableFrom": "issue_watchdogs",+ "tableTo": "agents",+ "columnsFrom": [+ "watchdog_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_watchdogs_watchdog_issue_id_issues_id_fk": {+ "name": "issue_watchdogs_watchdog_issue_id_issues_id_fk",+ "tableFrom": "issue_watchdogs",+ "tableTo": "issues",+ "columnsFrom": [+ "watchdog_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_watchdogs_created_by_agent_id_agents_id_fk": {+ "name": "issue_watchdogs_created_by_agent_id_agents_id_fk",+ "tableFrom": "issue_watchdogs",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_watchdogs_created_by_run_id_heartbeat_runs_id_fk": {+ "name": "issue_watchdogs_created_by_run_id_heartbeat_runs_id_fk",+ "tableFrom": "issue_watchdogs",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "created_by_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_watchdogs_updated_by_agent_id_agents_id_fk": {+ "name": "issue_watchdogs_updated_by_agent_id_agents_id_fk",+ "tableFrom": "issue_watchdogs",+ "tableTo": "agents",+ "columnsFrom": [+ "updated_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_watchdogs_updated_by_run_id_heartbeat_runs_id_fk": {+ "name": "issue_watchdogs_updated_by_run_id_heartbeat_runs_id_fk",+ "tableFrom": "issue_watchdogs",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "updated_by_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_work_products": {+ "name": "issue_work_products",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "execution_workspace_id": {+ "name": "execution_workspace_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "runtime_service_id": {+ "name": "runtime_service_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "external_id": {+ "name": "external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "review_state": {+ "name": "review_state",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'none'"+ },+ "is_primary": {+ "name": "is_primary",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "health_status": {+ "name": "health_status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'unknown'"+ },+ "summary": {+ "name": "summary",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "source_trust": {+ "name": "source_trust",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_run_id": {+ "name": "created_by_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_work_products_company_issue_type_idx": {+ "name": "issue_work_products_company_issue_type_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_work_products_company_execution_workspace_type_idx": {+ "name": "issue_work_products_company_execution_workspace_type_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "execution_workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_work_products_company_provider_external_id_idx": {+ "name": "issue_work_products_company_provider_external_id_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "external_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_work_products_company_updated_idx": {+ "name": "issue_work_products_company_updated_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_work_products_company_id_companies_id_fk": {+ "name": "issue_work_products_company_id_companies_id_fk",+ "tableFrom": "issue_work_products",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_work_products_project_id_projects_id_fk": {+ "name": "issue_work_products_project_id_projects_id_fk",+ "tableFrom": "issue_work_products",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_work_products_issue_id_issues_id_fk": {+ "name": "issue_work_products_issue_id_issues_id_fk",+ "tableFrom": "issue_work_products",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_work_products_execution_workspace_id_execution_workspaces_id_fk": {+ "name": "issue_work_products_execution_workspace_id_execution_workspaces_id_fk",+ "tableFrom": "issue_work_products",+ "tableTo": "execution_workspaces",+ "columnsFrom": [+ "execution_workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_work_products_runtime_service_id_workspace_runtime_services_id_fk": {+ "name": "issue_work_products_runtime_service_id_workspace_runtime_services_id_fk",+ "tableFrom": "issue_work_products",+ "tableTo": "workspace_runtime_services",+ "columnsFrom": [+ "runtime_service_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_work_products_created_by_run_id_heartbeat_runs_id_fk": {+ "name": "issue_work_products_created_by_run_id_heartbeat_runs_id_fk",+ "tableFrom": "issue_work_products",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "created_by_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issues": {+ "name": "issues",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "conversation_agent_id": {+ "name": "conversation_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "conversation_user_id": {+ "name": "conversation_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "conversation_state": {+ "name": "conversation_state",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "conversation_session_generation": {+ "name": "conversation_session_generation",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "conversation_boundary_comment_id": {+ "name": "conversation_boundary_comment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "project_id": {+ "name": "project_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "project_workspace_id": {+ "name": "project_workspace_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "goal_id": {+ "name": "goal_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "parent_id": {+ "name": "parent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'backlog'"+ },+ "status_version": {+ "name": "status_version",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "last_status_decision_id": {+ "name": "last_status_decision_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "work_mode": {+ "name": "work_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'standard'"+ },+ "harness_kind": {+ "name": "harness_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "priority": {+ "name": "priority",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'medium'"+ },+ "review_policy": {+ "name": "review_policy",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "assignee_agent_id": {+ "name": "assignee_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "assignee_user_id": {+ "name": "assignee_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "checkout_run_id": {+ "name": "checkout_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "execution_run_id": {+ "name": "execution_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "execution_agent_name_key": {+ "name": "execution_agent_name_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "execution_locked_at": {+ "name": "execution_locked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "responsible_user_id": {+ "name": "responsible_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "issue_number": {+ "name": "issue_number",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "origin_kind": {+ "name": "origin_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'manual'"+ },+ "origin_id": {+ "name": "origin_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "origin_run_id": {+ "name": "origin_run_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "origin_identity_context_id": {+ "name": "origin_identity_context_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "continuation_identity_context_id": {+ "name": "continuation_identity_context_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "origin_fingerprint": {+ "name": "origin_fingerprint",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'default'"+ },+ "request_depth": {+ "name": "request_depth",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "billing_code": {+ "name": "billing_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "assignee_adapter_overrides": {+ "name": "assignee_adapter_overrides",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "execution_policy": {+ "name": "execution_policy",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "execution_state": {+ "name": "execution_state",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "monitor_next_check_at": {+ "name": "monitor_next_check_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "monitor_wake_requested_at": {+ "name": "monitor_wake_requested_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "monitor_last_triggered_at": {+ "name": "monitor_last_triggered_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "monitor_attempt_count": {+ "name": "monitor_attempt_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "monitor_notes": {+ "name": "monitor_notes",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "monitor_scheduled_by": {+ "name": "monitor_scheduled_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "execution_workspace_id": {+ "name": "execution_workspace_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "execution_workspace_preference": {+ "name": "execution_workspace_preference",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "execution_workspace_settings": {+ "name": "execution_workspace_settings",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "source_trust": {+ "name": "source_trust",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "unblock_descriptor": {+ "name": "unblock_descriptor",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "blocked_transition_at": {+ "name": "blocked_transition_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "blocked_owner_notified_at": {+ "name": "blocked_owner_notified_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "cancelled_at": {+ "name": "cancelled_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "hidden_at": {+ "name": "hidden_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issues_conversation_identity_idx": {+ "name": "issues_conversation_identity_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "conversation_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "conversation_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_company_status_idx": {+ "name": "issues_company_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_company_harness_kind_idx": {+ "name": "issues_company_harness_kind_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "harness_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_company_assignee_status_idx": {+ "name": "issues_company_assignee_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "assignee_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_company_assignee_user_status_idx": {+ "name": "issues_company_assignee_user_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "assignee_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_company_responsible_user_idx": {+ "name": "issues_company_responsible_user_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "responsible_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_company_parent_idx": {+ "name": "issues_company_parent_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "parent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_company_project_idx": {+ "name": "issues_company_project_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_company_origin_idx": {+ "name": "issues_company_origin_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "origin_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "origin_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_company_project_workspace_idx": {+ "name": "issues_company_project_workspace_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "project_workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_company_execution_workspace_idx": {+ "name": "issues_company_execution_workspace_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "execution_workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_company_monitor_due_idx": {+ "name": "issues_company_monitor_due_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "monitor_next_check_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_company_updated_idx": {+ "name": "issues_company_updated_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_company_created_idx": {+ "name": "issues_company_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_open_normalized_title_created_idx": {+ "name": "issues_open_normalized_title_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "parent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "lower(regexp_replace(btrim(\"title\"), '\\s+', ' ', 'g'))",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"issues\".\"hidden_at\" is null and \"issues\".\"status\" not in ('done', 'cancelled')",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_company_priority_idx": {+ "name": "issues_company_priority_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "priority",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_identifier_idx": {+ "name": "issues_identifier_idx",+ "columns": [+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_title_search_idx": {+ "name": "issues_title_search_idx",+ "columns": [+ {+ "expression": "title",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "gin_trgm_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "gin",+ "with": {}+ },+ "issues_identifier_search_idx": {+ "name": "issues_identifier_search_idx",+ "columns": [+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "gin_trgm_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "gin",+ "with": {}+ },+ "issues_description_search_idx": {+ "name": "issues_description_search_idx",+ "columns": [+ {+ "expression": "description",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "gin_trgm_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "gin",+ "with": {}+ },+ "issues_open_routine_execution_uq": {+ "name": "issues_open_routine_execution_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "origin_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "origin_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "origin_fingerprint",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"issues\".\"origin_kind\" = 'routine_execution'\n and \"issues\".\"origin_id\" is not null\n and \"issues\".\"hidden_at\" is null\n and \"issues\".\"execution_run_id\" is not null\n and \"issues\".\"status\" in ('backlog', 'todo', 'in_progress', 'in_review', 'blocked')",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_active_liveness_recovery_incident_uq": {+ "name": "issues_active_liveness_recovery_incident_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "origin_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "origin_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"issues\".\"origin_kind\" = 'harness_liveness_escalation'\n and \"issues\".\"origin_id\" is not null\n and \"issues\".\"hidden_at\" is null\n and \"issues\".\"status\" not in ('done', 'cancelled')",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_active_liveness_recovery_leaf_uq": {+ "name": "issues_active_liveness_recovery_leaf_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "origin_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "origin_fingerprint",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"issues\".\"origin_kind\" = 'harness_liveness_escalation'\n and \"issues\".\"origin_fingerprint\" <> 'default'\n and \"issues\".\"hidden_at\" is null\n and \"issues\".\"status\" not in ('done', 'cancelled')",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_active_stale_run_evaluation_uq": {+ "name": "issues_active_stale_run_evaluation_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "origin_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "origin_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"issues\".\"origin_kind\" = 'stale_active_run_evaluation'\n and \"issues\".\"origin_id\" is not null\n and \"issues\".\"hidden_at\" is null\n and \"issues\".\"status\" not in ('done', 'cancelled')",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_active_task_watchdog_uq": {+ "name": "issues_active_task_watchdog_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "origin_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "origin_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"issues\".\"origin_kind\" = 'task_watchdog'\n and \"issues\".\"origin_id\" is not null\n and \"issues\".\"hidden_at\" is null\n and \"issues\".\"status\" not in ('done', 'cancelled')",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_active_productivity_review_uq": {+ "name": "issues_active_productivity_review_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "origin_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "origin_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"issues\".\"origin_kind\" = 'issue_productivity_review'\n and \"issues\".\"origin_id\" is not null\n and \"issues\".\"hidden_at\" is null\n and \"issues\".\"status\" not in ('done', 'cancelled')",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_active_stranded_issue_recovery_uq": {+ "name": "issues_active_stranded_issue_recovery_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "origin_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "origin_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"issues\".\"origin_kind\" = 'stranded_issue_recovery'\n and \"issues\".\"origin_id\" is not null\n and \"issues\".\"hidden_at\" is null\n and \"issues\".\"status\" not in ('done', 'cancelled')",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_onboarding_first_task_uq": {+ "name": "issues_onboarding_first_task_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"issues\".\"origin_kind\" = 'onboarding_first_task'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issues_company_id_companies_id_fk": {+ "name": "issues_company_id_companies_id_fk",+ "tableFrom": "issues",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issues_conversation_agent_id_agents_id_fk": {+ "name": "issues_conversation_agent_id_agents_id_fk",+ "tableFrom": "issues",+ "tableTo": "agents",+ "columnsFrom": [+ "conversation_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issues_project_id_projects_id_fk": {+ "name": "issues_project_id_projects_id_fk",+ "tableFrom": "issues",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issues_project_workspace_id_project_workspaces_id_fk": {+ "name": "issues_project_workspace_id_project_workspaces_id_fk",+ "tableFrom": "issues",+ "tableTo": "project_workspaces",+ "columnsFrom": [+ "project_workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issues_goal_id_goals_id_fk": {+ "name": "issues_goal_id_goals_id_fk",+ "tableFrom": "issues",+ "tableTo": "goals",+ "columnsFrom": [+ "goal_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issues_parent_id_issues_id_fk": {+ "name": "issues_parent_id_issues_id_fk",+ "tableFrom": "issues",+ "tableTo": "issues",+ "columnsFrom": [+ "parent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issues_assignee_agent_id_agents_id_fk": {+ "name": "issues_assignee_agent_id_agents_id_fk",+ "tableFrom": "issues",+ "tableTo": "agents",+ "columnsFrom": [+ "assignee_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issues_checkout_run_id_heartbeat_runs_id_fk": {+ "name": "issues_checkout_run_id_heartbeat_runs_id_fk",+ "tableFrom": "issues",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "checkout_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issues_execution_run_id_heartbeat_runs_id_fk": {+ "name": "issues_execution_run_id_heartbeat_runs_id_fk",+ "tableFrom": "issues",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "execution_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issues_created_by_agent_id_agents_id_fk": {+ "name": "issues_created_by_agent_id_agents_id_fk",+ "tableFrom": "issues",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issues_execution_workspace_id_execution_workspaces_id_fk": {+ "name": "issues_execution_workspace_id_execution_workspaces_id_fk",+ "tableFrom": "issues",+ "tableTo": "execution_workspaces",+ "columnsFrom": [+ "execution_workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issues_company_id_uq": {+ "name": "issues_company_id_uq",+ "nullsNotDistinct": false,+ "columns": [+ "company_id",+ "id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "issues_conversation_identity_check": {+ "name": "issues_conversation_identity_check",+ "value": "(\n \"issues\".\"conversation_agent_id\" is null and \"issues\".\"conversation_user_id\" is null and \"issues\".\"conversation_state\" is null\n ) or (\n \"issues\".\"conversation_agent_id\" is not null and \"issues\".\"conversation_user_id\" is not null\n and \"issues\".\"assignee_agent_id\" = \"issues\".\"conversation_agent_id\" and \"issues\".\"assignee_agent_id\" is not null\n and \"issues\".\"assignee_user_id\" is null and \"issues\".\"conversation_state\" is not null\n and \"issues\".\"conversation_state\" in ('active', 'waiting')\n and \"issues\".\"status\" not in ('done', 'cancelled')\n )"+ }+ },+ "isRLSEnabled": false+ },+ "public.join_requests": {+ "name": "join_requests",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "invite_id": {+ "name": "invite_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "request_type": {+ "name": "request_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending_approval'"+ },+ "request_ip": {+ "name": "request_ip",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "requesting_user_id": {+ "name": "requesting_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "request_email_snapshot": {+ "name": "request_email_snapshot",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_name": {+ "name": "agent_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "adapter_type": {+ "name": "adapter_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "capabilities": {+ "name": "capabilities",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_defaults_payload": {+ "name": "agent_defaults_payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "claim_secret_hash": {+ "name": "claim_secret_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "claim_secret_expires_at": {+ "name": "claim_secret_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "claim_secret_consumed_at": {+ "name": "claim_secret_consumed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_agent_id": {+ "name": "created_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "approved_by_user_id": {+ "name": "approved_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "approved_at": {+ "name": "approved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "rejected_by_user_id": {+ "name": "rejected_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "rejected_at": {+ "name": "rejected_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "join_requests_invite_unique_idx": {+ "name": "join_requests_invite_unique_idx",+ "columns": [+ {+ "expression": "invite_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "join_requests_company_status_type_created_idx": {+ "name": "join_requests_company_status_type_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "request_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "join_requests_pending_human_user_uq": {+ "name": "join_requests_pending_human_user_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "requesting_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"join_requests\".\"request_type\" = 'human' AND \"join_requests\".\"status\" = 'pending_approval' AND \"join_requests\".\"requesting_user_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "join_requests_pending_human_email_uq": {+ "name": "join_requests_pending_human_email_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "lower(\"request_email_snapshot\")",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"join_requests\".\"request_type\" = 'human' AND \"join_requests\".\"status\" = 'pending_approval' AND \"join_requests\".\"request_email_snapshot\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "join_requests_invite_id_invites_id_fk": {+ "name": "join_requests_invite_id_invites_id_fk",+ "tableFrom": "join_requests",+ "tableTo": "invites",+ "columnsFrom": [+ "invite_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "join_requests_company_id_companies_id_fk": {+ "name": "join_requests_company_id_companies_id_fk",+ "tableFrom": "join_requests",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "join_requests_created_agent_id_agents_id_fk": {+ "name": "join_requests_created_agent_id_agents_id_fk",+ "tableFrom": "join_requests",+ "tableTo": "agents",+ "columnsFrom": [+ "created_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.labels": {+ "name": "labels",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "labels_company_idx": {+ "name": "labels_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "labels_company_name_idx": {+ "name": "labels_company_name_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "labels_company_id_companies_id_fk": {+ "name": "labels_company_id_companies_id_fk",+ "tableFrom": "labels",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.managed_agent_profiles": {+ "name": "managed_agent_profiles",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "profile_key": {+ "name": "profile_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "display_name": {+ "name": "display_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "service": {+ "name": "service",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'anthropic_managed_agents'"+ },+ "anthropic_agent_id": {+ "name": "anthropic_agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_version": {+ "name": "agent_version",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "environment_id": {+ "name": "environment_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "beta_version": {+ "name": "beta_version",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'managed-agents-2026-04-01'"+ },+ "default_model": {+ "name": "default_model",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'claude-sonnet-5'"+ },+ "default_max_list_cost_cents": {+ "name": "default_max_list_cost_cents",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 100+ },+ "api_key_secret_id": {+ "name": "api_key_secret_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "retention_acknowledged": {+ "name": "retention_acknowledged",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "qualification": {+ "name": "qualification",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "qualified_at": {+ "name": "qualified_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "qualified_revision": {+ "name": "qualified_revision",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "managed_agent_profiles_company_idx": {+ "name": "managed_agent_profiles_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "managed_agent_profiles_company_key_uq": {+ "name": "managed_agent_profiles_company_key_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "profile_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "managed_agent_profiles_company_resource_uq": {+ "name": "managed_agent_profiles_company_resource_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "anthropic_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_version",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "environment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "managed_agent_profiles_company_id_companies_id_fk": {+ "name": "managed_agent_profiles_company_id_companies_id_fk",+ "tableFrom": "managed_agent_profiles",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "managed_agent_profiles_api_key_secret_id_company_secrets_id_fk": {+ "name": "managed_agent_profiles_api_key_secret_id_company_secrets_id_fk",+ "tableFrom": "managed_agent_profiles",+ "tableTo": "company_secrets",+ "columnsFrom": [+ "api_key_secret_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "restrict",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "managed_agent_profiles_service_check": {+ "name": "managed_agent_profiles_service_check",+ "value": "\"managed_agent_profiles\".\"service\" = 'anthropic_managed_agents'"+ },+ "managed_agent_profiles_beta_check": {+ "name": "managed_agent_profiles_beta_check",+ "value": "\"managed_agent_profiles\".\"beta_version\" = 'managed-agents-2026-04-01'"+ },+ "managed_agent_profiles_positive_budget_check": {+ "name": "managed_agent_profiles_positive_budget_check",+ "value": "\"managed_agent_profiles\".\"default_max_list_cost_cents\" > 0"+ },+ "managed_agent_profiles_qualified_revision_check": {+ "name": "managed_agent_profiles_qualified_revision_check",+ "value": "(\"managed_agent_profiles\".\"qualified_at\" IS NULL AND \"managed_agent_profiles\".\"qualified_revision\" IS NULL) OR (\"managed_agent_profiles\".\"qualified_at\" IS NOT NULL AND \"managed_agent_profiles\".\"qualification\" <> '{}'::jsonb AND \"managed_agent_profiles\".\"qualified_revision\" ~ '^sha256:[0-9a-f]{64}$')"+ }+ },+ "isRLSEnabled": false+ },+ "public.native_run_finalizations": {+ "name": "native_run_finalizations",+ "schema": "",+ "columns": {+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "phase": {+ "name": "phase",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "attempt": {+ "name": "attempt",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "lease_owner": {+ "name": "lease_owner",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "lease_expires_at": {+ "name": "lease_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "controller_boot_id": {+ "name": "controller_boot_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "controller_pid": {+ "name": "controller_pid",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "controller_process_started_at": {+ "name": "controller_process_started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "controller_generation": {+ "name": "controller_generation",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "recovery_state": {+ "name": "recovery_state",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "recovery_request_id": {+ "name": "recovery_request_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "recovery_history": {+ "name": "recovery_history",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "result_id": {+ "name": "result_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "assessment_id": {+ "name": "assessment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "decision_id": {+ "name": "decision_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "failure_code": {+ "name": "failure_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "failure_detail": {+ "name": "failure_detail",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "control_deadline_at": {+ "name": "control_deadline_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "native_run_finalizations_control_deadline_idx": {+ "name": "native_run_finalizations_control_deadline_idx",+ "columns": [+ {+ "expression": "control_deadline_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"native_run_finalizations\".\"control_deadline_at\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "native_run_finalizations_company_id_companies_id_fk": {+ "name": "native_run_finalizations_company_id_companies_id_fk",+ "tableFrom": "native_run_finalizations",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "native_run_finalizations_issue_company_fk": {+ "name": "native_run_finalizations_issue_company_fk",+ "tableFrom": "native_run_finalizations",+ "tableTo": "issues",+ "columnsFrom": [+ "company_id",+ "issue_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "native_run_finalizations_run_owner_fk": {+ "name": "native_run_finalizations_run_owner_fk",+ "tableFrom": "native_run_finalizations",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "company_id",+ "issue_id",+ "run_id"+ ],+ "columnsTo": [+ "company_id",+ "native_issue_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "native_run_finalizations_result_owner_fk": {+ "name": "native_run_finalizations_result_owner_fk",+ "tableFrom": "native_run_finalizations",+ "tableTo": "native_run_results",+ "columnsFrom": [+ "company_id",+ "issue_id",+ "run_id",+ "result_id"+ ],+ "columnsTo": [+ "company_id",+ "issue_id",+ "run_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "native_run_finalizations_assessment_owner_fk": {+ "name": "native_run_finalizations_assessment_owner_fk",+ "tableFrom": "native_run_finalizations",+ "tableTo": "work_assessments",+ "columnsFrom": [+ "company_id",+ "issue_id",+ "run_id",+ "assessment_id"+ ],+ "columnsTo": [+ "company_id",+ "issue_id",+ "run_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "native_run_finalizations_decision_owner_fk": {+ "name": "native_run_finalizations_decision_owner_fk",+ "tableFrom": "native_run_finalizations",+ "tableTo": "status_decisions",+ "columnsFrom": [+ "company_id",+ "issue_id",+ "run_id",+ "assessment_id",+ "decision_id"+ ],+ "columnsTo": [+ "company_id",+ "issue_id",+ "run_id",+ "assessment_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "native_run_finalizations_assessment_requires_result_check": {+ "name": "native_run_finalizations_assessment_requires_result_check",+ "value": "\"native_run_finalizations\".\"assessment_id\" is null or \"native_run_finalizations\".\"result_id\" is not null"+ },+ "native_run_finalizations_decision_requires_assessment_check": {+ "name": "native_run_finalizations_decision_requires_assessment_check",+ "value": "\"native_run_finalizations\".\"decision_id\" is null or \"native_run_finalizations\".\"assessment_id\" is not null"+ }+ },+ "isRLSEnabled": false+ },+ "public.native_run_results": {+ "name": "native_run_results",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "turn_id": {+ "name": "turn_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "completion_contract_id": {+ "name": "completion_contract_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "caller_result_id": {+ "name": "caller_result_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "caller_dedupe_key": {+ "name": "caller_dedupe_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "server_fingerprint": {+ "name": "server_fingerprint",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "schema_status": {+ "name": "schema_status",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "rejection_code": {+ "name": "rejection_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "result_json": {+ "name": "result_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "canonical_sha256": {+ "name": "canonical_sha256",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "native_run_results_run_fingerprint_uq": {+ "name": "native_run_results_run_fingerprint_uq",+ "columns": [+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "server_fingerprint",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "native_run_results_run_caller_result_uq": {+ "name": "native_run_results_run_caller_result_uq",+ "columns": [+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "caller_result_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "native_run_results_run_caller_dedupe_uq": {+ "name": "native_run_results_run_caller_dedupe_uq",+ "columns": [+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "caller_dedupe_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "native_run_results_company_id_companies_id_fk": {+ "name": "native_run_results_company_id_companies_id_fk",+ "tableFrom": "native_run_results",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "native_run_results_issue_company_fk": {+ "name": "native_run_results_issue_company_fk",+ "tableFrom": "native_run_results",+ "tableTo": "issues",+ "columnsFrom": [+ "company_id",+ "issue_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "native_run_results_run_contract_owner_fk": {+ "name": "native_run_results_run_contract_owner_fk",+ "tableFrom": "native_run_results",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "company_id",+ "issue_id",+ "run_id",+ "completion_contract_id"+ ],+ "columnsTo": [+ "company_id",+ "native_issue_id",+ "id",+ "completion_contract_id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "native_run_results_completion_contract_owner_fk": {+ "name": "native_run_results_completion_contract_owner_fk",+ "tableFrom": "native_run_results",+ "tableTo": "completion_contracts",+ "columnsFrom": [+ "company_id",+ "issue_id",+ "completion_contract_id"+ ],+ "columnsTo": [+ "company_id",+ "issue_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "native_run_results_company_issue_run_id_uq": {+ "name": "native_run_results_company_issue_run_id_uq",+ "nullsNotDistinct": false,+ "columns": [+ "company_id",+ "issue_id",+ "run_id",+ "id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.pipeline_automation_executions": {+ "name": "pipeline_automation_executions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "case_id": {+ "name": "case_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "automation_id": {+ "name": "automation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "triggering_event_id": {+ "name": "triggering_event_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "routine_id": {+ "name": "routine_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "execution_issue_id": {+ "name": "execution_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "retry_of_execution_id": {+ "name": "retry_of_execution_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "generation": {+ "name": "generation",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "error": {+ "name": "error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "pipeline_automation_executions_idempotency_uq": {+ "name": "pipeline_automation_executions_idempotency_uq",+ "columns": [+ {+ "expression": "case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "automation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "triggering_event_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_automation_executions_company_case_idx": {+ "name": "pipeline_automation_executions_company_case_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_automation_executions_routine_idx": {+ "name": "pipeline_automation_executions_routine_idx",+ "columns": [+ {+ "expression": "routine_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_automation_executions_execution_issue_idx": {+ "name": "pipeline_automation_executions_execution_issue_idx",+ "columns": [+ {+ "expression": "execution_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_automation_executions_retry_of_execution_idx": {+ "name": "pipeline_automation_executions_retry_of_execution_idx",+ "columns": [+ {+ "expression": "retry_of_execution_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "pipeline_automation_executions_company_id_companies_id_fk": {+ "name": "pipeline_automation_executions_company_id_companies_id_fk",+ "tableFrom": "pipeline_automation_executions",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "pipeline_automation_executions_case_id_pipeline_cases_id_fk": {+ "name": "pipeline_automation_executions_case_id_pipeline_cases_id_fk",+ "tableFrom": "pipeline_automation_executions",+ "tableTo": "pipeline_cases",+ "columnsFrom": [+ "case_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "pipeline_automation_executions_routine_id_routines_id_fk": {+ "name": "pipeline_automation_executions_routine_id_routines_id_fk",+ "tableFrom": "pipeline_automation_executions",+ "tableTo": "routines",+ "columnsFrom": [+ "routine_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "pipeline_automation_executions_execution_issue_id_issues_id_fk": {+ "name": "pipeline_automation_executions_execution_issue_id_issues_id_fk",+ "tableFrom": "pipeline_automation_executions",+ "tableTo": "issues",+ "columnsFrom": [+ "execution_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "pipeline_automation_executions_status_check": {+ "name": "pipeline_automation_executions_status_check",+ "value": "\"pipeline_automation_executions\".\"status\" in ('succeeded', 'failed')"+ }+ },+ "isRLSEnabled": false+ },+ "public.pipeline_case_blockers": {+ "name": "pipeline_case_blockers",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "case_id": {+ "name": "case_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "blocked_by_case_id": {+ "name": "blocked_by_case_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "pipeline_case_blockers_case_blocked_by_uq": {+ "name": "pipeline_case_blockers_case_blocked_by_uq",+ "columns": [+ {+ "expression": "case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "blocked_by_case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_case_blockers_blocked_by_idx": {+ "name": "pipeline_case_blockers_blocked_by_idx",+ "columns": [+ {+ "expression": "blocked_by_case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_case_blockers_company_case_idx": {+ "name": "pipeline_case_blockers_company_case_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "pipeline_case_blockers_company_id_companies_id_fk": {+ "name": "pipeline_case_blockers_company_id_companies_id_fk",+ "tableFrom": "pipeline_case_blockers",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "pipeline_case_blockers_case_id_pipeline_cases_id_fk": {+ "name": "pipeline_case_blockers_case_id_pipeline_cases_id_fk",+ "tableFrom": "pipeline_case_blockers",+ "tableTo": "pipeline_cases",+ "columnsFrom": [+ "case_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "pipeline_case_blockers_blocked_by_case_id_pipeline_cases_id_fk": {+ "name": "pipeline_case_blockers_blocked_by_case_id_pipeline_cases_id_fk",+ "tableFrom": "pipeline_case_blockers",+ "tableTo": "pipeline_cases",+ "columnsFrom": [+ "blocked_by_case_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "pipeline_case_blockers_no_self_block_check": {+ "name": "pipeline_case_blockers_no_self_block_check",+ "value": "\"pipeline_case_blockers\".\"case_id\" <> \"pipeline_case_blockers\".\"blocked_by_case_id\""+ }+ },+ "isRLSEnabled": false+ },+ "public.pipeline_case_documents": {+ "name": "pipeline_case_documents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "case_id": {+ "name": "case_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "document_id": {+ "name": "document_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "pipeline_case_documents_company_case_key_uq": {+ "name": "pipeline_case_documents_company_case_key_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_case_documents_document_uq": {+ "name": "pipeline_case_documents_document_uq",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_case_documents_company_case_updated_idx": {+ "name": "pipeline_case_documents_company_case_updated_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "pipeline_case_documents_company_id_companies_id_fk": {+ "name": "pipeline_case_documents_company_id_companies_id_fk",+ "tableFrom": "pipeline_case_documents",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "pipeline_case_documents_case_id_pipeline_cases_id_fk": {+ "name": "pipeline_case_documents_case_id_pipeline_cases_id_fk",+ "tableFrom": "pipeline_case_documents",+ "tableTo": "pipeline_cases",+ "columnsFrom": [+ "case_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "pipeline_case_documents_document_id_documents_id_fk": {+ "name": "pipeline_case_documents_document_id_documents_id_fk",+ "tableFrom": "pipeline_case_documents",+ "tableTo": "documents",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.pipeline_case_events": {+ "name": "pipeline_case_events",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "case_id": {+ "name": "case_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "actor_type": {+ "name": "actor_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "actor_user_id": {+ "name": "actor_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "actor_agent_id": {+ "name": "actor_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "from_stage_id": {+ "name": "from_stage_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "to_stage_id": {+ "name": "to_stage_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "pipeline_case_events_case_created_idx": {+ "name": "pipeline_case_events_case_created_idx",+ "columns": [+ {+ "expression": "case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_case_events_company_case_idx": {+ "name": "pipeline_case_events_company_case_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "pipeline_case_events_company_id_companies_id_fk": {+ "name": "pipeline_case_events_company_id_companies_id_fk",+ "tableFrom": "pipeline_case_events",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "pipeline_case_events_case_id_pipeline_cases_id_fk": {+ "name": "pipeline_case_events_case_id_pipeline_cases_id_fk",+ "tableFrom": "pipeline_case_events",+ "tableTo": "pipeline_cases",+ "columnsFrom": [+ "case_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "pipeline_case_events_actor_agent_id_agents_id_fk": {+ "name": "pipeline_case_events_actor_agent_id_agents_id_fk",+ "tableFrom": "pipeline_case_events",+ "tableTo": "agents",+ "columnsFrom": [+ "actor_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "pipeline_case_events_from_stage_id_pipeline_stages_id_fk": {+ "name": "pipeline_case_events_from_stage_id_pipeline_stages_id_fk",+ "tableFrom": "pipeline_case_events",+ "tableTo": "pipeline_stages",+ "columnsFrom": [+ "from_stage_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "pipeline_case_events_to_stage_id_pipeline_stages_id_fk": {+ "name": "pipeline_case_events_to_stage_id_pipeline_stages_id_fk",+ "tableFrom": "pipeline_case_events",+ "tableTo": "pipeline_stages",+ "columnsFrom": [+ "to_stage_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "pipeline_case_events_type_check": {+ "name": "pipeline_case_events_type_check",+ "value": "\"pipeline_case_events\".\"type\" in (\n 'ingested',\n 'updated',\n 'claimed',\n 'lease_released',\n 'lease_expired',\n 'transitioned',\n 'transition_forced',\n 'transition_suggested',\n 'suggestion_resolved',\n 'review_decided',\n 'conversation_opened',\n 'issue_linked',\n 'issue_unlinked',\n 'automation_executed',\n 'automation_failed',\n 'automation_retry_requested',\n 'automation_effects_retired',\n 'automation_retry_dispatched',\n 'blockers_set',\n 'blockers_resolved',\n 'children_terminal',\n 'upstream_drift',\n 'drift_acknowledged'\n )"+ },+ "pipeline_case_events_actor_type_check": {+ "name": "pipeline_case_events_actor_type_check",+ "value": "\"pipeline_case_events\".\"actor_type\" in ('user', 'agent', 'system')"+ },+ "pipeline_case_events_agent_run_check": {+ "name": "pipeline_case_events_agent_run_check",+ "value": "\"pipeline_case_events\".\"actor_type\" <> 'agent' or \"pipeline_case_events\".\"run_id\" is not null"+ }+ },+ "isRLSEnabled": false+ },+ "public.pipeline_case_issue_links": {+ "name": "pipeline_case_issue_links",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "case_id": {+ "name": "case_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_run_id": {+ "name": "created_by_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "automation_attempt_id": {+ "name": "automation_attempt_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "retired_at": {+ "name": "retired_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "retired_by_attempt_id": {+ "name": "retired_by_attempt_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "retired_reason": {+ "name": "retired_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "pipeline_case_issue_links_case_issue_uq": {+ "name": "pipeline_case_issue_links_case_issue_uq",+ "columns": [+ {+ "expression": "case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_case_issue_links_issue_idx": {+ "name": "pipeline_case_issue_links_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_case_issue_links_company_case_idx": {+ "name": "pipeline_case_issue_links_company_case_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_case_issue_links_automation_attempt_idx": {+ "name": "pipeline_case_issue_links_automation_attempt_idx",+ "columns": [+ {+ "expression": "automation_attempt_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "pipeline_case_issue_links_company_id_companies_id_fk": {+ "name": "pipeline_case_issue_links_company_id_companies_id_fk",+ "tableFrom": "pipeline_case_issue_links",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "pipeline_case_issue_links_case_id_pipeline_cases_id_fk": {+ "name": "pipeline_case_issue_links_case_id_pipeline_cases_id_fk",+ "tableFrom": "pipeline_case_issue_links",+ "tableTo": "pipeline_cases",+ "columnsFrom": [+ "case_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "pipeline_case_issue_links_issue_id_issues_id_fk": {+ "name": "pipeline_case_issue_links_issue_id_issues_id_fk",+ "tableFrom": "pipeline_case_issue_links",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "pipeline_case_issue_links_role_check": {+ "name": "pipeline_case_issue_links_role_check",+ "value": "\"pipeline_case_issue_links\".\"role\" in ('origin', 'conversation', 'work', 'automation')"+ }+ },+ "isRLSEnabled": false+ },+ "public.pipeline_cases": {+ "name": "pipeline_cases",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "pipeline_id": {+ "name": "pipeline_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "stage_id": {+ "name": "stage_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "case_key": {+ "name": "case_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "summary": {+ "name": "summary",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "fields": {+ "name": "fields",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "workspace_ref": {+ "name": "workspace_ref",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "parent_case_id": {+ "name": "parent_case_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "parent_case_version": {+ "name": "parent_case_version",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "request_key": {+ "name": "request_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "automation_attempt_id": {+ "name": "automation_attempt_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "pending_suggestion": {+ "name": "pending_suggestion",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "lease_owner_type": {+ "name": "lease_owner_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "lease_agent_id": {+ "name": "lease_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "lease_user_id": {+ "name": "lease_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "lease_token": {+ "name": "lease_token",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "lease_expires_at": {+ "name": "lease_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "terminal_kind": {+ "name": "terminal_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "terminal_at": {+ "name": "terminal_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "retired_at": {+ "name": "retired_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "retired_by_attempt_id": {+ "name": "retired_by_attempt_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "retired_reason": {+ "name": "retired_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "hidden_from_board_at": {+ "name": "hidden_from_board_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "child_count": {+ "name": "child_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "terminal_child_count": {+ "name": "terminal_child_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "origin_run_id": {+ "name": "origin_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "pipeline_cases_pipeline_case_key_uq": {+ "name": "pipeline_cases_pipeline_case_key_uq",+ "columns": [+ {+ "expression": "pipeline_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "case_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_cases_parent_request_key_uq": {+ "name": "pipeline_cases_parent_request_key_uq",+ "columns": [+ {+ "expression": "parent_case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "request_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"pipeline_cases\".\"request_key\" is not null and \"pipeline_cases\".\"retired_at\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_cases_company_idx": {+ "name": "pipeline_cases_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_cases_pipeline_stage_idx": {+ "name": "pipeline_cases_pipeline_stage_idx",+ "columns": [+ {+ "expression": "pipeline_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "stage_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_cases_parent_idx": {+ "name": "pipeline_cases_parent_idx",+ "columns": [+ {+ "expression": "parent_case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_cases_automation_attempt_idx": {+ "name": "pipeline_cases_automation_attempt_idx",+ "columns": [+ {+ "expression": "automation_attempt_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_cases_retired_idx": {+ "name": "pipeline_cases_retired_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "retired_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_cases_lease_expires_idx": {+ "name": "pipeline_cases_lease_expires_idx",+ "columns": [+ {+ "expression": "lease_expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"pipeline_cases\".\"lease_expires_at\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "pipeline_cases_company_id_companies_id_fk": {+ "name": "pipeline_cases_company_id_companies_id_fk",+ "tableFrom": "pipeline_cases",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "pipeline_cases_pipeline_id_pipelines_id_fk": {+ "name": "pipeline_cases_pipeline_id_pipelines_id_fk",+ "tableFrom": "pipeline_cases",+ "tableTo": "pipelines",+ "columnsFrom": [+ "pipeline_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "pipeline_cases_stage_id_pipeline_stages_id_fk": {+ "name": "pipeline_cases_stage_id_pipeline_stages_id_fk",+ "tableFrom": "pipeline_cases",+ "tableTo": "pipeline_stages",+ "columnsFrom": [+ "stage_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "pipeline_cases_parent_case_id_pipeline_cases_id_fk": {+ "name": "pipeline_cases_parent_case_id_pipeline_cases_id_fk",+ "tableFrom": "pipeline_cases",+ "tableTo": "pipeline_cases",+ "columnsFrom": [+ "parent_case_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "pipeline_cases_lease_agent_id_agents_id_fk": {+ "name": "pipeline_cases_lease_agent_id_agents_id_fk",+ "tableFrom": "pipeline_cases",+ "tableTo": "agents",+ "columnsFrom": [+ "lease_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "pipeline_cases_created_by_agent_id_agents_id_fk": {+ "name": "pipeline_cases_created_by_agent_id_agents_id_fk",+ "tableFrom": "pipeline_cases",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "pipeline_cases_terminal_kind_check": {+ "name": "pipeline_cases_terminal_kind_check",+ "value": "\"pipeline_cases\".\"terminal_kind\" is null or \"pipeline_cases\".\"terminal_kind\" in ('done', 'cancelled')"+ },+ "pipeline_cases_lease_owner_type_check": {+ "name": "pipeline_cases_lease_owner_type_check",+ "value": "\"pipeline_cases\".\"lease_owner_type\" is null or \"pipeline_cases\".\"lease_owner_type\" in ('user', 'agent')"+ }+ },+ "isRLSEnabled": false+ },+ "public.pipeline_documents": {+ "name": "pipeline_documents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "pipeline_id": {+ "name": "pipeline_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "document_id": {+ "name": "document_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "pipeline_documents_company_pipeline_key_uq": {+ "name": "pipeline_documents_company_pipeline_key_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "pipeline_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_documents_document_uq": {+ "name": "pipeline_documents_document_uq",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_documents_company_pipeline_updated_idx": {+ "name": "pipeline_documents_company_pipeline_updated_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "pipeline_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "pipeline_documents_company_id_companies_id_fk": {+ "name": "pipeline_documents_company_id_companies_id_fk",+ "tableFrom": "pipeline_documents",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "pipeline_documents_pipeline_id_pipelines_id_fk": {+ "name": "pipeline_documents_pipeline_id_pipelines_id_fk",+ "tableFrom": "pipeline_documents",+ "tableTo": "pipelines",+ "columnsFrom": [+ "pipeline_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "pipeline_documents_document_id_documents_id_fk": {+ "name": "pipeline_documents_document_id_documents_id_fk",+ "tableFrom": "pipeline_documents",+ "tableTo": "documents",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.pipeline_stages": {+ "name": "pipeline_stages",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "pipeline_id": {+ "name": "pipeline_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "pipeline_stages_pipeline_key_uq": {+ "name": "pipeline_stages_pipeline_key_uq",+ "columns": [+ {+ "expression": "pipeline_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_stages_pipeline_position_idx": {+ "name": "pipeline_stages_pipeline_position_idx",+ "columns": [+ {+ "expression": "pipeline_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "pipeline_stages_pipeline_id_pipelines_id_fk": {+ "name": "pipeline_stages_pipeline_id_pipelines_id_fk",+ "tableFrom": "pipeline_stages",+ "tableTo": "pipelines",+ "columnsFrom": [+ "pipeline_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "pipeline_stages_kind_check": {+ "name": "pipeline_stages_kind_check",+ "value": "\"pipeline_stages\".\"kind\" in ('working', 'review', 'done', 'cancelled')"+ }+ },+ "isRLSEnabled": false+ },+ "public.pipeline_transitions": {+ "name": "pipeline_transitions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "pipeline_id": {+ "name": "pipeline_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "from_stage_id": {+ "name": "from_stage_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "to_stage_id": {+ "name": "to_stage_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "label": {+ "name": "label",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "pipeline_transitions_pipeline_edge_uq": {+ "name": "pipeline_transitions_pipeline_edge_uq",+ "columns": [+ {+ "expression": "pipeline_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "from_stage_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "to_stage_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_transitions_pipeline_from_idx": {+ "name": "pipeline_transitions_pipeline_from_idx",+ "columns": [+ {+ "expression": "pipeline_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "from_stage_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipeline_transitions_pipeline_to_idx": {+ "name": "pipeline_transitions_pipeline_to_idx",+ "columns": [+ {+ "expression": "pipeline_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "to_stage_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "pipeline_transitions_pipeline_id_pipelines_id_fk": {+ "name": "pipeline_transitions_pipeline_id_pipelines_id_fk",+ "tableFrom": "pipeline_transitions",+ "tableTo": "pipelines",+ "columnsFrom": [+ "pipeline_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "pipeline_transitions_from_stage_id_pipeline_stages_id_fk": {+ "name": "pipeline_transitions_from_stage_id_pipeline_stages_id_fk",+ "tableFrom": "pipeline_transitions",+ "tableTo": "pipeline_stages",+ "columnsFrom": [+ "from_stage_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "pipeline_transitions_to_stage_id_pipeline_stages_id_fk": {+ "name": "pipeline_transitions_to_stage_id_pipeline_stages_id_fk",+ "tableFrom": "pipeline_transitions",+ "tableTo": "pipeline_stages",+ "columnsFrom": [+ "to_stage_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.pipelines": {+ "name": "pipelines",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "enforce_transitions": {+ "name": "enforce_transitions",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "archived_at": {+ "name": "archived_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "pipelines_company_key_uq": {+ "name": "pipelines_company_key_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipelines_company_idx": {+ "name": "pipelines_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "pipelines_company_project_idx": {+ "name": "pipelines_company_project_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "pipelines_company_id_companies_id_fk": {+ "name": "pipelines_company_id_companies_id_fk",+ "tableFrom": "pipelines",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "pipelines_project_id_projects_id_fk": {+ "name": "pipelines_project_id_projects_id_fk",+ "tableFrom": "pipelines",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "pipelines_created_by_agent_id_agents_id_fk": {+ "name": "pipelines_created_by_agent_id_agents_id_fk",+ "tableFrom": "pipelines",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.plugin_company_settings": {+ "name": "plugin_company_settings",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "plugin_id": {+ "name": "plugin_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "settings_json": {+ "name": "settings_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "plugin_company_settings_company_idx": {+ "name": "plugin_company_settings_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "plugin_company_settings_plugin_idx": {+ "name": "plugin_company_settings_plugin_idx",+ "columns": [+ {+ "expression": "plugin_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "plugin_company_settings_company_plugin_uq": {+ "name": "plugin_company_settings_company_plugin_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "plugin_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "plugin_company_settings_company_id_companies_id_fk": {+ "name": "plugin_company_settings_company_id_companies_id_fk",+ "tableFrom": "plugin_company_settings",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "plugin_company_settings_plugin_id_plugins_id_fk": {+ "name": "plugin_company_settings_plugin_id_plugins_id_fk",+ "tableFrom": "plugin_company_settings",+ "tableTo": "plugins",+ "columnsFrom": [+ "plugin_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.plugin_config": {+ "name": "plugin_config",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "plugin_id": {+ "name": "plugin_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "config_json": {+ "name": "config_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "plugin_config_plugin_company_idx": {+ "name": "plugin_config_plugin_company_idx",+ "columns": [+ {+ "expression": "plugin_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "plugin_config_plugin_id_plugins_id_fk": {+ "name": "plugin_config_plugin_id_plugins_id_fk",+ "tableFrom": "plugin_config",+ "tableTo": "plugins",+ "columnsFrom": [+ "plugin_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "plugin_config_company_id_companies_id_fk": {+ "name": "plugin_config_company_id_companies_id_fk",+ "tableFrom": "plugin_config",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.plugin_database_namespaces": {+ "name": "plugin_database_namespaces",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "plugin_id": {+ "name": "plugin_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "plugin_key": {+ "name": "plugin_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "namespace_name": {+ "name": "namespace_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "namespace_mode": {+ "name": "namespace_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'schema'"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "plugin_database_namespaces_plugin_idx": {+ "name": "plugin_database_namespaces_plugin_idx",+ "columns": [+ {+ "expression": "plugin_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "plugin_database_namespaces_namespace_idx": {+ "name": "plugin_database_namespaces_namespace_idx",+ "columns": [+ {+ "expression": "namespace_name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "plugin_database_namespaces_status_idx": {+ "name": "plugin_database_namespaces_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "plugin_database_namespaces_plugin_id_plugins_id_fk": {+ "name": "plugin_database_namespaces_plugin_id_plugins_id_fk",+ "tableFrom": "plugin_database_namespaces",+ "tableTo": "plugins",+ "columnsFrom": [+ "plugin_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.plugin_entities": {+ "name": "plugin_entities",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "plugin_id": {+ "name": "plugin_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "entity_type": {+ "name": "entity_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope_kind": {+ "name": "scope_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope_id": {+ "name": "scope_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "external_id": {+ "name": "external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "data": {+ "name": "data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "plugin_entities_plugin_idx": {+ "name": "plugin_entities_plugin_idx",+ "columns": [+ {+ "expression": "plugin_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "plugin_entities_company_idx": {+ "name": "plugin_entities_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "plugin_entities_type_idx": {+ "name": "plugin_entities_type_idx",+ "columns": [+ {+ "expression": "entity_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "plugin_entities_scope_idx": {+ "name": "plugin_entities_scope_idx",+ "columns": [+ {+ "expression": "scope_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "scope_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "plugin_entities_plugin_id_plugins_id_fk": {+ "name": "plugin_entities_plugin_id_plugins_id_fk",+ "tableFrom": "plugin_entities",+ "tableTo": "plugins",+ "columnsFrom": [+ "plugin_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "plugin_entities_company_id_companies_id_fk": {+ "name": "plugin_entities_company_id_companies_id_fk",+ "tableFrom": "plugin_entities",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "plugin_entities_external_idx": {+ "name": "plugin_entities_external_idx",+ "nullsNotDistinct": true,+ "columns": [+ "company_id",+ "plugin_id",+ "entity_type",+ "external_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.plugin_job_runs": {+ "name": "plugin_job_runs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "job_id": {+ "name": "job_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "plugin_id": {+ "name": "plugin_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "trigger": {+ "name": "trigger",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "duration_ms": {+ "name": "duration_ms",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "error": {+ "name": "error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "logs": {+ "name": "logs",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "finished_at": {+ "name": "finished_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "plugin_job_runs_job_idx": {+ "name": "plugin_job_runs_job_idx",+ "columns": [+ {+ "expression": "job_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "plugin_job_runs_plugin_idx": {+ "name": "plugin_job_runs_plugin_idx",+ "columns": [+ {+ "expression": "plugin_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "plugin_job_runs_company_idx": {+ "name": "plugin_job_runs_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "plugin_job_runs_status_idx": {+ "name": "plugin_job_runs_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "plugin_job_runs_job_id_plugin_jobs_id_fk": {+ "name": "plugin_job_runs_job_id_plugin_jobs_id_fk",+ "tableFrom": "plugin_job_runs",+ "tableTo": "plugin_jobs",+ "columnsFrom": [+ "job_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "plugin_job_runs_plugin_id_plugins_id_fk": {+ "name": "plugin_job_runs_plugin_id_plugins_id_fk",+ "tableFrom": "plugin_job_runs",+ "tableTo": "plugins",+ "columnsFrom": [+ "plugin_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "plugin_job_runs_company_id_companies_id_fk": {+ "name": "plugin_job_runs_company_id_companies_id_fk",+ "tableFrom": "plugin_job_runs",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.plugin_jobs": {+ "name": "plugin_jobs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "plugin_id": {+ "name": "plugin_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "job_key": {+ "name": "job_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "schedule": {+ "name": "schedule",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "last_run_at": {+ "name": "last_run_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "next_run_at": {+ "name": "next_run_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "plugin_jobs_plugin_idx": {+ "name": "plugin_jobs_plugin_idx",+ "columns": [+ {+ "expression": "plugin_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "plugin_jobs_next_run_idx": {+ "name": "plugin_jobs_next_run_idx",+ "columns": [+ {+ "expression": "next_run_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "plugin_jobs_unique_idx": {+ "name": "plugin_jobs_unique_idx",+ "columns": [+ {+ "expression": "plugin_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "job_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "plugin_jobs_plugin_id_plugins_id_fk": {+ "name": "plugin_jobs_plugin_id_plugins_id_fk",+ "tableFrom": "plugin_jobs",+ "tableTo": "plugins",+ "columnsFrom": [+ "plugin_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.plugin_logs": {+ "name": "plugin_logs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "plugin_id": {+ "name": "plugin_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "level": {+ "name": "level",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'info'"+ },+ "message": {+ "name": "message",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "meta": {+ "name": "meta",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "plugin_logs_plugin_time_idx": {+ "name": "plugin_logs_plugin_time_idx",+ "columns": [+ {+ "expression": "plugin_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "plugin_logs_company_idx": {+ "name": "plugin_logs_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "plugin_logs_level_idx": {+ "name": "plugin_logs_level_idx",+ "columns": [+ {+ "expression": "level",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "plugin_logs_plugin_id_plugins_id_fk": {+ "name": "plugin_logs_plugin_id_plugins_id_fk",+ "tableFrom": "plugin_logs",+ "tableTo": "plugins",+ "columnsFrom": [+ "plugin_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "plugin_logs_company_id_companies_id_fk": {+ "name": "plugin_logs_company_id_companies_id_fk",+ "tableFrom": "plugin_logs",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.plugin_managed_resources": {+ "name": "plugin_managed_resources",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "plugin_id": {+ "name": "plugin_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "plugin_key": {+ "name": "plugin_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "resource_kind": {+ "name": "resource_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "resource_key": {+ "name": "resource_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "resource_id": {+ "name": "resource_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "defaults_json": {+ "name": "defaults_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "plugin_managed_resources_company_idx": {+ "name": "plugin_managed_resources_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "plugin_managed_resources_plugin_idx": {+ "name": "plugin_managed_resources_plugin_idx",+ "columns": [+ {+ "expression": "plugin_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "plugin_managed_resources_resource_idx": {+ "name": "plugin_managed_resources_resource_idx",+ "columns": [+ {+ "expression": "resource_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "plugin_managed_resources_company_plugin_resource_uq": {+ "name": "plugin_managed_resources_company_plugin_resource_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "plugin_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "plugin_managed_resources_company_id_companies_id_fk": {+ "name": "plugin_managed_resources_company_id_companies_id_fk",+ "tableFrom": "plugin_managed_resources",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "plugin_managed_resources_plugin_id_plugins_id_fk": {+ "name": "plugin_managed_resources_plugin_id_plugins_id_fk",+ "tableFrom": "plugin_managed_resources",+ "tableTo": "plugins",+ "columnsFrom": [+ "plugin_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.plugin_migrations": {+ "name": "plugin_migrations",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "plugin_id": {+ "name": "plugin_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "plugin_key": {+ "name": "plugin_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "namespace_name": {+ "name": "namespace_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "migration_key": {+ "name": "migration_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "checksum": {+ "name": "checksum",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "plugin_version": {+ "name": "plugin_version",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "applied_at": {+ "name": "applied_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "error_message": {+ "name": "error_message",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "plugin_migrations_plugin_key_idx": {+ "name": "plugin_migrations_plugin_key_idx",+ "columns": [+ {+ "expression": "plugin_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "migration_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "plugin_migrations_plugin_idx": {+ "name": "plugin_migrations_plugin_idx",+ "columns": [+ {+ "expression": "plugin_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "plugin_migrations_status_idx": {+ "name": "plugin_migrations_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "plugin_migrations_plugin_id_plugins_id_fk": {+ "name": "plugin_migrations_plugin_id_plugins_id_fk",+ "tableFrom": "plugin_migrations",+ "tableTo": "plugins",+ "columnsFrom": [+ "plugin_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.plugin_state": {+ "name": "plugin_state",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "plugin_id": {+ "name": "plugin_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "scope_kind": {+ "name": "scope_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope_id": {+ "name": "scope_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "namespace": {+ "name": "namespace",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'default'"+ },+ "state_key": {+ "name": "state_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "value_json": {+ "name": "value_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "plugin_state_plugin_scope_idx": {+ "name": "plugin_state_plugin_scope_idx",+ "columns": [+ {+ "expression": "plugin_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "scope_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "plugin_state_plugin_id_plugins_id_fk": {+ "name": "plugin_state_plugin_id_plugins_id_fk",+ "tableFrom": "plugin_state",+ "tableTo": "plugins",+ "columnsFrom": [+ "plugin_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "plugin_state_unique_entry_idx": {+ "name": "plugin_state_unique_entry_idx",+ "nullsNotDistinct": true,+ "columns": [+ "plugin_id",+ "scope_kind",+ "scope_id",+ "namespace",+ "state_key"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.plugin_webhook_deliveries": {+ "name": "plugin_webhook_deliveries",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "plugin_id": {+ "name": "plugin_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "webhook_key": {+ "name": "webhook_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "external_id": {+ "name": "external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "duration_ms": {+ "name": "duration_ms",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "error": {+ "name": "error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "headers": {+ "name": "headers",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "finished_at": {+ "name": "finished_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "plugin_webhook_deliveries_plugin_idx": {+ "name": "plugin_webhook_deliveries_plugin_idx",+ "columns": [+ {+ "expression": "plugin_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "plugin_webhook_deliveries_company_idx": {+ "name": "plugin_webhook_deliveries_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "plugin_webhook_deliveries_status_idx": {+ "name": "plugin_webhook_deliveries_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "plugin_webhook_deliveries_key_idx": {+ "name": "plugin_webhook_deliveries_key_idx",+ "columns": [+ {+ "expression": "webhook_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "plugin_webhook_deliveries_plugin_id_plugins_id_fk": {+ "name": "plugin_webhook_deliveries_plugin_id_plugins_id_fk",+ "tableFrom": "plugin_webhook_deliveries",+ "tableTo": "plugins",+ "columnsFrom": [+ "plugin_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "plugin_webhook_deliveries_company_id_companies_id_fk": {+ "name": "plugin_webhook_deliveries_company_id_companies_id_fk",+ "tableFrom": "plugin_webhook_deliveries",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.plugins": {+ "name": "plugins",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "plugin_key": {+ "name": "plugin_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "package_name": {+ "name": "package_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "version": {+ "name": "version",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "api_version": {+ "name": "api_version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "categories": {+ "name": "categories",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "manifest_json": {+ "name": "manifest_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'installed'"+ },+ "install_order": {+ "name": "install_order",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "package_path": {+ "name": "package_path",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "installed_at": {+ "name": "installed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "plugins_plugin_key_idx": {+ "name": "plugins_plugin_key_idx",+ "columns": [+ {+ "expression": "plugin_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "plugins_status_idx": {+ "name": "plugins_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.principal_permission_grants": {+ "name": "principal_permission_grants",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "principal_type": {+ "name": "principal_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "principal_id": {+ "name": "principal_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "permission_key": {+ "name": "permission_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope": {+ "name": "scope",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "granted_by_user_id": {+ "name": "granted_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "principal_permission_grants_unique_idx": {+ "name": "principal_permission_grants_unique_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "principal_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "principal_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "permission_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "principal_permission_grants_company_permission_idx": {+ "name": "principal_permission_grants_company_permission_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "permission_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "principal_permission_grants_company_id_companies_id_fk": {+ "name": "principal_permission_grants_company_id_companies_id_fk",+ "tableFrom": "principal_permission_grants",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_goals": {+ "name": "project_goals",+ "schema": "",+ "columns": {+ "project_id": {+ "name": "project_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "goal_id": {+ "name": "goal_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_goals_project_idx": {+ "name": "project_goals_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_goals_goal_idx": {+ "name": "project_goals_goal_idx",+ "columns": [+ {+ "expression": "goal_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_goals_company_idx": {+ "name": "project_goals_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_goals_project_id_projects_id_fk": {+ "name": "project_goals_project_id_projects_id_fk",+ "tableFrom": "project_goals",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_goals_goal_id_goals_id_fk": {+ "name": "project_goals_goal_id_goals_id_fk",+ "tableFrom": "project_goals",+ "tableTo": "goals",+ "columnsFrom": [+ "goal_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_goals_company_id_companies_id_fk": {+ "name": "project_goals_company_id_companies_id_fk",+ "tableFrom": "project_goals",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_goals_project_id_goal_id_pk": {+ "name": "project_goals_project_id_goal_id_pk",+ "columns": [+ "project_id",+ "goal_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_memberships": {+ "name": "project_memberships",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "state": {+ "name": "state",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'joined'"+ },+ "starred_at": {+ "name": "starred_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_memberships_company_user_idx": {+ "name": "project_memberships_company_user_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_memberships_company_user_starred_idx": {+ "name": "project_memberships_company_user_starred_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "starred_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_memberships_project_idx": {+ "name": "project_memberships_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_memberships_company_user_project_uq": {+ "name": "project_memberships_company_user_project_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_memberships_company_id_companies_id_fk": {+ "name": "project_memberships_company_id_companies_id_fk",+ "tableFrom": "project_memberships",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_memberships_project_id_projects_id_fk": {+ "name": "project_memberships_project_id_projects_id_fk",+ "tableFrom": "project_memberships",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_workspaces": {+ "name": "project_workspaces",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_type": {+ "name": "source_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'local_path'"+ },+ "cwd": {+ "name": "cwd",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "repo_url": {+ "name": "repo_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "repo_ref": {+ "name": "repo_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "default_ref": {+ "name": "default_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'default'"+ },+ "setup_command": {+ "name": "setup_command",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "cleanup_command": {+ "name": "cleanup_command",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "remote_provider": {+ "name": "remote_provider",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "remote_workspace_ref": {+ "name": "remote_workspace_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "shared_workspace_key": {+ "name": "shared_workspace_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "is_primary": {+ "name": "is_primary",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_workspaces_company_project_idx": {+ "name": "project_workspaces_company_project_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_workspaces_project_primary_idx": {+ "name": "project_workspaces_project_primary_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "is_primary",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_workspaces_project_source_type_idx": {+ "name": "project_workspaces_project_source_type_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_workspaces_company_shared_key_idx": {+ "name": "project_workspaces_company_shared_key_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "shared_workspace_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_workspaces_project_remote_ref_idx": {+ "name": "project_workspaces_project_remote_ref_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "remote_provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "remote_workspace_ref",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_workspaces_company_id_companies_id_fk": {+ "name": "project_workspaces_company_id_companies_id_fk",+ "tableFrom": "project_workspaces",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "project_workspaces_project_id_projects_id_fk": {+ "name": "project_workspaces_project_id_projects_id_fk",+ "tableFrom": "project_workspaces",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.projects": {+ "name": "projects",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "goal_id": {+ "name": "goal_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'backlog'"+ },+ "lead_agent_id": {+ "name": "lead_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "target_date": {+ "name": "target_date",+ "type": "date",+ "primaryKey": false,+ "notNull": false+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "env": {+ "name": "env",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "pause_reason": {+ "name": "pause_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "paused_at": {+ "name": "paused_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "execution_workspace_policy": {+ "name": "execution_workspace_policy",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "archived_at": {+ "name": "archived_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "projects_company_idx": {+ "name": "projects_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "projects_company_id_companies_id_fk": {+ "name": "projects_company_id_companies_id_fk",+ "tableFrom": "projects",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "projects_goal_id_goals_id_fk": {+ "name": "projects_goal_id_goals_id_fk",+ "tableFrom": "projects",+ "tableTo": "goals",+ "columnsFrom": [+ "goal_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "projects_lead_agent_id_agents_id_fk": {+ "name": "projects_lead_agent_id_agents_id_fk",+ "tableFrom": "projects",+ "tableTo": "agents",+ "columnsFrom": [+ "lead_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.provider_trace_records": {+ "name": "provider_trace_records",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'capturing'"+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "trace_ref": {+ "name": "trace_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "frame_count": {+ "name": "frame_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "byte_count": {+ "name": "byte_count",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "digest": {+ "name": "digest",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "reason": {+ "name": "reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "requested_by": {+ "name": "requested_by",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "provider_trace_records_run_unique": {+ "name": "provider_trace_records_run_unique",+ "columns": [+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "provider_trace_records_expiry_idx": {+ "name": "provider_trace_records_expiry_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "provider_trace_records_company_created_idx": {+ "name": "provider_trace_records_company_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "provider_trace_records_company_id_companies_id_fk": {+ "name": "provider_trace_records_company_id_companies_id_fk",+ "tableFrom": "provider_trace_records",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "provider_trace_records_run_id_heartbeat_runs_id_fk": {+ "name": "provider_trace_records_run_id_heartbeat_runs_id_fk",+ "tableFrom": "provider_trace_records",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.remote_agent_profiles": {+ "name": "remote_agent_profiles",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "profile_key": {+ "name": "profile_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "display_name": {+ "name": "display_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "service": {+ "name": "service",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "configuration": {+ "name": "configuration",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "retention_acknowledged": {+ "name": "retention_acknowledged",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "qualification": {+ "name": "qualification",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "qualified_at": {+ "name": "qualified_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "qualified_revision": {+ "name": "qualified_revision",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "remote_agent_profiles_company_idx": {+ "name": "remote_agent_profiles_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "remote_agent_profiles_company_key_uq": {+ "name": "remote_agent_profiles_company_key_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "profile_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "remote_agent_profiles_company_id_companies_id_fk": {+ "name": "remote_agent_profiles_company_id_companies_id_fk",+ "tableFrom": "remote_agent_profiles",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "remote_agent_profiles_service_check": {+ "name": "remote_agent_profiles_service_check",+ "value": "\"remote_agent_profiles\".\"service\" = 'aws_bedrock_agentcore_harness'"+ },+ "remote_agent_profiles_qualified_revision_check": {+ "name": "remote_agent_profiles_qualified_revision_check",+ "value": "(\"remote_agent_profiles\".\"qualified_at\" IS NULL AND \"remote_agent_profiles\".\"qualified_revision\" IS NULL) OR (\"remote_agent_profiles\".\"qualified_at\" IS NOT NULL AND \"remote_agent_profiles\".\"qualification\" <> '{}'::jsonb AND \"remote_agent_profiles\".\"qualified_revision\" ~ '^sha256:[0-9a-f]{64}$')"+ }+ },+ "isRLSEnabled": false+ },+ "public.routine_documents": {+ "name": "routine_documents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "routine_id": {+ "name": "routine_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "document_id": {+ "name": "document_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "routine_documents_company_routine_key_uq": {+ "name": "routine_documents_company_routine_key_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "routine_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "routine_documents_document_uq": {+ "name": "routine_documents_document_uq",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "routine_documents_company_routine_updated_idx": {+ "name": "routine_documents_company_routine_updated_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "routine_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "routine_documents_company_id_companies_id_fk": {+ "name": "routine_documents_company_id_companies_id_fk",+ "tableFrom": "routine_documents",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "routine_documents_routine_id_routines_id_fk": {+ "name": "routine_documents_routine_id_routines_id_fk",+ "tableFrom": "routine_documents",+ "tableTo": "routines",+ "columnsFrom": [+ "routine_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "routine_documents_document_id_documents_id_fk": {+ "name": "routine_documents_document_id_documents_id_fk",+ "tableFrom": "routine_documents",+ "tableTo": "documents",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.routine_revisions": {+ "name": "routine_revisions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "routine_id": {+ "name": "routine_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "revision_number": {+ "name": "revision_number",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "snapshot": {+ "name": "snapshot",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "change_summary": {+ "name": "change_summary",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "restored_from_revision_id": {+ "name": "restored_from_revision_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_run_id": {+ "name": "created_by_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "responsible_user_id": {+ "name": "responsible_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "routine_revisions_routine_revision_uq": {+ "name": "routine_revisions_routine_revision_uq",+ "columns": [+ {+ "expression": "routine_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "revision_number",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "routine_revisions_company_routine_created_idx": {+ "name": "routine_revisions_company_routine_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "routine_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "routine_revisions_company_responsible_user_idx": {+ "name": "routine_revisions_company_responsible_user_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "responsible_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "routine_revisions_company_id_companies_id_fk": {+ "name": "routine_revisions_company_id_companies_id_fk",+ "tableFrom": "routine_revisions",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "routine_revisions_routine_id_routines_id_fk": {+ "name": "routine_revisions_routine_id_routines_id_fk",+ "tableFrom": "routine_revisions",+ "tableTo": "routines",+ "columnsFrom": [+ "routine_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "routine_revisions_restored_from_revision_id_routine_revisions_id_fk": {+ "name": "routine_revisions_restored_from_revision_id_routine_revisions_id_fk",+ "tableFrom": "routine_revisions",+ "tableTo": "routine_revisions",+ "columnsFrom": [+ "restored_from_revision_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "routine_revisions_created_by_agent_id_agents_id_fk": {+ "name": "routine_revisions_created_by_agent_id_agents_id_fk",+ "tableFrom": "routine_revisions",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "routine_revisions_created_by_run_id_heartbeat_runs_id_fk": {+ "name": "routine_revisions_created_by_run_id_heartbeat_runs_id_fk",+ "tableFrom": "routine_revisions",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "created_by_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.routine_runs": {+ "name": "routine_runs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "routine_id": {+ "name": "routine_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "trigger_id": {+ "name": "trigger_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'received'"+ },+ "triggered_at": {+ "name": "triggered_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "routine_revision_id": {+ "name": "routine_revision_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "responsible_user_id": {+ "name": "responsible_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "idempotency_key": {+ "name": "idempotency_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "trigger_payload": {+ "name": "trigger_payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "dispatch_fingerprint": {+ "name": "dispatch_fingerprint",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "linked_issue_id": {+ "name": "linked_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "coalesced_into_run_id": {+ "name": "coalesced_into_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "failure_reason": {+ "name": "failure_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "routine_runs_company_routine_idx": {+ "name": "routine_runs_company_routine_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "routine_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "routine_runs_revision_idx": {+ "name": "routine_runs_revision_idx",+ "columns": [+ {+ "expression": "routine_revision_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "routine_runs_company_responsible_user_idx": {+ "name": "routine_runs_company_responsible_user_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "responsible_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "routine_runs_trigger_idx": {+ "name": "routine_runs_trigger_idx",+ "columns": [+ {+ "expression": "trigger_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "routine_runs_dispatch_fingerprint_idx": {+ "name": "routine_runs_dispatch_fingerprint_idx",+ "columns": [+ {+ "expression": "routine_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "dispatch_fingerprint",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "routine_runs_linked_issue_idx": {+ "name": "routine_runs_linked_issue_idx",+ "columns": [+ {+ "expression": "linked_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "routine_runs_trigger_idempotency_idx": {+ "name": "routine_runs_trigger_idempotency_idx",+ "columns": [+ {+ "expression": "trigger_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "idempotency_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "routine_runs_company_id_companies_id_fk": {+ "name": "routine_runs_company_id_companies_id_fk",+ "tableFrom": "routine_runs",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "routine_runs_routine_id_routines_id_fk": {+ "name": "routine_runs_routine_id_routines_id_fk",+ "tableFrom": "routine_runs",+ "tableTo": "routines",+ "columnsFrom": [+ "routine_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "routine_runs_trigger_id_routine_triggers_id_fk": {+ "name": "routine_runs_trigger_id_routine_triggers_id_fk",+ "tableFrom": "routine_runs",+ "tableTo": "routine_triggers",+ "columnsFrom": [+ "trigger_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "routine_runs_routine_revision_id_routine_revisions_id_fk": {+ "name": "routine_runs_routine_revision_id_routine_revisions_id_fk",+ "tableFrom": "routine_runs",+ "tableTo": "routine_revisions",+ "columnsFrom": [+ "routine_revision_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "routine_runs_linked_issue_id_issues_id_fk": {+ "name": "routine_runs_linked_issue_id_issues_id_fk",+ "tableFrom": "routine_runs",+ "tableTo": "issues",+ "columnsFrom": [+ "linked_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.routine_triggers": {+ "name": "routine_triggers",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "routine_id": {+ "name": "routine_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "label": {+ "name": "label",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "cron_expression": {+ "name": "cron_expression",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "timezone": {+ "name": "timezone",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "next_run_at": {+ "name": "next_run_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_fired_at": {+ "name": "last_fired_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "public_id": {+ "name": "public_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "secret_id": {+ "name": "secret_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "signing_mode": {+ "name": "signing_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "replay_window_sec": {+ "name": "replay_window_sec",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "last_rotated_at": {+ "name": "last_rotated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_result": {+ "name": "last_result",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "updated_by_agent_id": {+ "name": "updated_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "updated_by_user_id": {+ "name": "updated_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "routine_triggers_company_routine_idx": {+ "name": "routine_triggers_company_routine_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "routine_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "routine_triggers_company_kind_idx": {+ "name": "routine_triggers_company_kind_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "routine_triggers_next_run_idx": {+ "name": "routine_triggers_next_run_idx",+ "columns": [+ {+ "expression": "next_run_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "routine_triggers_public_id_idx": {+ "name": "routine_triggers_public_id_idx",+ "columns": [+ {+ "expression": "public_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "routine_triggers_public_id_uq": {+ "name": "routine_triggers_public_id_uq",+ "columns": [+ {+ "expression": "public_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "routine_triggers_company_id_companies_id_fk": {+ "name": "routine_triggers_company_id_companies_id_fk",+ "tableFrom": "routine_triggers",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "routine_triggers_routine_id_routines_id_fk": {+ "name": "routine_triggers_routine_id_routines_id_fk",+ "tableFrom": "routine_triggers",+ "tableTo": "routines",+ "columnsFrom": [+ "routine_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "routine_triggers_secret_id_company_secrets_id_fk": {+ "name": "routine_triggers_secret_id_company_secrets_id_fk",+ "tableFrom": "routine_triggers",+ "tableTo": "company_secrets",+ "columnsFrom": [+ "secret_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "routine_triggers_created_by_agent_id_agents_id_fk": {+ "name": "routine_triggers_created_by_agent_id_agents_id_fk",+ "tableFrom": "routine_triggers",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "routine_triggers_updated_by_agent_id_agents_id_fk": {+ "name": "routine_triggers_updated_by_agent_id_agents_id_fk",+ "tableFrom": "routine_triggers",+ "tableTo": "agents",+ "columnsFrom": [+ "updated_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.routines": {+ "name": "routines",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "folder_id": {+ "name": "folder_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "goal_id": {+ "name": "goal_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "parent_issue_id": {+ "name": "parent_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "assignee_agent_id": {+ "name": "assignee_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "priority": {+ "name": "priority",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'medium'"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "concurrency_policy": {+ "name": "concurrency_policy",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'coalesce_if_active'"+ },+ "catch_up_policy": {+ "name": "catch_up_policy",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'skip_missed'"+ },+ "activity_gate_policy": {+ "name": "activity_gate_policy",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'always'"+ },+ "activity_gate_scope": {+ "name": "activity_gate_scope",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'company'"+ },+ "origin_kind": {+ "name": "origin_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'manual'"+ },+ "origin_id": {+ "name": "origin_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "variables": {+ "name": "variables",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "env": {+ "name": "env",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "latest_revision_id": {+ "name": "latest_revision_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "latest_revision_number": {+ "name": "latest_revision_number",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "responsible_user_id": {+ "name": "responsible_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "updated_by_agent_id": {+ "name": "updated_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "updated_by_user_id": {+ "name": "updated_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "last_triggered_at": {+ "name": "last_triggered_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_enqueued_at": {+ "name": "last_enqueued_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "routines_company_status_idx": {+ "name": "routines_company_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "routines_company_assignee_idx": {+ "name": "routines_company_assignee_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "assignee_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "routines_company_project_idx": {+ "name": "routines_company_project_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "routines_company_folder_idx": {+ "name": "routines_company_folder_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "folder_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "routines_company_responsible_user_idx": {+ "name": "routines_company_responsible_user_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "responsible_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "routines_company_origin_idx": {+ "name": "routines_company_origin_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "origin_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "origin_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "routines_company_id_companies_id_fk": {+ "name": "routines_company_id_companies_id_fk",+ "tableFrom": "routines",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "routines_project_id_projects_id_fk": {+ "name": "routines_project_id_projects_id_fk",+ "tableFrom": "routines",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "routines_folder_id_folders_id_fk": {+ "name": "routines_folder_id_folders_id_fk",+ "tableFrom": "routines",+ "tableTo": "folders",+ "columnsFrom": [+ "folder_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "routines_goal_id_goals_id_fk": {+ "name": "routines_goal_id_goals_id_fk",+ "tableFrom": "routines",+ "tableTo": "goals",+ "columnsFrom": [+ "goal_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "routines_parent_issue_id_issues_id_fk": {+ "name": "routines_parent_issue_id_issues_id_fk",+ "tableFrom": "routines",+ "tableTo": "issues",+ "columnsFrom": [+ "parent_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "routines_assignee_agent_id_agents_id_fk": {+ "name": "routines_assignee_agent_id_agents_id_fk",+ "tableFrom": "routines",+ "tableTo": "agents",+ "columnsFrom": [+ "assignee_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "routines_created_by_agent_id_agents_id_fk": {+ "name": "routines_created_by_agent_id_agents_id_fk",+ "tableFrom": "routines",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "routines_updated_by_agent_id_agents_id_fk": {+ "name": "routines_updated_by_agent_id_agents_id_fk",+ "tableFrom": "routines",+ "tableTo": "agents",+ "columnsFrom": [+ "updated_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.run_identity_contexts": {+ "name": "run_identity_contexts",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "revision": {+ "name": "revision",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "responsible_user_id": {+ "name": "responsible_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "message_id": {+ "name": "message_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "parent_context_id": {+ "name": "parent_context_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "cause": {+ "name": "cause",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "correlation_id": {+ "name": "correlation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'accepted'"+ },+ "accepted_at": {+ "name": "accepted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "github": {+ "name": "github",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "run_identity_contexts_run_revision_idx": {+ "name": "run_identity_contexts_run_revision_idx",+ "columns": [+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "revision",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "run_identity_contexts_run_correlation_idx": {+ "name": "run_identity_contexts_run_correlation_idx",+ "columns": [+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "correlation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "run_identity_contexts_company_run_idx": {+ "name": "run_identity_contexts_company_run_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "run_identity_contexts_company_id_companies_id_fk": {+ "name": "run_identity_contexts_company_id_companies_id_fk",+ "tableFrom": "run_identity_contexts",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.secret_access_events": {+ "name": "secret_access_events",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "secret_id": {+ "name": "secret_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "user_secret_definition_id": {+ "name": "user_secret_definition_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "secret_scope": {+ "name": "secret_scope",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'company'"+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "responsible_user_id": {+ "name": "responsible_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "credential_owner_user_id": {+ "name": "credential_owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "credential_subject_type": {+ "name": "credential_subject_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "credential_subject_id": {+ "name": "credential_subject_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "actor_type": {+ "name": "actor_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "actor_id": {+ "name": "actor_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "consumer_type": {+ "name": "consumer_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "consumer_id": {+ "name": "consumer_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "config_path": {+ "name": "config_path",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "heartbeat_run_id": {+ "name": "heartbeat_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "plugin_id": {+ "name": "plugin_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "outcome": {+ "name": "outcome",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "error_code": {+ "name": "error_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "secret_access_events_company_created_idx": {+ "name": "secret_access_events_company_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "secret_access_events_secret_created_idx": {+ "name": "secret_access_events_secret_created_idx",+ "columns": [+ {+ "expression": "secret_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "secret_access_events_user_definition_created_idx": {+ "name": "secret_access_events_user_definition_created_idx",+ "columns": [+ {+ "expression": "user_secret_definition_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "secret_access_events_company_credential_owner_idx": {+ "name": "secret_access_events_company_credential_owner_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "credential_owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "secret_access_events_consumer_idx": {+ "name": "secret_access_events_consumer_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "consumer_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "consumer_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "secret_access_events_run_idx": {+ "name": "secret_access_events_run_idx",+ "columns": [+ {+ "expression": "heartbeat_run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "secret_access_events_company_id_companies_id_fk": {+ "name": "secret_access_events_company_id_companies_id_fk",+ "tableFrom": "secret_access_events",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "secret_access_events_secret_id_company_secrets_id_fk": {+ "name": "secret_access_events_secret_id_company_secrets_id_fk",+ "tableFrom": "secret_access_events",+ "tableTo": "company_secrets",+ "columnsFrom": [+ "secret_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "secret_access_events_user_secret_definition_id_user_secret_definitions_id_fk": {+ "name": "secret_access_events_user_secret_definition_id_user_secret_definitions_id_fk",+ "tableFrom": "secret_access_events",+ "tableTo": "user_secret_definitions",+ "columnsFrom": [+ "user_secret_definition_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "secret_access_events_issue_id_issues_id_fk": {+ "name": "secret_access_events_issue_id_issues_id_fk",+ "tableFrom": "secret_access_events",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "secret_access_events_heartbeat_run_id_heartbeat_runs_id_fk": {+ "name": "secret_access_events_heartbeat_run_id_heartbeat_runs_id_fk",+ "tableFrom": "secret_access_events",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "heartbeat_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "secret_access_events_plugin_id_plugins_id_fk": {+ "name": "secret_access_events_plugin_id_plugins_id_fk",+ "tableFrom": "secret_access_events",+ "tableTo": "plugins",+ "columnsFrom": [+ "plugin_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.smoke_run_steps": {+ "name": "smoke_run_steps",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "path": {+ "name": "path",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scenario_step": {+ "name": "scenario_step",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "detail": {+ "name": "detail",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "screenshot_artifact_ref": {+ "name": "screenshot_artifact_ref",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "duration_ms": {+ "name": "duration_ms",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "smoke_run_steps_company_run_idx": {+ "name": "smoke_run_steps_company_run_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "smoke_run_steps_company_path_idx": {+ "name": "smoke_run_steps_company_path_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "path",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "smoke_run_steps_company_id_companies_id_fk": {+ "name": "smoke_run_steps_company_id_companies_id_fk",+ "tableFrom": "smoke_run_steps",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "smoke_run_steps_run_id_smoke_runs_id_fk": {+ "name": "smoke_run_steps_run_id_smoke_runs_id_fk",+ "tableFrom": "smoke_run_steps",+ "tableTo": "smoke_runs",+ "columnsFrom": [+ "run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.smoke_runs": {+ "name": "smoke_runs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "trigger": {+ "name": "trigger",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'running'"+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "finished_at": {+ "name": "finished_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "summary": {+ "name": "summary",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "smoke_runs_company_started_idx": {+ "name": "smoke_runs_company_started_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "started_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "smoke_runs_company_status_idx": {+ "name": "smoke_runs_company_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "smoke_runs_company_id_companies_id_fk": {+ "name": "smoke_runs_company_id_companies_id_fk",+ "tableFrom": "smoke_runs",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.status_card_updates": {+ "name": "status_card_updates",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "card_id": {+ "name": "card_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "trigger": {+ "name": "trigger",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "generation_issue_id": {+ "name": "generation_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "changes": {+ "name": "changes",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "input_tokens": {+ "name": "input_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "output_tokens": {+ "name": "output_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "cost_cents": {+ "name": "cost_cents",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "query_version": {+ "name": "query_version",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "change_summary": {+ "name": "change_summary",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "finished_at": {+ "name": "finished_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "error": {+ "name": "error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "status_card_updates_card_started_idx": {+ "name": "status_card_updates_card_started_idx",+ "columns": [+ {+ "expression": "card_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "started_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "status_card_updates_generation_issue_idx": {+ "name": "status_card_updates_generation_issue_idx",+ "columns": [+ {+ "expression": "generation_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "status_card_updates_card_id_status_cards_id_fk": {+ "name": "status_card_updates_card_id_status_cards_id_fk",+ "tableFrom": "status_card_updates",+ "tableTo": "status_cards",+ "columnsFrom": [+ "card_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "status_card_updates_generation_issue_id_issues_id_fk": {+ "name": "status_card_updates_generation_issue_id_issues_id_fk",+ "tableFrom": "status_card_updates",+ "tableTo": "issues",+ "columnsFrom": [+ "generation_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "status_card_updates_run_id_heartbeat_runs_id_fk": {+ "name": "status_card_updates_run_id_heartbeat_runs_id_fk",+ "tableFrom": "status_card_updates",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.status_cards": {+ "name": "status_cards",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "title_pinned": {+ "name": "title_pinned",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "interest_prompt": {+ "name": "interest_prompt",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "queries": {+ "name": "queries",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "query_version": {+ "name": "query_version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "query_compiled_at": {+ "name": "query_compiled_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "query_compiled_by_agent_id": {+ "name": "query_compiled_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "refresh_policy": {+ "name": "refresh_policy",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "state": {+ "name": "state",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'compiling'"+ },+ "pending_change_count": {+ "name": "pending_change_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "pending_change_hash": {+ "name": "pending_change_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "last_change_at": {+ "name": "last_change_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "fingerprint": {+ "name": "fingerprint",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "fingerprint_at": {+ "name": "fingerprint_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "mentioned_issue_ids": {+ "name": "mentioned_issue_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "document_id": {+ "name": "document_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "last_update_run_kind": {+ "name": "last_update_run_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "last_generated_at": {+ "name": "last_generated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_model": {+ "name": "last_model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "generating_issue_id": {+ "name": "generating_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "failure_reason": {+ "name": "failure_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "next_eval_at": {+ "name": "next_eval_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "archived_at": {+ "name": "archived_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "archived_by_user_id": {+ "name": "archived_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "archived_by_agent_id": {+ "name": "archived_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "status_cards_company_archived_idx": {+ "name": "status_cards_company_archived_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "archived_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "status_cards_company_next_eval_idx": {+ "name": "status_cards_company_next_eval_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "next_eval_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "status_cards_company_id_companies_id_fk": {+ "name": "status_cards_company_id_companies_id_fk",+ "tableFrom": "status_cards",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "status_cards_created_by_agent_id_agents_id_fk": {+ "name": "status_cards_created_by_agent_id_agents_id_fk",+ "tableFrom": "status_cards",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "status_cards_query_compiled_by_agent_id_agents_id_fk": {+ "name": "status_cards_query_compiled_by_agent_id_agents_id_fk",+ "tableFrom": "status_cards",+ "tableTo": "agents",+ "columnsFrom": [+ "query_compiled_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "status_cards_agent_id_agents_id_fk": {+ "name": "status_cards_agent_id_agents_id_fk",+ "tableFrom": "status_cards",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "status_cards_document_id_documents_id_fk": {+ "name": "status_cards_document_id_documents_id_fk",+ "tableFrom": "status_cards",+ "tableTo": "documents",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "status_cards_generating_issue_id_issues_id_fk": {+ "name": "status_cards_generating_issue_id_issues_id_fk",+ "tableFrom": "status_cards",+ "tableTo": "issues",+ "columnsFrom": [+ "generating_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "status_cards_archived_by_agent_id_agents_id_fk": {+ "name": "status_cards_archived_by_agent_id_agents_id_fk",+ "tableFrom": "status_cards",+ "tableTo": "agents",+ "columnsFrom": [+ "archived_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.status_decision_effects": {+ "name": "status_decision_effects",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "decision_id": {+ "name": "decision_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "ordinal": {+ "name": "ordinal",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "effect_kind": {+ "name": "effect_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "target_type": {+ "name": "target_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "target_id": {+ "name": "target_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "idempotency_key": {+ "name": "idempotency_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "delivery_state": {+ "name": "delivery_state",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "attempt_count": {+ "name": "attempt_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "delivered_at": {+ "name": "delivered_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "status_decision_effects_decision_ordinal_uq": {+ "name": "status_decision_effects_decision_ordinal_uq",+ "columns": [+ {+ "expression": "decision_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "ordinal",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "status_decision_effects_company_idempotency_uq": {+ "name": "status_decision_effects_company_idempotency_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "idempotency_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "status_decision_effects_company_id_companies_id_fk": {+ "name": "status_decision_effects_company_id_companies_id_fk",+ "tableFrom": "status_decision_effects",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "status_decision_effects_issue_company_fk": {+ "name": "status_decision_effects_issue_company_fk",+ "tableFrom": "status_decision_effects",+ "tableTo": "issues",+ "columnsFrom": [+ "company_id",+ "issue_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "status_decision_effects_decision_owner_fk": {+ "name": "status_decision_effects_decision_owner_fk",+ "tableFrom": "status_decision_effects",+ "tableTo": "status_decisions",+ "columnsFrom": [+ "company_id",+ "issue_id",+ "decision_id"+ ],+ "columnsTo": [+ "company_id",+ "issue_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.status_decisions": {+ "name": "status_decisions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "assessment_id": {+ "name": "assessment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "decision_version": {+ "name": "decision_version",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true+ },+ "policy_version": {+ "name": "policy_version",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "from_status": {+ "name": "from_status",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "to_status": {+ "name": "to_status",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "reason_code": {+ "name": "reason_code",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "decision_json": {+ "name": "decision_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "decision_digest": {+ "name": "decision_digest",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "application_state": {+ "name": "application_state",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'proposed'"+ },+ "supersedes_decision_id": {+ "name": "supersedes_decision_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "applied_at": {+ "name": "applied_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "status_decisions_company_issue_version_uq": {+ "name": "status_decisions_company_issue_version_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "decision_version",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "status_decisions_company_assessment_uq": {+ "name": "status_decisions_company_assessment_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "assessment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "status_decisions_company_issue_digest_uq": {+ "name": "status_decisions_company_issue_digest_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "decision_digest",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "status_decisions_company_id_companies_id_fk": {+ "name": "status_decisions_company_id_companies_id_fk",+ "tableFrom": "status_decisions",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "status_decisions_issue_company_fk": {+ "name": "status_decisions_issue_company_fk",+ "tableFrom": "status_decisions",+ "tableTo": "issues",+ "columnsFrom": [+ "company_id",+ "issue_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "status_decisions_assessment_owner_fk": {+ "name": "status_decisions_assessment_owner_fk",+ "tableFrom": "status_decisions",+ "tableTo": "work_assessments",+ "columnsFrom": [+ "company_id",+ "issue_id",+ "run_id",+ "assessment_id"+ ],+ "columnsTo": [+ "company_id",+ "issue_id",+ "run_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "status_decisions_supersedes_owner_fk": {+ "name": "status_decisions_supersedes_owner_fk",+ "tableFrom": "status_decisions",+ "tableTo": "status_decisions",+ "columnsFrom": [+ "company_id",+ "issue_id",+ "supersedes_decision_id"+ ],+ "columnsTo": [+ "company_id",+ "issue_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "status_decisions_company_issue_id_uq": {+ "name": "status_decisions_company_issue_id_uq",+ "nullsNotDistinct": false,+ "columns": [+ "company_id",+ "issue_id",+ "id"+ ]+ },+ "status_decisions_company_issue_run_assessment_id_uq": {+ "name": "status_decisions_company_issue_run_assessment_id_uq",+ "nullsNotDistinct": false,+ "columns": [+ "company_id",+ "issue_id",+ "run_id",+ "assessment_id",+ "id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.summary_slots": {+ "name": "summary_slots",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "scope_kind": {+ "name": "scope_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope_id": {+ "name": "scope_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "slot_key": {+ "name": "slot_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "document_id": {+ "name": "document_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'idle'"+ },+ "failure_reason": {+ "name": "failure_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "generating_issue_id": {+ "name": "generating_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "last_generated_at": {+ "name": "last_generated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_generated_by_agent_id": {+ "name": "last_generated_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "last_model": {+ "name": "last_model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "summary_slots_document_uq": {+ "name": "summary_slots_document_uq",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "summary_slots_company_scope_idx": {+ "name": "summary_slots_company_scope_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "scope_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "scope_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "summary_slots_company_generating_issue_idx": {+ "name": "summary_slots_company_generating_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "generating_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "summary_slots_company_updated_idx": {+ "name": "summary_slots_company_updated_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "summary_slots_company_id_companies_id_fk": {+ "name": "summary_slots_company_id_companies_id_fk",+ "tableFrom": "summary_slots",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "summary_slots_document_id_documents_id_fk": {+ "name": "summary_slots_document_id_documents_id_fk",+ "tableFrom": "summary_slots",+ "tableTo": "documents",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "summary_slots_generating_issue_id_issues_id_fk": {+ "name": "summary_slots_generating_issue_id_issues_id_fk",+ "tableFrom": "summary_slots",+ "tableTo": "issues",+ "columnsFrom": [+ "generating_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "summary_slots_last_generated_by_agent_id_agents_id_fk": {+ "name": "summary_slots_last_generated_by_agent_id_agents_id_fk",+ "tableFrom": "summary_slots",+ "tableTo": "agents",+ "columnsFrom": [+ "last_generated_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "summary_slots_company_scope_slot_uq": {+ "name": "summary_slots_company_scope_slot_uq",+ "nullsNotDistinct": true,+ "columns": [+ "company_id",+ "scope_kind",+ "scope_id",+ "slot_key"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.tool_access_audit_events": {+ "name": "tool_access_audit_events",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "gateway_id": {+ "name": "gateway_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "gateway_token_id": {+ "name": "gateway_token_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "gateway_public_id": {+ "name": "gateway_public_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_name": {+ "name": "client_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "correlation_id": {+ "name": "correlation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "connection_id": {+ "name": "connection_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "catalog_entry_id": {+ "name": "catalog_entry_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "actor_type": {+ "name": "actor_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'system'"+ },+ "actor_id": {+ "name": "actor_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "action": {+ "name": "action",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "outcome": {+ "name": "outcome",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "reason_code": {+ "name": "reason_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "details": {+ "name": "details",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "tool_access_audit_company_created_idx": {+ "name": "tool_access_audit_company_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_access_audit_connection_idx": {+ "name": "tool_access_audit_connection_idx",+ "columns": [+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_access_audit_gateway_idx": {+ "name": "tool_access_audit_gateway_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "gateway_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tool_access_audit_events_company_id_companies_id_fk": {+ "name": "tool_access_audit_events_company_id_companies_id_fk",+ "tableFrom": "tool_access_audit_events",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_access_audit_events_gateway_id_tool_mcp_gateways_id_fk": {+ "name": "tool_access_audit_events_gateway_id_tool_mcp_gateways_id_fk",+ "tableFrom": "tool_access_audit_events",+ "tableTo": "tool_mcp_gateways",+ "columnsFrom": [+ "gateway_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_access_audit_events_gateway_token_id_tool_mcp_gateway_tokens_id_fk": {+ "name": "tool_access_audit_events_gateway_token_id_tool_mcp_gateway_tokens_id_fk",+ "tableFrom": "tool_access_audit_events",+ "tableTo": "tool_mcp_gateway_tokens",+ "columnsFrom": [+ "gateway_token_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_access_audit_events_connection_id_tool_connections_id_fk": {+ "name": "tool_access_audit_events_connection_id_tool_connections_id_fk",+ "tableFrom": "tool_access_audit_events",+ "tableTo": "tool_connections",+ "columnsFrom": [+ "connection_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_access_audit_events_catalog_entry_id_tool_catalog_entries_id_fk": {+ "name": "tool_access_audit_events_catalog_entry_id_tool_catalog_entries_id_fk",+ "tableFrom": "tool_access_audit_events",+ "tableTo": "tool_catalog_entries",+ "columnsFrom": [+ "catalog_entry_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.tool_action_deliveries": {+ "name": "tool_action_deliveries",+ "schema": "",+ "columns": {+ "action_request_id": {+ "name": "action_request_id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "interaction_id": {+ "name": "interaction_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "delivered_at": {+ "name": "delivered_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "tool_action_deliveries_pending_idx": {+ "name": "tool_action_deliveries_pending_idx",+ "columns": [+ {+ "expression": "delivered_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tool_action_deliveries_action_request_id_tool_action_requests_id_fk": {+ "name": "tool_action_deliveries_action_request_id_tool_action_requests_id_fk",+ "tableFrom": "tool_action_deliveries",+ "tableTo": "tool_action_requests",+ "columnsFrom": [+ "action_request_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_action_deliveries_company_id_companies_id_fk": {+ "name": "tool_action_deliveries_company_id_companies_id_fk",+ "tableFrom": "tool_action_deliveries",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_action_deliveries_issue_id_issues_id_fk": {+ "name": "tool_action_deliveries_issue_id_issues_id_fk",+ "tableFrom": "tool_action_deliveries",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_action_deliveries_interaction_id_issue_thread_interactions_id_fk": {+ "name": "tool_action_deliveries_interaction_id_issue_thread_interactions_id_fk",+ "tableFrom": "tool_action_deliveries",+ "tableTo": "issue_thread_interactions",+ "columnsFrom": [+ "interaction_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.tool_action_requests": {+ "name": "tool_action_requests",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "invocation_id": {+ "name": "invocation_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "interaction_id": {+ "name": "interaction_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "approval_id": {+ "name": "approval_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "canonical_arguments_hash": {+ "name": "canonical_arguments_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "canonical_arguments_summary": {+ "name": "canonical_arguments_summary",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "signed_arguments": {+ "name": "signed_arguments",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "preview_markdown": {+ "name": "preview_markdown",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "requested_by_agent_id": {+ "name": "requested_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "requested_by_user_id": {+ "name": "requested_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_by_agent_id": {+ "name": "resolved_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_by_user_id": {+ "name": "resolved_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "decided_by_agent_id": {+ "name": "decided_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "decided_by_user_id": {+ "name": "decided_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "decided_at": {+ "name": "decided_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_at": {+ "name": "resolved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "tool_action_requests_company_status_idx": {+ "name": "tool_action_requests_company_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_action_requests_invocation_idx": {+ "name": "tool_action_requests_invocation_idx",+ "columns": [+ {+ "expression": "invocation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_action_requests_issue_idx": {+ "name": "tool_action_requests_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tool_action_requests_company_id_companies_id_fk": {+ "name": "tool_action_requests_company_id_companies_id_fk",+ "tableFrom": "tool_action_requests",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_action_requests_invocation_id_tool_invocations_id_fk": {+ "name": "tool_action_requests_invocation_id_tool_invocations_id_fk",+ "tableFrom": "tool_action_requests",+ "tableTo": "tool_invocations",+ "columnsFrom": [+ "invocation_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_action_requests_issue_id_issues_id_fk": {+ "name": "tool_action_requests_issue_id_issues_id_fk",+ "tableFrom": "tool_action_requests",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_action_requests_interaction_id_issue_thread_interactions_id_fk": {+ "name": "tool_action_requests_interaction_id_issue_thread_interactions_id_fk",+ "tableFrom": "tool_action_requests",+ "tableTo": "issue_thread_interactions",+ "columnsFrom": [+ "interaction_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_action_requests_approval_id_approvals_id_fk": {+ "name": "tool_action_requests_approval_id_approvals_id_fk",+ "tableFrom": "tool_action_requests",+ "tableTo": "approvals",+ "columnsFrom": [+ "approval_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_action_requests_requested_by_agent_id_agents_id_fk": {+ "name": "tool_action_requests_requested_by_agent_id_agents_id_fk",+ "tableFrom": "tool_action_requests",+ "tableTo": "agents",+ "columnsFrom": [+ "requested_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_action_requests_resolved_by_agent_id_agents_id_fk": {+ "name": "tool_action_requests_resolved_by_agent_id_agents_id_fk",+ "tableFrom": "tool_action_requests",+ "tableTo": "agents",+ "columnsFrom": [+ "resolved_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_action_requests_decided_by_agent_id_agents_id_fk": {+ "name": "tool_action_requests_decided_by_agent_id_agents_id_fk",+ "tableFrom": "tool_action_requests",+ "tableTo": "agents",+ "columnsFrom": [+ "decided_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.tool_applications": {+ "name": "tool_applications",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "application_key": {+ "name": "application_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "plugin_id": {+ "name": "plugin_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "owner_agent_id": {+ "name": "owner_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "archived_at": {+ "name": "archived_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "tool_applications_company_idx": {+ "name": "tool_applications_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_applications_company_status_idx": {+ "name": "tool_applications_company_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_applications_company_name_uq": {+ "name": "tool_applications_company_name_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_applications_company_key_uq": {+ "name": "tool_applications_company_key_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "application_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tool_applications_company_id_companies_id_fk": {+ "name": "tool_applications_company_id_companies_id_fk",+ "tableFrom": "tool_applications",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_applications_plugin_id_plugins_id_fk": {+ "name": "tool_applications_plugin_id_plugins_id_fk",+ "tableFrom": "tool_applications",+ "tableTo": "plugins",+ "columnsFrom": [+ "plugin_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_applications_owner_agent_id_agents_id_fk": {+ "name": "tool_applications_owner_agent_id_agents_id_fk",+ "tableFrom": "tool_applications",+ "tableTo": "agents",+ "columnsFrom": [+ "owner_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.tool_call_events": {+ "name": "tool_call_events",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "event_type": {+ "name": "event_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "actor_type": {+ "name": "actor_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'system'"+ },+ "actor_id": {+ "name": "actor_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "gateway_id": {+ "name": "gateway_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "gateway_token_id": {+ "name": "gateway_token_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "gateway_public_id": {+ "name": "gateway_public_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_subject_type": {+ "name": "client_subject_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_subject_id": {+ "name": "client_subject_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_name": {+ "name": "client_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "mcp_session_id": {+ "name": "mcp_session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "correlation_id": {+ "name": "correlation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "application_id": {+ "name": "application_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "connection_id": {+ "name": "connection_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "catalog_entry_id": {+ "name": "catalog_entry_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "invocation_id": {+ "name": "invocation_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "action_request_id": {+ "name": "action_request_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "runtime_slot_id": {+ "name": "runtime_slot_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "tool_name": {+ "name": "tool_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "decision": {+ "name": "decision",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "matched_policy_ids": {+ "name": "matched_policy_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "reason_code": {+ "name": "reason_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "policy_explanation": {+ "name": "policy_explanation",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "credential_scope_summary": {+ "name": "credential_scope_summary",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "header_policy_summary": {+ "name": "header_policy_summary",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "outcome": {+ "name": "outcome",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "latency_ms": {+ "name": "latency_ms",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "arguments_summary": {+ "name": "arguments_summary",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "request_hash": {+ "name": "request_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "request_summary": {+ "name": "request_summary",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "result_hash": {+ "name": "result_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "result_summary": {+ "name": "result_summary",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "result_size_bytes": {+ "name": "result_size_bytes",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "redaction_plan": {+ "name": "redaction_plan",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "rate_limit_state": {+ "name": "rate_limit_state",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "error_code": {+ "name": "error_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "error_message": {+ "name": "error_message",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "tool_call_events_company_created_idx": {+ "name": "tool_call_events_company_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_call_events_run_idx": {+ "name": "tool_call_events_run_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_call_events_issue_idx": {+ "name": "tool_call_events_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_call_events_invocation_idx": {+ "name": "tool_call_events_invocation_idx",+ "columns": [+ {+ "expression": "invocation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_call_events_gateway_idx": {+ "name": "tool_call_events_gateway_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "gateway_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tool_call_events_company_id_companies_id_fk": {+ "name": "tool_call_events_company_id_companies_id_fk",+ "tableFrom": "tool_call_events",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_call_events_agent_id_agents_id_fk": {+ "name": "tool_call_events_agent_id_agents_id_fk",+ "tableFrom": "tool_call_events",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_call_events_run_id_heartbeat_runs_id_fk": {+ "name": "tool_call_events_run_id_heartbeat_runs_id_fk",+ "tableFrom": "tool_call_events",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_call_events_issue_id_issues_id_fk": {+ "name": "tool_call_events_issue_id_issues_id_fk",+ "tableFrom": "tool_call_events",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_call_events_gateway_id_tool_mcp_gateways_id_fk": {+ "name": "tool_call_events_gateway_id_tool_mcp_gateways_id_fk",+ "tableFrom": "tool_call_events",+ "tableTo": "tool_mcp_gateways",+ "columnsFrom": [+ "gateway_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_call_events_gateway_token_id_tool_mcp_gateway_tokens_id_fk": {+ "name": "tool_call_events_gateway_token_id_tool_mcp_gateway_tokens_id_fk",+ "tableFrom": "tool_call_events",+ "tableTo": "tool_mcp_gateway_tokens",+ "columnsFrom": [+ "gateway_token_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_call_events_application_id_tool_applications_id_fk": {+ "name": "tool_call_events_application_id_tool_applications_id_fk",+ "tableFrom": "tool_call_events",+ "tableTo": "tool_applications",+ "columnsFrom": [+ "application_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_call_events_connection_id_tool_connections_id_fk": {+ "name": "tool_call_events_connection_id_tool_connections_id_fk",+ "tableFrom": "tool_call_events",+ "tableTo": "tool_connections",+ "columnsFrom": [+ "connection_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_call_events_catalog_entry_id_tool_catalog_entries_id_fk": {+ "name": "tool_call_events_catalog_entry_id_tool_catalog_entries_id_fk",+ "tableFrom": "tool_call_events",+ "tableTo": "tool_catalog_entries",+ "columnsFrom": [+ "catalog_entry_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_call_events_invocation_id_tool_invocations_id_fk": {+ "name": "tool_call_events_invocation_id_tool_invocations_id_fk",+ "tableFrom": "tool_call_events",+ "tableTo": "tool_invocations",+ "columnsFrom": [+ "invocation_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_call_events_action_request_id_tool_action_requests_id_fk": {+ "name": "tool_call_events_action_request_id_tool_action_requests_id_fk",+ "tableFrom": "tool_call_events",+ "tableTo": "tool_action_requests",+ "columnsFrom": [+ "action_request_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_call_events_runtime_slot_id_tool_runtime_slots_id_fk": {+ "name": "tool_call_events_runtime_slot_id_tool_runtime_slots_id_fk",+ "tableFrom": "tool_call_events",+ "tableTo": "tool_runtime_slots",+ "columnsFrom": [+ "runtime_slot_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.tool_catalog_entries": {+ "name": "tool_catalog_entries",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "application_id": {+ "name": "application_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "connection_id": {+ "name": "connection_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "entry_kind": {+ "name": "entry_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'tool'"+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "tool_name": {+ "name": "tool_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "input_schema": {+ "name": "input_schema",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "output_schema": {+ "name": "output_schema",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "annotations": {+ "name": "annotations",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "risk_level": {+ "name": "risk_level",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'read'"+ },+ "is_read_only": {+ "name": "is_read_only",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "is_write": {+ "name": "is_write",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "is_destructive": {+ "name": "is_destructive",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "version": {+ "name": "version",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "version_hash": {+ "name": "version_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "schema_hash": {+ "name": "schema_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "first_seen_at": {+ "name": "first_seen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_seen_at": {+ "name": "last_seen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "reviewed_at": {+ "name": "reviewed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "reviewed_by_agent_id": {+ "name": "reviewed_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "reviewed_by_user_id": {+ "name": "reviewed_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "quarantined_at": {+ "name": "quarantined_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "quarantine_reason": {+ "name": "quarantine_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "tool_catalog_entries_company_idx": {+ "name": "tool_catalog_entries_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_catalog_entries_application_idx": {+ "name": "tool_catalog_entries_application_idx",+ "columns": [+ {+ "expression": "application_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_catalog_entries_connection_idx": {+ "name": "tool_catalog_entries_connection_idx",+ "columns": [+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_catalog_entries_company_status_idx": {+ "name": "tool_catalog_entries_company_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_catalog_entries_connection_name_uq": {+ "name": "tool_catalog_entries_connection_name_uq",+ "columns": [+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tool_catalog_entries_company_id_companies_id_fk": {+ "name": "tool_catalog_entries_company_id_companies_id_fk",+ "tableFrom": "tool_catalog_entries",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_catalog_entries_application_id_tool_applications_id_fk": {+ "name": "tool_catalog_entries_application_id_tool_applications_id_fk",+ "tableFrom": "tool_catalog_entries",+ "tableTo": "tool_applications",+ "columnsFrom": [+ "application_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_catalog_entries_connection_id_tool_connections_id_fk": {+ "name": "tool_catalog_entries_connection_id_tool_connections_id_fk",+ "tableFrom": "tool_catalog_entries",+ "tableTo": "tool_connections",+ "columnsFrom": [+ "connection_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_catalog_entries_reviewed_by_agent_id_agents_id_fk": {+ "name": "tool_catalog_entries_reviewed_by_agent_id_agents_id_fk",+ "tableFrom": "tool_catalog_entries",+ "tableTo": "agents",+ "columnsFrom": [+ "reviewed_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.tool_connection_installs": {+ "name": "tool_connection_installs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "connection_id": {+ "name": "connection_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "target_type": {+ "name": "target_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "target_id": {+ "name": "target_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "tool_connection_installs_company_target_idx": {+ "name": "tool_connection_installs_company_target_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_connection_installs_connection_idx": {+ "name": "tool_connection_installs_connection_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_connection_installs_target_uq": {+ "name": "tool_connection_installs_target_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tool_connection_installs_company_id_companies_id_fk": {+ "name": "tool_connection_installs_company_id_companies_id_fk",+ "tableFrom": "tool_connection_installs",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_connection_installs_connection_id_tool_connections_id_fk": {+ "name": "tool_connection_installs_connection_id_tool_connections_id_fk",+ "tableFrom": "tool_connection_installs",+ "tableTo": "tool_connections",+ "columnsFrom": [+ "connection_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_connection_installs_created_by_agent_id_agents_id_fk": {+ "name": "tool_connection_installs_created_by_agent_id_agents_id_fk",+ "tableFrom": "tool_connection_installs",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "tool_connection_installs_target_type_check": {+ "name": "tool_connection_installs_target_type_check",+ "value": "\"tool_connection_installs\".\"target_type\" in ('company', 'agent')"+ }+ },+ "isRLSEnabled": false+ },+ "public.tool_connections": {+ "name": "tool_connections",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "application_id": {+ "name": "application_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "uid": {+ "name": "uid",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "connection_kind": {+ "name": "connection_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'managed'"+ },+ "connection_purpose": {+ "name": "connection_purpose",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'tool'"+ },+ "ownership": {+ "name": "ownership",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'customer'"+ },+ "transport": {+ "name": "transport",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "auth_kind": {+ "name": "auth_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'none'"+ },+ "credential_source": {+ "name": "credential_source",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'paperclip_vault'"+ },+ "external_credential": {+ "name": "external_credential",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "credential_policy": {+ "name": "credential_policy",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'shared'"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'draft'"+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "transport_config": {+ "name": "transport_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "credential_refs": {+ "name": "credential_refs",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "credential_secret_refs": {+ "name": "credential_secret_refs",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "health_status": {+ "name": "health_status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'unchecked'"+ },+ "health_message": {+ "name": "health_message",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "health_checked_at": {+ "name": "health_checked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_health_at": {+ "name": "last_health_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_catalog_refresh_at": {+ "name": "last_catalog_refresh_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "tool_connections_company_idx": {+ "name": "tool_connections_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_connections_application_idx": {+ "name": "tool_connections_application_idx",+ "columns": [+ {+ "expression": "application_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_connections_company_enabled_idx": {+ "name": "tool_connections_company_enabled_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "enabled",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_connections_company_uid_uq": {+ "name": "tool_connections_company_uid_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "uid",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tool_connections_company_id_companies_id_fk": {+ "name": "tool_connections_company_id_companies_id_fk",+ "tableFrom": "tool_connections",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_connections_application_id_tool_applications_id_fk": {+ "name": "tool_connections_application_id_tool_applications_id_fk",+ "tableFrom": "tool_connections",+ "tableTo": "tool_applications",+ "columnsFrom": [+ "application_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "tool_connections_created_by_agent_id_agents_id_fk": {+ "name": "tool_connections_created_by_agent_id_agents_id_fk",+ "tableFrom": "tool_connections",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "tool_connections_company_id_uq": {+ "name": "tool_connections_company_id_uq",+ "nullsNotDistinct": false,+ "columns": [+ "company_id",+ "id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "tool_connections_ownership_check": {+ "name": "tool_connections_ownership_check",+ "value": "\"tool_connections\".\"ownership\" in ('platform_shared', 'platform_provisioned', 'customer', 'dcr')"+ },+ "tool_connections_transport_check": {+ "name": "tool_connections_transport_check",+ "value": "\"tool_connections\".\"transport\" in ('mcp_remote', 'rest_api', 'local_stdio', 'chat_sdk', 'runtime_auth')"+ },+ "tool_connections_purpose_check": {+ "name": "tool_connections_purpose_check",+ "value": "\"tool_connections\".\"connection_purpose\" in ('tool', 'channel', 'ai')"+ },+ "tool_connections_channel_transport_check": {+ "name": "tool_connections_channel_transport_check",+ "value": "(\n (\"tool_connections\".\"connection_purpose\" = 'tool' and \"tool_connections\".\"transport\" not in ('chat_sdk', 'runtime_auth'))\n or\n (\"tool_connections\".\"connection_purpose\" = 'channel' and (\"tool_connections\".\"transport\" = 'chat_sdk' or (\"tool_connections\".\"transport\" = 'rest_api' and \"tool_connections\".\"config\"->>'provider' = 'agentmail')))\n or\n (\"tool_connections\".\"connection_purpose\" = 'ai' and \"tool_connections\".\"transport\" = 'runtime_auth')\n )"+ },+ "tool_connections_auth_kind_check": {+ "name": "tool_connections_auth_kind_check",+ "value": "\"tool_connections\".\"auth_kind\" in ('oauth', 'api_key', 'none')"+ },+ "tool_connections_credential_source_check": {+ "name": "tool_connections_credential_source_check",+ "value": "\"tool_connections\".\"credential_source\" in ('paperclip_vault', 'vercel_connect')"+ },+ "tool_connections_credential_source_one_of_check": {+ "name": "tool_connections_credential_source_one_of_check",+ "value": "(\n (\"tool_connections\".\"credential_source\" = 'paperclip_vault' and \"tool_connections\".\"external_credential\" is null)\n or\n (\"tool_connections\".\"credential_source\" = 'vercel_connect' and \"tool_connections\".\"external_credential\" is not null and jsonb_array_length(\"tool_connections\".\"credential_refs\") = 0 and jsonb_array_length(\"tool_connections\".\"credential_secret_refs\") = 0)\n )"+ },+ "tool_connections_credential_policy_check": {+ "name": "tool_connections_credential_policy_check",+ "value": "\"tool_connections\".\"credential_policy\" in ('shared', 'per_user', 'per_user_with_fallback', 'per_agent')"+ }+ },+ "isRLSEnabled": false+ },+ "public.tool_gateway_rate_limit_counters": {+ "name": "tool_gateway_rate_limit_counters",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "counter_key": {+ "name": "counter_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "window_start_at": {+ "name": "window_start_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "window_ms": {+ "name": "window_ms",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "limit": {+ "name": "limit",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "count": {+ "name": "count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "reset_at": {+ "name": "reset_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "tool_gateway_rate_limit_counters_company_idx": {+ "name": "tool_gateway_rate_limit_counters_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_gateway_rate_limit_counters_window_uq": {+ "name": "tool_gateway_rate_limit_counters_window_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "counter_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "window_start_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tool_gateway_rate_limit_counters_company_id_companies_id_fk": {+ "name": "tool_gateway_rate_limit_counters_company_id_companies_id_fk",+ "tableFrom": "tool_gateway_rate_limit_counters",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.tool_gateway_sessions": {+ "name": "tool_gateway_sessions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "project_id": {+ "name": "project_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "gateway_id": {+ "name": "gateway_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "gateway_token_id": {+ "name": "gateway_token_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "gateway_public_id": {+ "name": "gateway_public_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_subject_type": {+ "name": "client_subject_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_subject_id": {+ "name": "client_subject_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_name": {+ "name": "client_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "mcp_session_id": {+ "name": "mcp_session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "correlation_id": {+ "name": "correlation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "token_hash": {+ "name": "token_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "last_used_at": {+ "name": "last_used_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "revoked_at": {+ "name": "revoked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "tool_gateway_sessions_token_hash_uq": {+ "name": "tool_gateway_sessions_token_hash_uq",+ "columns": [+ {+ "expression": "token_hash",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_gateway_sessions_company_agent_idx": {+ "name": "tool_gateway_sessions_company_agent_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_gateway_sessions_company_expires_idx": {+ "name": "tool_gateway_sessions_company_expires_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_gateway_sessions_run_idx": {+ "name": "tool_gateway_sessions_run_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_gateway_sessions_issue_idx": {+ "name": "tool_gateway_sessions_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_gateway_sessions_gateway_idx": {+ "name": "tool_gateway_sessions_gateway_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "gateway_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tool_gateway_sessions_company_id_companies_id_fk": {+ "name": "tool_gateway_sessions_company_id_companies_id_fk",+ "tableFrom": "tool_gateway_sessions",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_gateway_sessions_agent_id_agents_id_fk": {+ "name": "tool_gateway_sessions_agent_id_agents_id_fk",+ "tableFrom": "tool_gateway_sessions",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_gateway_sessions_run_id_heartbeat_runs_id_fk": {+ "name": "tool_gateway_sessions_run_id_heartbeat_runs_id_fk",+ "tableFrom": "tool_gateway_sessions",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_gateway_sessions_issue_id_issues_id_fk": {+ "name": "tool_gateway_sessions_issue_id_issues_id_fk",+ "tableFrom": "tool_gateway_sessions",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_gateway_sessions_project_id_projects_id_fk": {+ "name": "tool_gateway_sessions_project_id_projects_id_fk",+ "tableFrom": "tool_gateway_sessions",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_gateway_sessions_gateway_id_tool_mcp_gateways_id_fk": {+ "name": "tool_gateway_sessions_gateway_id_tool_mcp_gateways_id_fk",+ "tableFrom": "tool_gateway_sessions",+ "tableTo": "tool_mcp_gateways",+ "columnsFrom": [+ "gateway_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_gateway_sessions_gateway_token_id_tool_mcp_gateway_tokens_id_fk": {+ "name": "tool_gateway_sessions_gateway_token_id_tool_mcp_gateway_tokens_id_fk",+ "tableFrom": "tool_gateway_sessions",+ "tableTo": "tool_mcp_gateway_tokens",+ "columnsFrom": [+ "gateway_token_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.tool_invocations": {+ "name": "tool_invocations",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "idempotency_key": {+ "name": "idempotency_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "actor_type": {+ "name": "actor_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'system'"+ },+ "actor_id": {+ "name": "actor_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "gateway_id": {+ "name": "gateway_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "gateway_token_id": {+ "name": "gateway_token_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "gateway_public_id": {+ "name": "gateway_public_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_subject_type": {+ "name": "client_subject_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_subject_id": {+ "name": "client_subject_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_name": {+ "name": "client_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "mcp_session_id": {+ "name": "mcp_session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "correlation_id": {+ "name": "correlation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "application_id": {+ "name": "application_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "connection_id": {+ "name": "connection_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "catalog_entry_id": {+ "name": "catalog_entry_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "catalog_version_hash": {+ "name": "catalog_version_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "catalog_schema_hash": {+ "name": "catalog_schema_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider_type": {+ "name": "provider_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "application_key": {+ "name": "application_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "upstream_tool_name": {+ "name": "upstream_tool_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "risk_level": {+ "name": "risk_level",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "tool_name": {+ "name": "tool_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "arguments_hash": {+ "name": "arguments_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "arguments_summary": {+ "name": "arguments_summary",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "policy_decision": {+ "name": "policy_decision",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "matched_policy_ids": {+ "name": "matched_policy_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "policy_explanation": {+ "name": "policy_explanation",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "credential_scope_summary": {+ "name": "credential_scope_summary",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "header_policy_summary": {+ "name": "header_policy_summary",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "approval_state": {+ "name": "approval_state",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'not_required'"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "upstream_request_id": {+ "name": "upstream_request_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "result_hash": {+ "name": "result_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "result_summary": {+ "name": "result_summary",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "result_size_bytes": {+ "name": "result_size_bytes",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "result_artifact_id": {+ "name": "result_artifact_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "error_code": {+ "name": "error_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "error_message": {+ "name": "error_message",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "tool_invocations_company_created_idx": {+ "name": "tool_invocations_company_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_invocations_run_idx": {+ "name": "tool_invocations_run_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_invocations_issue_idx": {+ "name": "tool_invocations_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_invocations_gateway_idx": {+ "name": "tool_invocations_gateway_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "gateway_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_invocations_company_idempotency_uq": {+ "name": "tool_invocations_company_idempotency_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "idempotency_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tool_invocations_company_id_companies_id_fk": {+ "name": "tool_invocations_company_id_companies_id_fk",+ "tableFrom": "tool_invocations",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_invocations_agent_id_agents_id_fk": {+ "name": "tool_invocations_agent_id_agents_id_fk",+ "tableFrom": "tool_invocations",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_invocations_issue_id_issues_id_fk": {+ "name": "tool_invocations_issue_id_issues_id_fk",+ "tableFrom": "tool_invocations",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_invocations_run_id_heartbeat_runs_id_fk": {+ "name": "tool_invocations_run_id_heartbeat_runs_id_fk",+ "tableFrom": "tool_invocations",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_invocations_gateway_id_tool_mcp_gateways_id_fk": {+ "name": "tool_invocations_gateway_id_tool_mcp_gateways_id_fk",+ "tableFrom": "tool_invocations",+ "tableTo": "tool_mcp_gateways",+ "columnsFrom": [+ "gateway_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_invocations_gateway_token_id_tool_mcp_gateway_tokens_id_fk": {+ "name": "tool_invocations_gateway_token_id_tool_mcp_gateway_tokens_id_fk",+ "tableFrom": "tool_invocations",+ "tableTo": "tool_mcp_gateway_tokens",+ "columnsFrom": [+ "gateway_token_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_invocations_application_id_tool_applications_id_fk": {+ "name": "tool_invocations_application_id_tool_applications_id_fk",+ "tableFrom": "tool_invocations",+ "tableTo": "tool_applications",+ "columnsFrom": [+ "application_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_invocations_connection_id_tool_connections_id_fk": {+ "name": "tool_invocations_connection_id_tool_connections_id_fk",+ "tableFrom": "tool_invocations",+ "tableTo": "tool_connections",+ "columnsFrom": [+ "connection_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_invocations_catalog_entry_id_tool_catalog_entries_id_fk": {+ "name": "tool_invocations_catalog_entry_id_tool_catalog_entries_id_fk",+ "tableFrom": "tool_invocations",+ "tableTo": "tool_catalog_entries",+ "columnsFrom": [+ "catalog_entry_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.tool_mcp_gateway_tokens": {+ "name": "tool_mcp_gateway_tokens",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "gateway_id": {+ "name": "gateway_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "token_hash": {+ "name": "token_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "token_prefix": {+ "name": "token_prefix",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "subject_type": {+ "name": "subject_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'gateway_client'"+ },+ "subject_id": {+ "name": "subject_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_label": {+ "name": "client_label",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "owner_note": {+ "name": "owner_note",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "allowed_actions": {+ "name": "allowed_actions",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[\"tools/list\",\"tools/call\"]'::jsonb"+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "expiry_override_reason": {+ "name": "expiry_override_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "expiry_override_by_user_id": {+ "name": "expiry_override_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "expiry_override_by_agent_id": {+ "name": "expiry_override_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "expiry_override_at": {+ "name": "expiry_override_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_used_at": {+ "name": "last_used_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "revoked_at": {+ "name": "revoked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "tool_mcp_gateway_tokens_token_hash_uq": {+ "name": "tool_mcp_gateway_tokens_token_hash_uq",+ "columns": [+ {+ "expression": "token_hash",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_mcp_gateway_tokens_gateway_idx": {+ "name": "tool_mcp_gateway_tokens_gateway_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "gateway_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_mcp_gateway_tokens_subject_idx": {+ "name": "tool_mcp_gateway_tokens_subject_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_mcp_gateway_tokens_company_expires_idx": {+ "name": "tool_mcp_gateway_tokens_company_expires_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tool_mcp_gateway_tokens_company_id_companies_id_fk": {+ "name": "tool_mcp_gateway_tokens_company_id_companies_id_fk",+ "tableFrom": "tool_mcp_gateway_tokens",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_mcp_gateway_tokens_gateway_id_tool_mcp_gateways_id_fk": {+ "name": "tool_mcp_gateway_tokens_gateway_id_tool_mcp_gateways_id_fk",+ "tableFrom": "tool_mcp_gateway_tokens",+ "tableTo": "tool_mcp_gateways",+ "columnsFrom": [+ "gateway_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_mcp_gateway_tokens_expiry_override_by_agent_id_agents_id_fk": {+ "name": "tool_mcp_gateway_tokens_expiry_override_by_agent_id_agents_id_fk",+ "tableFrom": "tool_mcp_gateway_tokens",+ "tableTo": "agents",+ "columnsFrom": [+ "expiry_override_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_mcp_gateway_tokens_created_by_agent_id_agents_id_fk": {+ "name": "tool_mcp_gateway_tokens_created_by_agent_id_agents_id_fk",+ "tableFrom": "tool_mcp_gateway_tokens",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.tool_mcp_gateways": {+ "name": "tool_mcp_gateways",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "gateway_public_id": {+ "name": "gateway_public_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'gw_' || replace(gen_random_uuid()::text, '-', '')"+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "slug": {+ "name": "slug",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "display_slug": {+ "name": "display_slug",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "profile_id": {+ "name": "profile_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "default_profile_mode": {+ "name": "default_profile_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'gateway_only'"+ },+ "context_scope_type": {+ "name": "context_scope_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'none'"+ },+ "context_scope_id": {+ "name": "context_scope_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "project_id": {+ "name": "project_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "approval_issue_id": {+ "name": "approval_issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "auth_config": {+ "name": "auth_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{\"version\":1,\"bearer\":{\"enabled\":true,\"tokenPrefix\":\"pcgw\",\"defaultTtlSeconds\":7776000,\"requireFiniteExpiry\":true,\"longLivedTokenRequiresOverride\":true},\"oauth\":{\"enabled\":false,\"reservedFor\":\"v1_5\",\"dynamicClientRegistration\":false,\"authorizationCodePkce\":false}}'::jsonb"+ },+ "header_policy": {+ "name": "header_policy",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{\"version\":1,\"callerPassthrough\":{\"enabled\":false,\"allowedHeaders\":[]},\"staticHeaders\":[],\"generatedMetadata\":{\"enabled\":false,\"allowedHeaders\":[]},\"responseHeaders\":{\"forwardMcpRequiredHeaders\":true,\"forwardSafeCacheHeaders\":true}}'::jsonb"+ },+ "metadata_policy": {+ "name": "metadata_policy",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{\"version\":1,\"forwardCompanyId\":false,\"forwardGatewayId\":false,\"forwardProjectId\":false,\"forwardIssueId\":false,\"forwardAgentId\":false,\"forwardRunId\":false,\"forwardCorrelationId\":true}'::jsonb"+ },+ "on_demand_tools_config": {+ "name": "on_demand_tools_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{\"enabled\":false,\"searchToolName\":\"search_tools\",\"runToolName\":\"run_tool\"}'::jsonb"+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "archived_at": {+ "name": "archived_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "tool_mcp_gateways_company_idx": {+ "name": "tool_mcp_gateways_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_mcp_gateways_company_status_idx": {+ "name": "tool_mcp_gateways_company_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_mcp_gateways_profile_idx": {+ "name": "tool_mcp_gateways_profile_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "profile_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_mcp_gateways_public_id_uq": {+ "name": "tool_mcp_gateways_public_id_uq",+ "columns": [+ {+ "expression": "gateway_public_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_mcp_gateways_company_slug_uq": {+ "name": "tool_mcp_gateways_company_slug_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_mcp_gateways_company_name_uq": {+ "name": "tool_mcp_gateways_company_name_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tool_mcp_gateways_company_id_companies_id_fk": {+ "name": "tool_mcp_gateways_company_id_companies_id_fk",+ "tableFrom": "tool_mcp_gateways",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_mcp_gateways_profile_id_tool_profiles_id_fk": {+ "name": "tool_mcp_gateways_profile_id_tool_profiles_id_fk",+ "tableFrom": "tool_mcp_gateways",+ "tableTo": "tool_profiles",+ "columnsFrom": [+ "profile_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "restrict",+ "onUpdate": "no action"+ },+ "tool_mcp_gateways_agent_id_agents_id_fk": {+ "name": "tool_mcp_gateways_agent_id_agents_id_fk",+ "tableFrom": "tool_mcp_gateways",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_mcp_gateways_project_id_projects_id_fk": {+ "name": "tool_mcp_gateways_project_id_projects_id_fk",+ "tableFrom": "tool_mcp_gateways",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_mcp_gateways_issue_id_issues_id_fk": {+ "name": "tool_mcp_gateways_issue_id_issues_id_fk",+ "tableFrom": "tool_mcp_gateways",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_mcp_gateways_approval_issue_id_issues_id_fk": {+ "name": "tool_mcp_gateways_approval_issue_id_issues_id_fk",+ "tableFrom": "tool_mcp_gateways",+ "tableTo": "issues",+ "columnsFrom": [+ "approval_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_mcp_gateways_created_by_agent_id_agents_id_fk": {+ "name": "tool_mcp_gateways_created_by_agent_id_agents_id_fk",+ "tableFrom": "tool_mcp_gateways",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.tool_oauth_states": {+ "name": "tool_oauth_states",+ "schema": "",+ "columns": {+ "state": {+ "name": "state",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "connection_id": {+ "name": "connection_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "code_verifier": {+ "name": "code_verifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_actor_type": {+ "name": "created_by_actor_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_actor_id": {+ "name": "created_by_actor_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_session_id": {+ "name": "created_by_session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "subject_user_id": {+ "name": "subject_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "subject_agent_id": {+ "name": "subject_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "requested_scopes": {+ "name": "requested_scopes",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "return_to": {+ "name": "return_to",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "interaction_id": {+ "name": "interaction_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "tool_oauth_states_company_idx": {+ "name": "tool_oauth_states_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_oauth_states_connection_idx": {+ "name": "tool_oauth_states_connection_idx",+ "columns": [+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_oauth_states_actor_idx": {+ "name": "tool_oauth_states_actor_idx",+ "columns": [+ {+ "expression": "created_by_actor_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_by_actor_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_oauth_states_subject_agent_idx": {+ "name": "tool_oauth_states_subject_agent_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_oauth_states_expires_at_idx": {+ "name": "tool_oauth_states_expires_at_idx",+ "columns": [+ {+ "expression": "expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tool_oauth_states_company_id_companies_id_fk": {+ "name": "tool_oauth_states_company_id_companies_id_fk",+ "tableFrom": "tool_oauth_states",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_oauth_states_connection_id_tool_connections_id_fk": {+ "name": "tool_oauth_states_connection_id_tool_connections_id_fk",+ "tableFrom": "tool_oauth_states",+ "tableTo": "tool_connections",+ "columnsFrom": [+ "connection_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_oauth_states_subject_agent_id_agents_id_fk": {+ "name": "tool_oauth_states_subject_agent_id_agents_id_fk",+ "tableFrom": "tool_oauth_states",+ "tableTo": "agents",+ "columnsFrom": [+ "subject_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.tool_policies": {+ "name": "tool_policies",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "policy_type": {+ "name": "policy_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "priority": {+ "name": "priority",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 100+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "selectors": {+ "name": "selectors",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "conditions": {+ "name": "conditions",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "tool_policies_company_enabled_idx": {+ "name": "tool_policies_company_enabled_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "enabled",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_policies_company_type_idx": {+ "name": "tool_policies_company_type_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "policy_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_policies_company_name_uq": {+ "name": "tool_policies_company_name_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tool_policies_company_id_companies_id_fk": {+ "name": "tool_policies_company_id_companies_id_fk",+ "tableFrom": "tool_policies",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_policies_created_by_agent_id_agents_id_fk": {+ "name": "tool_policies_created_by_agent_id_agents_id_fk",+ "tableFrom": "tool_policies",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.tool_profile_bindings": {+ "name": "tool_profile_bindings",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "profile_id": {+ "name": "profile_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "target_type": {+ "name": "target_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "target_id": {+ "name": "target_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "priority": {+ "name": "priority",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 100+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "tool_profile_bindings_company_target_idx": {+ "name": "tool_profile_bindings_company_target_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_profile_bindings_target_profile_uq": {+ "name": "tool_profile_bindings_target_profile_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "profile_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tool_profile_bindings_company_id_companies_id_fk": {+ "name": "tool_profile_bindings_company_id_companies_id_fk",+ "tableFrom": "tool_profile_bindings",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_profile_bindings_profile_id_tool_profiles_id_fk": {+ "name": "tool_profile_bindings_profile_id_tool_profiles_id_fk",+ "tableFrom": "tool_profile_bindings",+ "tableTo": "tool_profiles",+ "columnsFrom": [+ "profile_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_profile_bindings_created_by_agent_id_agents_id_fk": {+ "name": "tool_profile_bindings_created_by_agent_id_agents_id_fk",+ "tableFrom": "tool_profile_bindings",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.tool_profile_entries": {+ "name": "tool_profile_entries",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "profile_id": {+ "name": "profile_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "selector_type": {+ "name": "selector_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "effect": {+ "name": "effect",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'include'"+ },+ "application_id": {+ "name": "application_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "connection_id": {+ "name": "connection_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "catalog_entry_id": {+ "name": "catalog_entry_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "tool_name": {+ "name": "tool_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "risk_level": {+ "name": "risk_level",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "conditions": {+ "name": "conditions",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "tool_profile_entries_company_profile_idx": {+ "name": "tool_profile_entries_company_profile_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "profile_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_profile_entries_application_idx": {+ "name": "tool_profile_entries_application_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "application_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_profile_entries_connection_idx": {+ "name": "tool_profile_entries_connection_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_profile_entries_catalog_entry_idx": {+ "name": "tool_profile_entries_catalog_entry_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "catalog_entry_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tool_profile_entries_company_id_companies_id_fk": {+ "name": "tool_profile_entries_company_id_companies_id_fk",+ "tableFrom": "tool_profile_entries",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_profile_entries_profile_id_tool_profiles_id_fk": {+ "name": "tool_profile_entries_profile_id_tool_profiles_id_fk",+ "tableFrom": "tool_profile_entries",+ "tableTo": "tool_profiles",+ "columnsFrom": [+ "profile_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_profile_entries_application_id_tool_applications_id_fk": {+ "name": "tool_profile_entries_application_id_tool_applications_id_fk",+ "tableFrom": "tool_profile_entries",+ "tableTo": "tool_applications",+ "columnsFrom": [+ "application_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_profile_entries_connection_id_tool_connections_id_fk": {+ "name": "tool_profile_entries_connection_id_tool_connections_id_fk",+ "tableFrom": "tool_profile_entries",+ "tableTo": "tool_connections",+ "columnsFrom": [+ "connection_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_profile_entries_catalog_entry_id_tool_catalog_entries_id_fk": {+ "name": "tool_profile_entries_catalog_entry_id_tool_catalog_entries_id_fk",+ "tableFrom": "tool_profile_entries",+ "tableTo": "tool_catalog_entries",+ "columnsFrom": [+ "catalog_entry_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.tool_profiles": {+ "name": "tool_profiles",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "profile_key": {+ "name": "profile_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "default_action": {+ "name": "default_action",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'deny'"+ },+ "new_tools_reviewed_at": {+ "name": "new_tools_reviewed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "tool_profiles_company_status_idx": {+ "name": "tool_profiles_company_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_profiles_company_key_uq": {+ "name": "tool_profiles_company_key_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "profile_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_profiles_company_name_uq": {+ "name": "tool_profiles_company_name_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tool_profiles_company_id_companies_id_fk": {+ "name": "tool_profiles_company_id_companies_id_fk",+ "tableFrom": "tool_profiles",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.tool_rate_limit_counters": {+ "name": "tool_rate_limit_counters",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "policy_id": {+ "name": "policy_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "counter_key": {+ "name": "counter_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope_type": {+ "name": "scope_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope_id": {+ "name": "scope_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "window_kind": {+ "name": "window_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "window_start_at": {+ "name": "window_start_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "limit": {+ "name": "limit",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "remaining": {+ "name": "remaining",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "reset_at": {+ "name": "reset_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "tool_rate_limit_counters_company_idx": {+ "name": "tool_rate_limit_counters_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_rate_limit_counters_window_uq": {+ "name": "tool_rate_limit_counters_window_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "policy_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "counter_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "window_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "window_start_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tool_rate_limit_counters_company_id_companies_id_fk": {+ "name": "tool_rate_limit_counters_company_id_companies_id_fk",+ "tableFrom": "tool_rate_limit_counters",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_rate_limit_counters_policy_id_tool_policies_id_fk": {+ "name": "tool_rate_limit_counters_policy_id_tool_policies_id_fk",+ "tableFrom": "tool_rate_limit_counters",+ "tableTo": "tool_policies",+ "columnsFrom": [+ "policy_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.tool_runtime_metric_counters": {+ "name": "tool_runtime_metric_counters",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "metric": {+ "name": "metric",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "bucket_start_at": {+ "name": "bucket_start_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "count": {+ "name": "count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "tool_runtime_metric_counters_company_metric_idx": {+ "name": "tool_runtime_metric_counters_company_metric_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "metric",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "bucket_start_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_runtime_metric_counters_bucket_uq": {+ "name": "tool_runtime_metric_counters_bucket_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "metric",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "bucket_start_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tool_runtime_metric_counters_company_id_companies_id_fk": {+ "name": "tool_runtime_metric_counters_company_id_companies_id_fk",+ "tableFrom": "tool_runtime_metric_counters",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.tool_runtime_slots": {+ "name": "tool_runtime_slots",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "application_id": {+ "name": "application_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "connection_id": {+ "name": "connection_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "project_workspace_id": {+ "name": "project_workspace_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "execution_workspace_id": {+ "name": "execution_workspace_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "owner_scope_type": {+ "name": "owner_scope_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'connection'"+ },+ "owner_scope_id": {+ "name": "owner_scope_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "runtime_kind": {+ "name": "runtime_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'local_stdio'"+ },+ "slot_key": {+ "name": "slot_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'stopped'"+ },+ "reuse_key": {+ "name": "reuse_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_scope": {+ "name": "workspace_scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "credential_scope_hash": {+ "name": "credential_scope_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider_ref": {+ "name": "provider_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "process_id": {+ "name": "process_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "command_template_key": {+ "name": "command_template_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "health_status": {+ "name": "health_status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'unchecked'"+ },+ "health_message": {+ "name": "health_message",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "last_health_check_at": {+ "name": "last_health_check_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_started_at": {+ "name": "last_started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "stopped_at": {+ "name": "stopped_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_used_at": {+ "name": "last_used_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "idle_expires_at": {+ "name": "idle_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "idle_deadline_at": {+ "name": "idle_deadline_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "tool_runtime_slots_company_idx": {+ "name": "tool_runtime_slots_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_runtime_slots_connection_idx": {+ "name": "tool_runtime_slots_connection_idx",+ "columns": [+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_runtime_slots_execution_workspace_idx": {+ "name": "tool_runtime_slots_execution_workspace_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "execution_workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_runtime_slots_slot_key_uq": {+ "name": "tool_runtime_slots_slot_key_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "slot_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tool_runtime_slots_company_id_companies_id_fk": {+ "name": "tool_runtime_slots_company_id_companies_id_fk",+ "tableFrom": "tool_runtime_slots",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_runtime_slots_application_id_tool_applications_id_fk": {+ "name": "tool_runtime_slots_application_id_tool_applications_id_fk",+ "tableFrom": "tool_runtime_slots",+ "tableTo": "tool_applications",+ "columnsFrom": [+ "application_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_runtime_slots_connection_id_tool_connections_id_fk": {+ "name": "tool_runtime_slots_connection_id_tool_connections_id_fk",+ "tableFrom": "tool_runtime_slots",+ "tableTo": "tool_connections",+ "columnsFrom": [+ "connection_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_runtime_slots_project_workspace_id_project_workspaces_id_fk": {+ "name": "tool_runtime_slots_project_workspace_id_project_workspaces_id_fk",+ "tableFrom": "tool_runtime_slots",+ "tableTo": "project_workspaces",+ "columnsFrom": [+ "project_workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_runtime_slots_execution_workspace_id_execution_workspaces_id_fk": {+ "name": "tool_runtime_slots_execution_workspace_id_execution_workspaces_id_fk",+ "tableFrom": "tool_runtime_slots",+ "tableTo": "execution_workspaces",+ "columnsFrom": [+ "execution_workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tool_runtime_slots_issue_id_issues_id_fk": {+ "name": "tool_runtime_slots_issue_id_issues_id_fk",+ "tableFrom": "tool_runtime_slots",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.tool_stdio_command_templates": {+ "name": "tool_stdio_command_templates",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "template_key": {+ "name": "template_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "command": {+ "name": "command",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "args": {+ "name": "args",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "env_keys": {+ "name": "env_keys",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "tools": {+ "name": "tools",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "disabled_at": {+ "name": "disabled_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "tool_stdio_command_templates_company_idx": {+ "name": "tool_stdio_command_templates_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_stdio_command_templates_company_status_idx": {+ "name": "tool_stdio_command_templates_company_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tool_stdio_command_templates_company_key_uq": {+ "name": "tool_stdio_command_templates_company_key_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "template_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tool_stdio_command_templates_company_id_companies_id_fk": {+ "name": "tool_stdio_command_templates_company_id_companies_id_fk",+ "tableFrom": "tool_stdio_command_templates",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tool_stdio_command_templates_created_by_agent_id_agents_id_fk": {+ "name": "tool_stdio_command_templates_created_by_agent_id_agents_id_fk",+ "tableFrom": "tool_stdio_command_templates",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_inbox_agent_policies": {+ "name": "user_inbox_agent_policies",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "mode": {+ "name": "mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'open'"+ },+ "allowed_agent_ids": {+ "name": "allowed_agent_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_inbox_agent_policies_company_user_uq": {+ "name": "user_inbox_agent_policies_company_user_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_inbox_agent_policies_allowed_agent_ids_idx": {+ "name": "user_inbox_agent_policies_allowed_agent_ids_idx",+ "columns": [+ {+ "expression": "allowed_agent_ids",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "gin",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_inbox_agent_policies_company_id_companies_id_fk": {+ "name": "user_inbox_agent_policies_company_id_companies_id_fk",+ "tableFrom": "user_inbox_agent_policies",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "user_inbox_agent_policies_mode_check": {+ "name": "user_inbox_agent_policies_mode_check",+ "value": "\"user_inbox_agent_policies\".\"mode\" in ('open', 'allowlist', 'disabled')"+ }+ },+ "isRLSEnabled": false+ },+ "public.user_secret_declarations": {+ "name": "user_secret_declarations",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_secret_definition_id": {+ "name": "user_secret_definition_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "target_type": {+ "name": "target_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "target_id": {+ "name": "target_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "config_path": {+ "name": "config_path",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "env_key": {+ "name": "env_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "version_selector": {+ "name": "version_selector",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'latest'"+ },+ "required": {+ "name": "required",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "allow_missing_override": {+ "name": "allow_missing_override",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "label": {+ "name": "label",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_secret_declarations_company_idx": {+ "name": "user_secret_declarations_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_secret_declarations_definition_idx": {+ "name": "user_secret_declarations_definition_idx",+ "columns": [+ {+ "expression": "user_secret_definition_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_secret_declarations_target_idx": {+ "name": "user_secret_declarations_target_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_secret_declarations_company_required_idx": {+ "name": "user_secret_declarations_company_required_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "required",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_secret_declarations_target_path_uq": {+ "name": "user_secret_declarations_target_path_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "config_path",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_secret_declarations_required_override_idx": {+ "name": "user_secret_declarations_required_override_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "allow_missing_override",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"user_secret_declarations\".\"allow_missing_override\" = true",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_secret_declarations_company_id_companies_id_fk": {+ "name": "user_secret_declarations_company_id_companies_id_fk",+ "tableFrom": "user_secret_declarations",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_secret_declarations_user_secret_definition_id_user_secret_definitions_id_fk": {+ "name": "user_secret_declarations_user_secret_definition_id_user_secret_definitions_id_fk",+ "tableFrom": "user_secret_declarations",+ "tableTo": "user_secret_definitions",+ "columnsFrom": [+ "user_secret_definition_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_secret_definitions": {+ "name": "user_secret_definitions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'local_encrypted'"+ },+ "managed_mode": {+ "name": "managed_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'paperclip_managed'"+ },+ "provider_config_id": {+ "name": "provider_config_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "provider_metadata": {+ "name": "provider_metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "usage_guidance": {+ "name": "usage_guidance",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "updated_by_agent_id": {+ "name": "updated_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "updated_by_user_id": {+ "name": "updated_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_secret_definitions_company_status_idx": {+ "name": "user_secret_definitions_company_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_secret_definitions_company_provider_idx": {+ "name": "user_secret_definitions_company_provider_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_secret_definitions_provider_config_idx": {+ "name": "user_secret_definitions_provider_config_idx",+ "columns": [+ {+ "expression": "provider_config_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_secret_definitions_company_key_uq": {+ "name": "user_secret_definitions_company_key_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"user_secret_definitions\".\"deleted_at\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_secret_definitions_company_id_companies_id_fk": {+ "name": "user_secret_definitions_company_id_companies_id_fk",+ "tableFrom": "user_secret_definitions",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_secret_definitions_provider_config_id_company_secret_provider_configs_id_fk": {+ "name": "user_secret_definitions_provider_config_id_company_secret_provider_configs_id_fk",+ "tableFrom": "user_secret_definitions",+ "tableTo": "company_secret_provider_configs",+ "columnsFrom": [+ "provider_config_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "user_secret_definitions_created_by_agent_id_agents_id_fk": {+ "name": "user_secret_definitions_created_by_agent_id_agents_id_fk",+ "tableFrom": "user_secret_definitions",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "user_secret_definitions_updated_by_agent_id_agents_id_fk": {+ "name": "user_secret_definitions_updated_by_agent_id_agents_id_fk",+ "tableFrom": "user_secret_definitions",+ "tableTo": "agents",+ "columnsFrom": [+ "updated_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_sidebar_preferences": {+ "name": "user_sidebar_preferences",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "company_order": {+ "name": "company_order",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_sidebar_preferences_user_uq": {+ "name": "user_sidebar_preferences_user_uq",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.work_assessments": {+ "name": "work_assessments",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "turn_id": {+ "name": "turn_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "contract_id": {+ "name": "contract_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "result_id": {+ "name": "result_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "trigger_kind": {+ "name": "trigger_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "trigger_ref": {+ "name": "trigger_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "trigger_capability": {+ "name": "trigger_capability",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "trigger_actor_company_id": {+ "name": "trigger_actor_company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "prior_issue_status": {+ "name": "prior_issue_status",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "prior_status_version": {+ "name": "prior_status_version",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true+ },+ "prior_decision_id": {+ "name": "prior_decision_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "policy_version": {+ "name": "policy_version",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "assessment_json": {+ "name": "assessment_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "input_digest": {+ "name": "input_digest",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "supersedes_assessment_id": {+ "name": "supersedes_assessment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "work_assessments_company_issue_input_uq": {+ "name": "work_assessments_company_issue_input_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "input_digest",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "work_assessments_company_id_companies_id_fk": {+ "name": "work_assessments_company_id_companies_id_fk",+ "tableFrom": "work_assessments",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "work_assessments_trigger_actor_company_id_companies_id_fk": {+ "name": "work_assessments_trigger_actor_company_id_companies_id_fk",+ "tableFrom": "work_assessments",+ "tableTo": "companies",+ "columnsFrom": [+ "trigger_actor_company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "work_assessments_issue_company_fk": {+ "name": "work_assessments_issue_company_fk",+ "tableFrom": "work_assessments",+ "tableTo": "issues",+ "columnsFrom": [+ "company_id",+ "issue_id"+ ],+ "columnsTo": [+ "company_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "work_assessments_run_owner_fk": {+ "name": "work_assessments_run_owner_fk",+ "tableFrom": "work_assessments",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "company_id",+ "issue_id",+ "run_id"+ ],+ "columnsTo": [+ "company_id",+ "native_issue_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "work_assessments_contract_owner_fk": {+ "name": "work_assessments_contract_owner_fk",+ "tableFrom": "work_assessments",+ "tableTo": "completion_contracts",+ "columnsFrom": [+ "company_id",+ "issue_id",+ "contract_id"+ ],+ "columnsTo": [+ "company_id",+ "issue_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "work_assessments_result_owner_fk": {+ "name": "work_assessments_result_owner_fk",+ "tableFrom": "work_assessments",+ "tableTo": "native_run_results",+ "columnsFrom": [+ "company_id",+ "issue_id",+ "run_id",+ "result_id"+ ],+ "columnsTo": [+ "company_id",+ "issue_id",+ "run_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "work_assessments_supersedes_owner_fk": {+ "name": "work_assessments_supersedes_owner_fk",+ "tableFrom": "work_assessments",+ "tableTo": "work_assessments",+ "columnsFrom": [+ "company_id",+ "issue_id",+ "run_id",+ "supersedes_assessment_id"+ ],+ "columnsTo": [+ "company_id",+ "issue_id",+ "run_id",+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "work_assessments_company_issue_run_id_uq": {+ "name": "work_assessments_company_issue_run_id_uq",+ "nullsNotDistinct": false,+ "columns": [+ "company_id",+ "issue_id",+ "run_id",+ "id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "work_assessments_trigger_actor_company_check": {+ "name": "work_assessments_trigger_actor_company_check",+ "value": "\"work_assessments\".\"trigger_actor_company_id\" = \"work_assessments\".\"company_id\""+ }+ },+ "isRLSEnabled": false+ },+ "public.workspace_operations": {+ "name": "workspace_operations",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "execution_workspace_id": {+ "name": "execution_workspace_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "heartbeat_run_id": {+ "name": "heartbeat_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "phase": {+ "name": "phase",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "command": {+ "name": "command",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "cwd": {+ "name": "cwd",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'running'"+ },+ "exit_code": {+ "name": "exit_code",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "log_store": {+ "name": "log_store",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "log_ref": {+ "name": "log_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "log_bytes": {+ "name": "log_bytes",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false+ },+ "log_sha256": {+ "name": "log_sha256",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "log_compressed": {+ "name": "log_compressed",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "stdout_excerpt": {+ "name": "stdout_excerpt",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "stderr_excerpt": {+ "name": "stderr_excerpt",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "finished_at": {+ "name": "finished_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "workspace_operations_company_run_started_idx": {+ "name": "workspace_operations_company_run_started_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "heartbeat_run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "started_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspace_operations_company_workspace_started_idx": {+ "name": "workspace_operations_company_workspace_started_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "execution_workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "started_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspace_operations_company_workspace_issue_started_idx": {+ "name": "workspace_operations_company_workspace_issue_started_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "execution_workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "started_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "workspace_operations_company_id_companies_id_fk": {+ "name": "workspace_operations_company_id_companies_id_fk",+ "tableFrom": "workspace_operations",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "workspace_operations_execution_workspace_id_execution_workspaces_id_fk": {+ "name": "workspace_operations_execution_workspace_id_execution_workspaces_id_fk",+ "tableFrom": "workspace_operations",+ "tableTo": "execution_workspaces",+ "columnsFrom": [+ "execution_workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "workspace_operations_heartbeat_run_id_heartbeat_runs_id_fk": {+ "name": "workspace_operations_heartbeat_run_id_heartbeat_runs_id_fk",+ "tableFrom": "workspace_operations",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "heartbeat_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "workspace_operations_issue_id_issues_id_fk": {+ "name": "workspace_operations_issue_id_issues_id_fk",+ "tableFrom": "workspace_operations",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.workspace_runtime_services": {+ "name": "workspace_runtime_services",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "project_workspace_id": {+ "name": "project_workspace_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "execution_workspace_id": {+ "name": "execution_workspace_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "scope_type": {+ "name": "scope_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope_id": {+ "name": "scope_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "service_name": {+ "name": "service_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "lifecycle": {+ "name": "lifecycle",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "reuse_key": {+ "name": "reuse_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "command": {+ "name": "command",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "cwd": {+ "name": "cwd",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "port": {+ "name": "port",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider_ref": {+ "name": "provider_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "owner_agent_id": {+ "name": "owner_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "started_by_run_id": {+ "name": "started_by_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "last_used_at": {+ "name": "last_used_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "stopped_at": {+ "name": "stopped_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "stop_policy": {+ "name": "stop_policy",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "exposure": {+ "name": "exposure",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "exposure_handle": {+ "name": "exposure_handle",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "backend_url": {+ "name": "backend_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "health_status": {+ "name": "health_status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'unknown'"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "workspace_runtime_services_company_workspace_status_idx": {+ "name": "workspace_runtime_services_company_workspace_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "project_workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspace_runtime_services_company_execution_workspace_status_idx": {+ "name": "workspace_runtime_services_company_execution_workspace_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "execution_workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspace_runtime_services_company_project_status_idx": {+ "name": "workspace_runtime_services_company_project_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspace_runtime_services_run_idx": {+ "name": "workspace_runtime_services_run_idx",+ "columns": [+ {+ "expression": "started_by_run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspace_runtime_services_company_updated_idx": {+ "name": "workspace_runtime_services_company_updated_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "workspace_runtime_services_company_id_companies_id_fk": {+ "name": "workspace_runtime_services_company_id_companies_id_fk",+ "tableFrom": "workspace_runtime_services",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "workspace_runtime_services_project_id_projects_id_fk": {+ "name": "workspace_runtime_services_project_id_projects_id_fk",+ "tableFrom": "workspace_runtime_services",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "workspace_runtime_services_project_workspace_id_project_workspaces_id_fk": {+ "name": "workspace_runtime_services_project_workspace_id_project_workspaces_id_fk",+ "tableFrom": "workspace_runtime_services",+ "tableTo": "project_workspaces",+ "columnsFrom": [+ "project_workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "workspace_runtime_services_execution_workspace_id_execution_workspaces_id_fk": {+ "name": "workspace_runtime_services_execution_workspace_id_execution_workspaces_id_fk",+ "tableFrom": "workspace_runtime_services",+ "tableTo": "execution_workspaces",+ "columnsFrom": [+ "execution_workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "workspace_runtime_services_issue_id_issues_id_fk": {+ "name": "workspace_runtime_services_issue_id_issues_id_fk",+ "tableFrom": "workspace_runtime_services",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "workspace_runtime_services_owner_agent_id_agents_id_fk": {+ "name": "workspace_runtime_services_owner_agent_id_agents_id_fk",+ "tableFrom": "workspace_runtime_services",+ "tableTo": "agents",+ "columnsFrom": [+ "owner_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "workspace_runtime_services_started_by_run_id_heartbeat_runs_id_fk": {+ "name": "workspace_runtime_services_started_by_run_id_heartbeat_runs_id_fk",+ "tableFrom": "workspace_runtime_services",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "started_by_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ }+ },+ "enums": {},+ "schemas": {},+ "sequences": {+ "public.chat_telegram_draft_ids": {+ "name": "chat_telegram_draft_ids",+ "schema": "public",+ "increment": "1",+ "startWith": "1",+ "minValue": "1",+ "maxValue": "2147483647",+ "cache": "1",+ "cycle": false+ }+ },+ "roles": {},+ "policies": {},+ "views": {},+ "_meta": {+ "columns": {},+ "schemas": {},+ "tables": {}+ }+}\ No newline at end of filediff --git a/packages/db/src/migrations/meta/_journal.json b/packages/db/src/migrations/meta/_journal.jsonindex 2af6b17ac5..2ee7f0b8e3 100644--- a/packages/db/src/migrations/meta/_journal.json+++ b/packages/db/src/migrations/meta/_journal.json@@ -1947,6 +1947,13 @@"when": 1789390281190,"tag": "0279_tired_deathstrike","breakpoints": true+ },+ {+ "idx": 280,+ "version": "7",+ "when": 1789743991329,+ "tag": "0280_unique_genesis",+ "breakpoints": true}]}\ No newline at end of filediff --git a/packages/db/src/schema/agents.ts b/packages/db/src/schema/agents.tsindex 171eb2fb8a..248c8c8d0b 100644--- a/packages/db/src/schema/agents.ts+++ b/packages/db/src/schema/agents.ts@@ -1,3 +1,4 @@+import type { AgentAppearance } from "@paperclipai/shared";import {type AnyPgColumn,pgTable,@@ -21,6 +22,7 @@ export const agents = pgTable(role: text("role").notNull().default("general"),title: text("title"),icon: text("icon"),+ appearance: jsonb("appearance").$type<AgentAppearance>(),status: text("status").notNull().default("idle"),reportsTo: uuid("reports_to").references((): AnyPgColumn => agents.id),capabilities: text("capabilities"),diff --git a/packages/shared/package.json b/packages/shared/package.jsonindex 8904376a17..77ee18413b 100644--- a/packages/shared/package.json+++ b/packages/shared/package.json@@ -40,16 +40,18 @@"dist"],"scripts": {- "build": "tsc",+ "build": "tsc && mkdir -p dist/cliplab && cp src/cliplab/LICENSE src/cliplab/PROVENANCE.md dist/cliplab/","clean": "rm -rf dist","typecheck": "tsc --noEmit"},"dependencies": {- "zod": "^4.4.3"+ "zod": "^4.4.3",+ "three": "0.185.1"},"devDependencies": {"@types/node": "^24.0.0",- "typescript": "^7.0.2"+ "typescript": "^7.0.2",+ "@types/three": "0.185.4"},"engines": {"node": ">=24.11.0"diff --git a/packages/shared/src/agent-appearance.test.ts b/packages/shared/src/agent-appearance.test.tsnew file mode 100644index 0000000000..36bd71510a--- /dev/null+++ b/packages/shared/src/agent-appearance.test.ts@@ -0,0 +1,29 @@+import { describe, expect, it } from "vitest";+import { AGENT_PALETTE_IDS, agentAppearanceSchema, appearanceForPalette, legacyAgentAppearance, randomAgentAppearance, resolveAgentAppearance, agentAvatarUrl } from "./agent-appearance.js";+import { renderAgentSvg } from "./cliplab/static.js";++describe("agent appearance", () => {+ it("assigns only the 17 permanent cap palettes", () => {+ for (let i = 0; i < 100; i++) expect(AGENT_PALETTE_IDS).toContain(randomAgentAppearance().paletteId);+ expect(agentAppearanceSchema.safeParse({ schemaVersion: 1, characterVersion: "cap-v1", paletteId: "muted-dream" }).success).toBe(false);+ });+ it("preserves a saved appearance and resolves legacy IDs deterministically", () => {+ const appearance = appearanceForPalette("deep-tide");+ expect(resolveAgentAppearance(appearance, "different-id")).toEqual(appearance);+ expect(resolveAgentAppearance(null, "agent-1")).toEqual(legacyAgentAppearance("agent-1"));+ expect(legacyAgentAppearance("agent-1")).toEqual(legacyAgentAppearance("agent-1"));+ expect(agentAvatarUrl(appearance, 24, 2)).toBe("/api/agent-avatars/cap-v1/deep-tide/rest.png?size=24&scale=2");+ });+ it("renders without a browser and preserves logical-size detail at high density", () => {+ const appearance = appearanceForPalette("bubblegum-sky");+ const small = renderAgentSvg(appearance, 16, 2);+ expect(small).toContain('width="32"');+ expect(small).not.toContain('id="agent-face-visible"');+ const eyes = renderAgentSvg(appearance, 24, 2);+ expect(eyes).toContain('width="48"');+ expect(eyes).toContain('id="agent-face-visible"');+ expect(eyes).not.toContain('id="agent-candle-light"');+ expect(renderAgentSvg(appearance, 48, 1)).toContain('id="agent-candle-light"');+ expect(renderAgentSvg(appearance, 24, 2)).toBe(eyes);+ });+});diff --git a/packages/shared/src/agent-appearance.ts b/packages/shared/src/agent-appearance.tsnew file mode 100644index 0000000000..3bfce8499a--- /dev/null+++ b/packages/shared/src/agent-appearance.ts@@ -0,0 +1,52 @@+import { z } from "zod";++export const AGENT_PALETTE_IDS = ["bubblegum-sky", "pink-lemonade", "orchid-peach", "coral-mint", "lime-lagoon", "arctic-blue", "solar-flare", "violet-ember", "deep-tide", "coral-current", "golden-hour", "tangerine-cobalt", "electric-grove", "flamingo-jade", "cherry-pop", "turquoise-cherry", "ultraviolet-tide"] as const;+export type AgentPaletteId = typeof AGENT_PALETTE_IDS[number];+export type CharacterPaletteId = AgentPaletteId | "muted-dream";+export const AGENT_AVATAR_SIZES = [16, 20, 24, 32, 40, 48, 64, 96, 128, 256, 512] as const;+export type AgentAvatarSize = typeof AGENT_AVATAR_SIZES[number];+export const CHARACTER_STATES = ["rest", "idle", "listening", "thinking", "working", "success", "confused", "sleepy", "loading"] as const;+export type CharacterState = typeof CHARACTER_STATES[number];+export const agentAppearanceSchema = z.object({+ schemaVersion: z.literal(1),+ characterVersion: z.literal("cap-v1"),+ paletteId: z.enum(AGENT_PALETTE_IDS),+}).strict();+export type AgentAppearance = z.infer<typeof agentAppearanceSchema>;++export function appearanceForPalette(paletteId: AgentPaletteId): AgentAppearance {+ return { schemaVersion: 1, characterVersion: "cap-v1", paletteId };+}+/** A persisted choice, never randomize while rendering. */+export function randomAgentAppearance(): AgentAppearance {+ const bytes = new Uint32Array(1);+ // Rejection sampling avoids modulo bias.+ const limit = Math.floor(0x100000000 / AGENT_PALETTE_IDS.length) * AGENT_PALETTE_IDS.length;+ do { globalThis.crypto.getRandomValues(bytes); } while (bytes[0] >= limit);+ return appearanceForPalette(AGENT_PALETTE_IDS[bytes[0] % AGENT_PALETTE_IDS.length]);+}+/** Must match the migration: rolling base-31 hash, modulo 17 at every step. */+export function legacyAgentAppearance(id: string): AgentAppearance {+ let hash = 0;+ for (const char of id) hash = (hash * 31 + char.charCodeAt(0)) % AGENT_PALETTE_IDS.length;+ return appearanceForPalette(AGENT_PALETTE_IDS[hash]);+}+export function resolveAgentAppearance(appearance: unknown, id = "agent"): AgentAppearance {+ const parsed = agentAppearanceSchema.safeParse(appearance);+ return parsed.success ? parsed.data : legacyAgentAppearance(id);+}+export function agentAvatarUrl(appearance: AgentAppearance, size: AgentAvatarSize = 512, scale: 1 | 2 = 1, pose: CharacterState = "rest", muted = false): string {+ return `/api/agent-avatars/${appearance.characterVersion}/${muted ? "muted-dream" : appearance.paletteId}/${pose}.png?size=${size}&scale=${scale}`;+}+export function characterStateForAgent(status: string): CharacterState {+ if (status === "running") return "working";+ if (status === "error") return "confused";+ if (status === "paused" || status === "terminated" || status === "pending_approval") return "rest";+ return "idle";+}++/** Hydrate compact agent projections without an additional per-agent request. */+export function withAgentAppearance<T extends { id: string; appearance?: AgentAppearance | null }>(agent: T) {+ const appearance = resolveAgentAppearance(agent.appearance, agent.id);+ return { ...agent, appearance, avatarUrl: agentAvatarUrl(appearance) };+}diff --git a/packages/shared/src/cliplab/LICENSE b/packages/shared/src/cliplab/LICENSEnew file mode 100644index 0000000000..07a83c8665--- /dev/null+++ b/packages/shared/src/cliplab/LICENSE@@ -0,0 +1,22 @@+MIT License++Copyright (c) 2026 Jérémy Perret (bloub, the project this is forked from)+Copyright (c) 2026 Tonio (Cliplab, modifications)++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.diff --git a/packages/shared/src/cliplab/PROVENANCE.md b/packages/shared/src/cliplab/PROVENANCE.mdnew file mode 100644index 0000000000..3c4964707c--- /dev/null+++ b/packages/shared/src/cliplab/PROVENANCE.md@@ -0,0 +1,17 @@+# ClipLab cap-v1++Source: https://github.com/tonio-alucema/cliplab+Commit: a050f7246738db1d0763e286862747633293e2af+License: MIT (see LICENSE). Three.js is MIT licensed.++Paperclip adaptations: ESM extensions, optional graphics backend for Node SVG+snapshots, region-scoped runtime input (with explicit page scope for onboarding),+suspended frame scheduling, and supersampled live textures/canvases. Live-only+framing leaves the versioned static snapshot geometry unchanged. The Vue+studio and media encoders are not included. Keep this version immutable after+release; new artwork or rasterization changes require a new character version.++Palette source: https://cliptoon-color-library.vercel.app/+The 17 assignable colors and Muted dream are frozen as cap-v1 tokens in+ui/src/index.css. Generated palette data is checked by+scripts/sync-agent-palette-tokens.mjs --check.diff --git a/packages/shared/src/cliplab/definition.ts b/packages/shared/src/cliplab/definition.tsnew file mode 100644index 0000000000..73914402b3--- /dev/null+++ b/packages/shared/src/cliplab/definition.ts@@ -0,0 +1,18 @@+import type { AgentAppearance, CharacterPaletteId, CharacterState } from "../agent-appearance.js";+import { defaultProject, definitionOf, sampleDefinition, BASE_POSE, type Definition, type Sample } from "./model.js";+import { CAP_V1_COLORS } from "./palette-tokens.js";++export function characterDefinition(appearance: AgentAppearance, muted = false): Definition {+ const project = defaultProject();+ const colors = CAP_V1_COLORS[(muted ? "muted-dream" : appearance.paletteId) as CharacterPaletteId];+ const character = { ...project.characters[1], id: "paperclip-cap-v1", name: "Agent", color: colors.a, color2: colors.b,+ gradientAngle: 0, iris: false, toon: true, shadow: false, followCursor: true, followRotation: true };+ const definition = definitionOf(project, character);+ for (const animation of definition.animations) if (animation.id === "happy") animation.loop = false;+ return definition;+}+export function animationId(state: CharacterState) { return state === "success" ? "happy" : state === "rest" ? "idle" : state; }+export function characterStill(definition: Definition, state: CharacterState): Sample {+ if (state === "rest") return { pose: { ...BASE_POSE }, blink: 0, bob: 0, breathe: 0, expressionId: "idle", beatIndex: 0, stepIndex: 0 };+ return sampleDefinition(definition, animationId(state), 0.6);+}diff --git a/packages/shared/src/cliplab/face-morph.ts b/packages/shared/src/cliplab/face-morph.tsnew file mode 100644index 0000000000..ed485fa245--- /dev/null+++ b/packages/shared/src/cliplab/face-morph.ts@@ -0,0 +1,205 @@+// Vendored from ClipLab a050f724; see PROVENANCE.md and LICENSE.+import type { Detail, FaceLayer, Pose } from './model.js'+import { irisOffset, type Gaze } from './gaze.js'++export type Point = { x: number; y: number }+const COUNT = 128, TAU = Math.PI * 2+const pt = (x: number, y: number): Point => ({ x, y })+const distance = (a: Point, b: Point) => Math.hypot(b.x - a.x, b.y - a.y)+const unit = (a: Point) => { const n = Math.hypot(a.x, a.y) || 1; return pt(a.x / n, a.y / n) }+const arc = (x: number, y: number, rx: number, ry: number, from = 0, to = TAU, count = 64) => Array.from({ length: count + 1 }, (_, i) => { const a = from + (to - from) * i / count; return pt(x + Math.cos(a) * rx, y + Math.sin(a) * ry) })+const cubic = (a: Point, b: Point, c: Point, d: Point, n = 32) => Array.from({ length: n + 1 }, (_, i) => {+ const t = i / n, s = 1 - t+ return pt(s ** 3 * a.x + 3 * s ** 2 * t * b.x + 3 * s * t ** 2 * c.x + t ** 3 * d.x, s ** 3 * a.y + 3 * s ** 2 * t * b.y + 3 * s * t ** 2 * c.y + t ** 3 * d.y)+})+const quad = (a: Point, b: Point, c: Point) => cubic(a, pt(a.x + (b.x - a.x) * 2 / 3, a.y + (b.y - a.y) * 2 / 3), pt(c.x + (b.x - c.x) * 2 / 3, c.y + (b.y - c.y) * 2 / 3), c)+const area = (p: Point[]) => p.reduce((sum, a, i) => { const b = p[(i + 1) % p.length]!; return sum + a.x * b.y - b.x * a.y }, 0)+function clean(points: Point[]) {+ const p = points.filter((point, i) => i === 0 || distance(point, points[i - 1]!) > .00001)+ if (p.length > 1 && distance(p[0]!, p.at(-1)!) < .00001) p.pop()+ return p+}+/** Stable winding, anchor and perimeter correspondence; never align against a live blend. */+export function contour(points: Point[]): Point[] {+ let p = clean(points)+ if (p.length < 2) return Array.from({ length: COUNT }, () => ({ ...(p[0] ?? pt(0, 0)) }))+ if (area(p) < 0) p.reverse()+ let anchor = 0+ for (let i = 1; i < p.length; i++) if (p[i]!.x < p[anchor]!.x - .00001 || (Math.abs(p[i]!.x - p[anchor]!.x) < .00001 && p[i]!.y < p[anchor]!.y)) anchor = i+ p = [...p.slice(anchor), ...p.slice(0, anchor)]+ const lengths = p.map((a, i) => distance(a, p[(i + 1) % p.length]!)), total = lengths.reduce((a, b) => a + b, 0)+ let segment = 0, traversed = 0+ return Array.from({ length: COUNT }, (_, i) => {+ const target = total * i / COUNT+ while (segment < p.length - 1 && traversed + lengths[segment]! < target) traversed += lengths[segment++]!+ const a = p[segment]!, b = p[(segment + 1) % p.length]!, t = (target - traversed) / (lengths[segment] || 1)+ return pt(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t)+ })+}+function ribbon(points: Point[], width: number): Point[] {+ const p = clean(points), h = width / 2+ const normals = p.slice(1).map((b, i) => { const a = p[i]!; return unit(pt(a.y - b.y, b.x - a.x)) })+ if (!normals.length) return arc(p[0]!.x, p[0]!.y, h, h)+ const side = (sign: number) => p.flatMap((a, i) => {+ const before = normals[Math.max(0, i - 1)]!, after = normals[Math.min(normals.length - 1, i)]!+ const cross = before.x * after.y - before.y * after.x+ if (i > 0 && i < p.length - 1 && cross * sign < -.0001) {+ const from = Math.atan2(before.y * sign, before.x * sign)+ const delta = Math.atan2(cross, before.x * after.x + before.y * after.y)+ return arc(a.x, a.y, h, h, from, from + delta, Math.max(2, Math.ceil(Math.abs(delta) * 10)))+ }+ const n = unit(pt(before.x + after.x, before.y + after.y)), reach = h / Math.max(.35, n.x * after.x + n.y * after.y)+ return [pt(a.x + n.x * reach * sign, a.y + n.y * reach * sign)]+ })+ const end = p.at(-1)!, first = p[0]!, endAngle = Math.atan2(normals.at(-1)!.y, normals.at(-1)!.x), startAngle = Math.atan2(normals[0]!.y, normals[0]!.x)+ return [...side(1), ...arc(end.x, end.y, h, h, endAngle, endAngle - Math.PI, 16), ...side(-1).reverse(), ...arc(first.x, first.y, h, h, startAngle - Math.PI, startAngle - TAU, 16)]+}+function expand(points: Point[], amount: number) {+ const p = clean(points); if (area(p) < 0) p.reverse()+ return p.flatMap((a, i) => {+ const before = p[(i - 1 + p.length) % p.length]!, after = p[(i + 1) % p.length]!+ const u = unit(pt(a.y - before.y, before.x - a.x)), v = unit(pt(after.y - a.y, a.x - after.x)), n = unit(pt(u.x + v.x, u.y + v.y))+ const cross = u.x * v.y - u.y * v.x+ if (cross > .0001) {+ const from = Math.atan2(u.y, u.x), delta = Math.atan2(cross, u.x * v.x + u.y * v.y)+ return arc(a.x, a.y, amount, amount, from, from + delta, Math.max(2, Math.ceil(delta * 10)))+ }+ const reach = amount / Math.max(.5, n.x * v.x + n.y * v.y)+ return [pt(a.x + n.x * reach, a.y + n.y * reach)]+ })+}+export const traitWeight = (layers: FaceLayer[], predicate: (pose: FaceLayer['traits']) => boolean) => layers.reduce((n, layer) => n + (predicate(layer.traits) ? layer.weight : 0), 0)+export function blendContours(contours: Point[][], layers: FaceLayer[]): Point[] {+ return Array.from({ length: COUNT }, (_, i) => contours.reduce((point, shape, j) => pt(point.x + shape[i]!.x * layers[j]!.weight, point.y + shape[i]!.y * layers[j]!.weight), pt(0, 0)))+}+function trace(ctx: CanvasRenderingContext2D, shape: Point[]) {+ ctx.beginPath(); ctx.moveTo(shape[0]!.x, shape[0]!.y)+ for (const point of shape.slice(1)) ctx.lineTo(point.x, point.y)+ ctx.closePath()+}+export function isLineEye(pose: Pick<Pose, 'eye' | 'mouth'>, side: number, detail: Detail) {+ return ['closed', 'arc-up', 'arc-down', 'squint'].includes(pose.eye) || (pose.eye === 'wink' && side > 0) || (detail === 'eyes' && ['open', 'grin'].includes(pose.mouth) && pose.eye === 'dot')+}+export function eyeContour(pose: Pose, r: number, side: number, blink: number, detail: Detail): Point[] {+ const stroke = Math.max(13, r * .43)+ if ((pose.faceSet === 'set-2' && pose.eye === 'wink' && side > 0) || pose.eye === 'squint') {+ const sign = pose.eye === 'wink' ? -1 : side+ return contour(ribbon([pt(-r * sign * .7, -r * .8), pt(r * sign * .6, 0), pt(-r * sign * .7, r * .8)], stroke))+ }+ if (isLineEye(pose, side, detail)) {+ const happy = ['open', 'grin', 'smile', 'u-smile'].includes(pose.mouth)+ const up = pose.eye === 'arc-up' || (pose.eye !== 'arc-down' && happy)+ return contour(ribbon(arc(0, 0, r, r, up ? Math.PI : 0, up ? TAU : Math.PI), stroke))+ }+ const h = Math.max(.12, 1 - blink) * pose.eyeHeight * (pose.eye === 'soft' ? .65 : 1)+ let shape: Point[]+ if (pose.eye === 'star') shape = Array.from({ length: 10 }, (_, i) => { const a = i / 10 * TAU - Math.PI / 2, size = r * 1.2 * (i % 2 ? .46 : 1); return pt(Math.cos(a) * size, Math.sin(a) * size) })+ else if (pose.eye === 'heart') shape = [...cubic(pt(0, r), pt(-r * 2, -r * .1), pt(-r, -r * 1.5), pt(0, -r * .55)), ...cubic(pt(0, -r * .55), pt(r, -r * 1.5), pt(r * 2, -r * .1), pt(0, r))]+ else if (pose.eye === 'half-lidded') shape = arc(0, 0, r, r, 0, Math.PI)+ else { const size = r * (pose.eye === 'pupil' && detail === 'full' ? 1.5 : 1); shape = arc(0, 0, size, size) }+ const open = contour(shape.map(p => pt(p.x, p.y * h)))+ const closing = Math.max(0, Math.min(1, (blink - .5) / .5))+ if (!closing) return open+ const closed = contour(ribbon([pt(-r, 0), pt(r, 0)], stroke))+ return open.map((p, i) => pt(p.x + (closed[i]!.x - p.x) * closing, p.y + (closed[i]!.y - p.y) * closing))+}+export function mouthGeometry(pose: Pose): { outline: Point[]; opening: Point[]; width: number; height: number } {+ const broad = ['open', 'grin', 'cry'].includes(pose.mouth), w = (broad ? 124 : pose.mouth === 'oh' ? 51 : 61) * pose.mouthWidth+ const h = (broad ? 48 : 22) + 72 * pose.mouthOpen, stroke = 17 * pose.mouthStroke+ let path: Point[], filled = false+ if (pose.mouth === 'smile') path = arc(0, -10, w, w, Math.PI * .18, Math.PI * .82)+ else if (pose.mouth === 'u-smile') path = arc(0, -8, w * .56, w * .56, 0, Math.PI)+ else if (pose.mouth === 'frown') path = arc(0, 39, w, w, Math.PI * 1.2, Math.PI * 1.8)+ else if (pose.mouth === 'line' || pose.mouth === 'sleep') path = [pt(-w * .58, 0), pt(w * .58, 0)]+ else if (pose.mouth === 'kiss') path = [...cubic(pt(-w * .25, -21), pt(w * .48, -34), pt(w * .53, -2), pt(0, 0)), ...cubic(pt(0, 0), pt(w * .53, 2), pt(w * .48, 34), pt(-w * .25, 21))]+ else if (pose.mouth === 'wave') path = cubic(pt(-w, 4), pt(-w * .35, -25), pt(w * .35, 25), pt(w, -4))+ else if (pose.mouth === 'tongue-out') path = quad(pt(-w, -9), pt(0, -2), pt(w, -9))+ else {+ filled = true+ if (pose.mouth === 'oh') { const r = w * (.55 + .3 * pose.mouthOpen); path = arc(0, 14, r, r) }+ else if (pose.mouth === 'cry') path = [...cubic(pt(-w, 30), pt(-w * 1.1, -h), pt(w * 1.1, -h), pt(w, 30)), ...quad(pt(w, 30), pt(w, 44), pt(w * .76, 38)), ...quad(pt(w * .76, 38), pt(0, 24), pt(-w * .76, 38)), ...quad(pt(-w * .76, 38), pt(-w, 44), pt(-w, 30))].map(p => pt(p.x, p.y + 36 / (4 / 3)))+ else { const tilt = pose.mouth === 'grin' ? 24 : 0; path = [...quad(pt(-w, -11), pt(0, 5), pt(w, -11 - tilt)), ...cubic(pt(w, -11 - tilt), pt(w * 1.02, h), pt(-w * 1.02, h), pt(-w, -11))] }+ }+ return { outline: contour(filled ? expand(path, stroke / 2) : ribbon(path, stroke)), opening: filled ? contour(path) : Array.from({ length: COUNT }, () => pt(0, 0)), width: w, height: h }+}+function colorMix(colors: { color: string; weight: number }[]) {+ const value = [0, 0, 0]+ for (const { color, weight } of colors) for (let i = 0; i < 3; i++) value[i]! += parseInt(color.slice(1 + i * 2, 3 + i * 2), 16) * weight+ return `rgb(${value.map(v => Math.round(v)).join(',')})`+}+export function drawMorphEye(ctx: CanvasRenderingContext2D, pose: Pose, layers: FaceLayer[], r: number, side: number, blink: number, detail: Detail, ink: string, iris: boolean, gaze: Gaze) {+ const shape = blendContours(layers.map(layer => eyeContour({ ...pose, ...layer.traits }, r, side, blink, detail)), layers)+ const filled = (traits: FaceLayer['traits']) => !isLineEye(traits, side, detail)+ const cheeks = traitWeight(layers, t => t.cheeks && filled(t))+ ctx.save()+ if (cheeks > 0) {+ const h = Math.max(.12, 1 - blink) * pose.eyeHeight * (1 - .35 * traitWeight(layers, t => t.eye === 'soft')), cut = r * .82 * Math.sqrt(cheeks)+ ctx.beginPath(); ctx.rect(-r * 3, -r * 3, r * 6, r * 6); ctx.moveTo(cut, r * 1.13 * h); ctx.ellipse(0, r * 1.13 * h, cut, cut * h, 0, 0, TAU); ctx.clip('evenodd')+ }+ ctx.fillStyle = colorMix(layers.map(({ traits, weight }) => ({ weight, color: detail === 'full' && traits.eye === 'pupil' ? '#fffef9' : detail === 'full' && traits.eye === 'heart' && traits.faceSet === 'set-2' ? '#ff3f58' : ink })))+ trace(ctx, shape); ctx.fill(); ctx.clip()+ ctx.scale(1, Math.max(.12, 1 - blink) * pose.eyeHeight * (1 - .35 * traitWeight(layers, t => t.eye === 'soft')))+ const pupil = detail === 'full' ? traitWeight(layers, t => t.eye === 'pupil') : 0+ if (pupil > 0) {+ ctx.globalAlpha = pupil * (1 - blink); ctx.fillStyle = ink+ ctx.beginPath(); ctx.arc(gaze.x * r * 1.5 * .52, -gaze.y * r * 1.5 * .52, r * .6, 0, TAU); ctx.fill()+ }+ const visible = iris && detail === 'full' ? traitWeight(layers, t => filled(t) && t.eye !== 'pupil' && t.eye !== 'half-lidded') : 0+ if (visible > 0) {+ const dot = irisOffset(r, gaze, 0, cheeks)+ ctx.globalAlpha = visible * (1 - blink); ctx.fillStyle = '#ffffff'+ ctx.beginPath(); ctx.arc(dot.x, dot.y, r * .28, 0, TAU); ctx.fill()+ }+ ctx.restore()+}+/** Find the lower contour at the drool's right-side attachment point. Using+ * the rendered outline keeps it attached throughout mouth-shape morphs. */+export function droolAnchor(outline: Point[], width: number): Point {+ const x = Math.min(width * .35, Math.max(...outline.map(p => p.x)) * .75)+ let bottom = -Infinity+ for (let i = 0; i < outline.length; i++) {+ const a = outline[i]!, b = outline[(i + 1) % outline.length]!+ if ((a.x <= x && b.x >= x) || (b.x <= x && a.x >= x)) {+ const y = Math.abs(b.x - a.x) < 1e-8 ? Math.max(a.y, b.y) : a.y + (b.y - a.y) * (x - a.x) / (b.x - a.x)+ bottom = Math.max(bottom, y)+ }+ }+ // The round cap overlaps the lip by two units so there is no visible gap.+ return { x, y: (Number.isFinite(bottom) ? bottom : 0) + 6 }+}+export function drawDrool(ctx: CanvasRenderingContext2D, anchor: Point, amount = 1) {+ ctx.save(); ctx.globalAlpha = amount; ctx.strokeStyle = '#fffef5'; ctx.lineWidth = 16+ ctx.beginPath(); ctx.moveTo(anchor.x, anchor.y); ctx.lineTo(anchor.x + 3, anchor.y + 34 * amount); ctx.stroke()+ ctx.fillStyle = '#fffef5'; ctx.beginPath(); ctx.arc(anchor.x + 3, anchor.y + 38 * amount, 8 * amount, 0, TAU); ctx.fill(); ctx.restore()+}+export function drawMorphMouth(ctx: CanvasRenderingContext2D, pose: Pose, layers: FaceLayer[], ink: string) {+ const geometry = layers.map(layer => mouthGeometry({ ...pose, ...layer.traits }))+ const outline = blendContours(geometry.map(g => g.outline), layers), opening = blendContours(geometry.map(g => g.opening), layers)+ const w = geometry.reduce((sum, g, i) => sum + g.width * layers[i]!.weight, 0), h = geometry.reduce((sum, g, i) => sum + g.height * layers[i]!.weight, 0)+ ctx.fillStyle = ink; trace(ctx, outline); ctx.fill()+ ctx.save(); trace(ctx, outline); ctx.clip(); trace(ctx, opening); ctx.clip()+ const tongue = traitWeight(layers, t => t.tongue), teeth = traitWeight(layers, t => t.teeth)+ ctx.translate(0, 27 * traitWeight(layers, t => t.mouth === 'cry'))+ if (tongue > 0) { ctx.globalAlpha = tongue; ctx.fillStyle = '#f37b83'; ctx.beginPath(); ctx.ellipse(10, h * .65, w * .65, h * .34, -.1, 0, TAU); ctx.fill() }+ if (teeth > 0) { ctx.globalAlpha = teeth; ctx.fillStyle = '#fffef8'; ctx.beginPath(); ctx.roundRect(-w * .76, -23, w * 1.52, 30, 12); ctx.fill() }+ ctx.restore()+ const out = traitWeight(layers, t => t.mouth === 'tongue-out')+ if (out > 0) {+ const w = 61 * pose.mouthWidth+ ctx.save(); ctx.globalAlpha = out; ctx.fillStyle = '#ff526c'; ctx.beginPath(); ctx.moveTo(-w * .6 * out, 5); ctx.lineTo(w * .6 * out, 5); ctx.bezierCurveTo(w * .88 * out, (85 * pose.mouthOpen + 28) * out, -w * .88 * out, (85 * pose.mouthOpen + 28) * out, -w * .6 * out, 5); ctx.fill(); ctx.restore()+ }+ const drool = traitWeight(layers, t => t.drool)+ if (drool > 0) drawDrool(ctx, droolAnchor(outline, w), drool)+}++export function drawMorphBrow(ctx: CanvasRenderingContext2D, layers: FaceLayer[], r: number, side: number, ink: string) {+ if (!layers.some(layer => layer.traits.brows !== 'none')) return+ const shapes = layers.map(({ traits }) => {+ if (traits.brows === 'none') return contour([pt(0, 0)])+ const path = traits.brows === 'raised' ? arc(0, 10, r * .85, r * .85, Math.PI * 1.15, Math.PI * 1.85)+ : traits.brows === 'worried' ? quad(pt(side * r, 2), pt(-side * r * .1, 10), pt(-side * r * .75, -16))+ : [pt(side * r, -10), pt(-side * r * .75, 8)]+ return contour(ribbon(path, 12))+ })+ ctx.fillStyle = ink; trace(ctx, blendContours(shapes, layers)); ctx.fill()+}diff --git a/packages/shared/src/cliplab/gaze.ts b/packages/shared/src/cliplab/gaze.tsnew file mode 100644index 0000000000..852055d2c9--- /dev/null+++ b/packages/shared/src/cliplab/gaze.ts@@ -0,0 +1,65 @@+// Vendored from ClipLab a050f724; see PROVENANCE.md and LICENSE.+export interface Gaze { x: number; y: number }+export interface PointerLook extends Gaze { weight: number }+export interface EyeGazes { left: Gaze; right: Gaze }+export const centeredGaze = (): Gaze => ({ x: 0, y: 0 })+export const inactivePointer = (): PointerLook => ({ x: 0, y: 0, weight: 0 })++/** Geometric canvas coordinates retain the target's position, even outside the canvas. */+export function pointerLook(pointer: { clientX: number; clientY: number }, bounds: { left: number; top: number; width: number; height: number }): PointerLook {+ return { x: (pointer.clientX - bounds.left) / Math.max(1, bounds.width) * 2 - 1, y: 1 - (pointer.clientY - bounds.top) / Math.max(1, bounds.height) * 2, weight: 1 }+}++export function easePointer(current: PointerLook, target: PointerLook, seconds: number, immediate = false): PointerLook {+ return { ...easeGaze(current, target, seconds, immediate), weight: easeGaze({ x: current.weight, y: 0 }, { x: target.weight, y: 0 }, seconds, immediate).x }+}++/** Solve in the projected eye's own axes, then gently saturate travel with distance. */+export function gazeAtPoint(pointer: Gaze, center: Gaze, right: Gaze, up: Gaze): Gaze {+ const rx = right.x - center.x, ry = right.y - center.y, ux = up.x - center.x, uy = up.y - center.y+ const determinant = rx * uy - ry * ux+ if (Math.abs(determinant) < 1e-10) return centeredGaze()+ const dx = pointer.x - center.x, dy = pointer.y - center.y+ const x = (dx * uy - dy * ux) / determinant, y = (rx * dy - ry * dx) / determinant+ const distance = Math.hypot(x, y, 1.15)+ return { x: x / distance, y: y / distance }+}++export function localGaze(gaze: Gaze, rotation: number): Gaze {+ const angle = rotation * Math.PI / 180+ return clampGaze({ x: gaze.x * Math.cos(angle) - gaze.y * Math.sin(angle), y: gaze.x * Math.sin(angle) + gaze.y * Math.cos(angle) })+}++export function clampGaze({ x, y }: Gaze): Gaze {+ x = Number.isFinite(x) ? x : 0; y = Number.isFinite(y) ? y : 0+ const length = Math.max(1, Math.hypot(x, y))+ return { x: x / length, y: y / length }+}++export function pointerGaze(pointer: { clientX: number; clientY: number }, bounds: { left: number; top: number; width: number; height: number }): Gaze {+ return clampGaze({+ x: (pointer.clientX - bounds.left - bounds.width / 2) / Math.max(80, bounds.width / 2),+ y: -(pointer.clientY - bounds.top - bounds.height / 2) / Math.max(80, bounds.height / 2)+ })+}++/** Time-based easing, shared by the studio and paused or playing app characters. */+export function easeGaze(current: Gaze, target: Gaze, seconds: number, immediate = false): Gaze {+ const amount = immediate ? 1 : 1 - Math.exp(-Math.max(0, seconds) * 16)+ const next = { x: current.x + (target.x - current.x) * amount, y: current.y + (target.y - current.y) * amount }+ return Math.hypot(next.x - target.x, next.y - target.y) < .0005 ? { ...target } : next+}++/** Keep the complete white dot inside the eye, with a small margin at every angle. */+export function irisOffset(radius: number, gaze: Gaze, eyeRotation = 0, cheeks: boolean | number = false): Gaze {+ const look = clampGaze(gaze), angle = eyeRotation * Math.PI / 180+ const x = look.x * radius * .62, y = -look.y * radius * .62+ const dot = { x: x * Math.cos(angle) + y * Math.sin(angle), y: -x * Math.sin(angle) + y * Math.cos(angle) }+ // Stay above the cheek's circular cutout, including the dot radius and a small gap.+ if (cheeks) {+ const amount = typeof cheeks === 'number' ? Math.max(0, Math.min(1, cheeks)) : 1+ const clearance = radius * (.82 * Math.sqrt(amount) + .305)+ if (Math.abs(dot.x) < clearance) dot.y = Math.min(dot.y, radius * 1.13 - Math.sqrt(clearance ** 2 - dot.x ** 2))+ }+ return dot+}diff --git a/packages/shared/src/cliplab/model.ts b/packages/shared/src/cliplab/model.tsnew file mode 100644index 0000000000..75572b3dbe--- /dev/null+++ b/packages/shared/src/cliplab/model.ts@@ -0,0 +1,323 @@+// Vendored from ClipLab a050f724; see PROVENANCE.md and LICENSE.+export type Shape = 'capsule' | 'cap' | 'sphere'+export type Eye = 'dot' | 'soft' | 'closed' | 'wink' | 'star' | 'heart' | 'squint' | 'wide' | 'arc-up' | 'arc-down' | 'half-lidded' | 'pupil'+export type Mouth = 'smile' | 'open' | 'line' | 'frown' | 'oh' | 'wave' | 'sleep' | 'grin' | 'cry' | 'u-smile' | 'kiss' | 'tongue-out'+export type Prop = 'none' | 'zzz' | 'sparkle' | 'heart' | 'question' | 'sweat' | 'crown'+export type Detail = 'body' | 'eyes' | 'full'++export interface Pose {+ eye: Eye; mouth: Mouth; prop: Prop+ faceSet: 'set-1' | 'set-2'; brows: 'none' | 'raised' | 'worried' | 'angry'; blush: number+ eyeSize: number; eyeHeight: number; spacing: number; eyeTilt: number+ leftScale: number; rightScale: number; gazeX: number; gazeY: number+ leftX: number; rightX: number; leftY: number; rightY: number; leftRotation: number; rightRotation: number+ mouthWidth: number; mouthOpen: number; faceScale: number; faceY: number+ rotationX: number; rotationY: number; rotationZ: number; squash: number+ tongue: boolean; teeth: boolean; drool: boolean; cheeks: boolean; tears: boolean; mouthStroke: number+}+export interface Beat { id: string; name: string; duration: number; pose: Pose; gradientAction?: 'rotate' | 'hold' }+export interface Expression { id: string; name: string; description: string; beats: Beat[]; poseExpressionId?: string }+export interface Step { id: string; expressionId: string; duration: number }+export interface Animation { id: string; name: string; steps: Step[]; loop: boolean }+export interface Character {+ id: string; name: string; shape: Shape; color: string; color2: string; gradient: boolean+ gradientAngle: number; toon: boolean; trueFront: boolean; lockPosition: boolean; eyeColor: string; iris: boolean+ elevated: boolean; elevation: number; shadow: boolean+ motion: number; speed: number; blink: boolean; blinkInterval: number; followCursor: boolean; followRotation: boolean+}+export interface Definition { version: 1; character: Character; expressions: Expression[]; animations: Animation[] }+export interface Project { version: 1; name: string; characters: Character[]; expressions: Expression[]; animations: Animation[]; defaultsRevision?: number }+export type FaceTraits = Pick<Pose, 'eye' | 'mouth' | 'faceSet' | 'brows' | 'cheeks' | 'tongue' | 'teeth' | 'drool'>+export interface FaceLayer { traits: FaceTraits; weight: number }+export interface Sample { pose: Pose; blink: number; bob: number; breathe: number; expressionId: string; beatIndex: number; stepIndex: number; effectPhase?: number; propAmount?: number; tearAmount?: number; gradientRotation?: number; gradientMix?: number; faceLayers?: FaceLayer[] }++export const EYES: Eye[] = ['dot', 'soft', 'closed', 'wink', 'star', 'heart', 'squint', 'wide', 'arc-up', 'arc-down', 'half-lidded', 'pupil']+export const MOUTHS: Mouth[] = ['smile', 'open', 'line', 'frown', 'oh', 'wave', 'sleep', 'grin', 'cry', 'u-smile', 'kiss', 'tongue-out']+export const PROPS: Prop[] = ['none', 'zzz', 'sparkle', 'heart', 'question', 'sweat', 'crown']+export const SHAPES: { id: Shape; name: string; ratio: string }[] = [+ { id: 'capsule', name: 'Capsule', ratio: '1:2' }, { id: 'cap', name: 'End cap', ratio: '1:1' }, { id: 'sphere', name: 'Circle', ratio: '1:1' }+]+export const PALETTES = [+ ['#ff986d', '#ffd092'], ['#81d4c1', '#c6efd2'], ['#a79ce8', '#d8cafa'],+ ['#f0ce58', '#fff1a5'], ['#ee98b2', '#ffd2da'], ['#72b6de', '#b9e4f5']+]++export function detailAt(size: number): Detail { return size <= 16 ? 'body' : size <= 24 ? 'eyes' : 'full' }+export function uid(prefix = 'item') { return `${prefix}-${crypto.randomUUID().slice(0, 8)}` }+export function clone<T>(value: T): T { return JSON.parse(JSON.stringify(value)) as T }+export const BASE_POSE: Pose = {+ eye: 'dot', mouth: 'smile', prop: 'none', faceSet: 'set-1', brows: 'none', blush: 0, eyeSize: 1, eyeHeight: 1, spacing: 1, eyeTilt: 0,+ leftScale: 1, rightScale: 1, gazeX: 0, gazeY: 0, mouthWidth: 1, mouthOpen: .5,+ leftX: 0, rightX: 0, leftY: 0, rightY: 0, leftRotation: 0, rightRotation: 0,+ faceScale: .75, faceY: 0, rotationX: 0, rotationY: 0, rotationZ: 0, squash: 1,+ tongue: false, teeth: false, drool: false, cheeks: false, tears: false, mouthStroke: 1+}+const p = (v: Partial<Pose> = {}): Pose => ({ ...BASE_POSE, ...v })+const b = (id: string, name: string, duration: number, pose: Partial<Pose>): Beat => ({ id, name, duration, pose: p(pose) })++export function defaultExpressions(): Expression[] {+ return [+ { id: 'idle', name: 'Idle', description: 'A little breath. A quiet smile.', beats: [+ b('idle-1', 'Settle', 1.8, {}), b('idle-2', 'Look around', 1.4, { gazeX: .22, rotationZ: -3, rotationY: 5 }), b('idle-3', 'Return', 1.8, {})+ ] },+ { id: 'listening', name: 'Listening', description: 'Present, curious, and all ears.', beats: [+ b('listen-1', 'Notice', 1.2, { eye: 'wide', mouth: 'line', eyeSize: 1.06, rotationX: -4 }), b('listen-2', 'Lean in', 1.5, { mouth: 'smile', eyeHeight: 1.13, rotationZ: 6, rotationX: -7 }), b('listen-3', 'Nod', 1.1, { mouth: 'smile', rotationX: 5, rotationZ: 3 })+ ] },+ { id: 'thinking', name: 'Thinking', description: 'A glance up. Something is taking shape.', beats: [+ b('think-1', 'Wonder', 1.5, { mouth: 'oh', mouthOpen: .23, mouthWidth: .6, gazeX: .6, gazeY: .55, rotationZ: -7, prop: 'question' }), b('think-2', 'Consider', 1.6, { eye: 'soft', mouth: 'wave', gazeX: -.35, gazeY: .2, rotationY: -8, rotationZ: 4 }), b('think-3', 'Almost', 1.2, { mouth: 'smile', gazeY: .25, rotationZ: -3 })+ ] },+ { id: 'working', name: 'Working', description: 'Small, focused, steady movements.', beats: [+ b('work-1', 'Focus left', 1.0, { eye: 'soft', mouth: 'line', mouthWidth: .65, gazeX: -.5, gazeY: -.3, rotationY: -7, rotationX: 4 }), b('work-2', 'Focus right', 1.0, { eye: 'soft', mouth: 'line', mouthWidth: .65, gazeX: .5, gazeY: -.3, rotationY: 7, rotationX: 4 }), b('work-3', 'Check', 1.4, { mouth: 'smile', rotationX: -3 })+ ] },+ { id: 'happy', name: 'Happy', description: 'A small open smile says it all.', beats: [+ b('happy-1', 'Light up', .9, { mouth: 'open', mouthOpen: .62, rotationZ: -5, squash: 1.025 }), b('happy-2', 'Delight', 1.3, { eye: 'arc-up', mouth: 'grin', mouthOpen: .8, prop: 'sparkle', rotationZ: 5, squash: .97 }), b('happy-3', 'Glow', 1.5, { mouth: 'open', mouthOpen: .5, rotationZ: -2 })+ ] },+ { id: 'confused', name: 'Confused', description: 'A little uneven. A second look.', beats: [+ b('confused-1', 'Wait', 1.2, { eye: 'soft', leftScale: .7, rightScale: 1.1, mouth: 'wave', rotationZ: 10, prop: 'question' }), b('confused-2', 'Really?', 1.4, { leftScale: 1.1, rightScale: .7, mouth: 'oh', mouthOpen: .25, rotationZ: -9, gazeX: -.2 }), b('confused-3', 'Hmm', 1.3, { eye: 'soft', mouth: 'frown', mouthWidth: .75, rotationZ: 4 })+ ] },+ { id: 'sleepy', name: 'Sleepy', description: 'Slow breathing, drifting sleep marks.', beats: [+ b('sleep-1', 'Doze', 2, { eye: 'arc-down', mouth: 'sleep', prop: 'zzz', drool: true, rotationZ: -6, rotationX: 4, squash: .97 }), b('sleep-2', 'Breathe in', 2, { eye: 'arc-down', mouth: 'oh', mouthOpen: .25, mouthWidth: .65, prop: 'zzz', drool: true, rotationZ: -3, squash: 1.025 }), b('sleep-3', 'Breathe out', 2, { eye: 'arc-down', mouth: 'sleep', prop: 'zzz', drool: true, rotationZ: -7, squash: .98 })+ ] },+ { id: 'sad', name: 'Sad', description: 'A round frown, a little lower.', beats: [+ b('sad-1', 'Low', 1.6, { mouth: 'frown', rotationZ: -3 }), b('sad-2', 'Sigh', 1.8, { eye: 'arc-down', mouth: 'frown', rotationX: 4 }), b('sad-3', 'Look up', 1.6, { mouth: 'frown', gazeY: .2 })+ ] },+ { id: 'tearful', name: 'Tearful', description: 'A trembling mouth and falling tears.', beats: [+ b('tear-1', 'Well up', 1.5, { mouth: 'cry', tears: true, mouthOpen: .6, rotationZ: -3 }), b('tear-2', 'Let go', 1.8, { mouth: 'cry', tears: true, mouthOpen: .85, eye: 'arc-down', rotationZ: 3 }), b('tear-3', 'Breathe', 1.8, { mouth: 'cry', tears: true, mouthOpen: .5 })+ ] },+ { id: 'playful', name: 'Playful', description: 'A wink, a grin, a little mischief.', beats: [+ b('play-1', 'Peek', 1.1, { mouth: 'open', tongue: true, rotationY: -10, rotationZ: -8 }), b('play-2', 'Wink', 1.2, { eye: 'squint', mouth: 'u-smile', tongue: true, mouthOpen: .7, rotationZ: 9, prop: 'sparkle' }), b('play-3', 'Grin', 1.3, { mouth: 'grin', cheeks: true, teeth: true, mouthOpen: .45, rotationZ: -3 })+ ] },+ { id: 'loading', name: 'Loading', description: 'Focused Working gestures with a gently eased gradient turn.', poseExpressionId: 'working', beats: [+ { ...b('loading-rotate', 'Rotate', 2, {}), gradientAction: 'rotate' },+ { ...b('loading-hold', 'Hold', .5, {}), gradientAction: 'hold' }+ ] }+ ]+}+export function defaultProject(): Project {+ const base: Character = {+ id: 'milo', name: 'Milo', shape: 'capsule', color: '#ff986d', color2: '#ffd092', gradient: true,+ gradientAngle: 20, toon: true, trueFront: false, lockPosition: false, eyeColor: '#080909', iris: false, elevated: false, elevation: .065,+ shadow: true, motion: .45, speed: 1, blink: true, blinkInterval: 4.2, followCursor: false, followRotation: false+ }+ const expressions = defaultExpressions()+ const sequences: Record<string, [string, number][]> = {+ listening: [['listening', 3.8], ['idle', 1.6]],+ thinking: [['thinking', 4.3], ['working', 1.8]],+ working: [['working', 6.8], ['thinking', 2.2]],+ happy: [['happy', 3.7], ['playful', 2.4], ['idle', 1.8]],+ confused: [['confused', 3.9], ['thinking', 2.1]],+ playful: [['playful', 3.6], ['happy', 2.2]]+ }+ return {+ version: 1, name: 'My character studio', defaultsRevision: 2,+ characters: [base, { ...base, id: 'pip', name: 'Pip', shape: 'cap', color: '#81d4c1', color2: '#c6efd2' }, { ...base, id: 'lumi', name: 'Lumi', shape: 'sphere', color: '#a79ce8', color2: '#d8cafa' }],+ expressions,+ animations: expressions.map((e) => ({+ id: e.id, name: e.id === 'happy' ? 'Success' : e.name, loop: true,+ steps: (sequences[e.id] ?? [[e.id, expressionDuration(e)] as [string, number]]).map(([expressionId, duration], i) => ({ id: `${e.id}-step-${i + 1}`, expressionId, duration }))+ }))+ }+}+const safeDuration = (value: number) => Number.isFinite(value) ? Math.max(.2, value) : 1+export function expressionDuration(expression: Expression) { return expression.beats.reduce((n, beat) => n + safeDuration(beat.duration), 0) }+export function animationDuration(animation: Animation) { return animation.steps.reduce((n, step) => n + safeDuration(step.duration), 0) }+export function isGradientExpression(expression: Expression) { return expression.beats.some(beat => beat.gradientAction !== undefined) }+export function addLoadingAnimation(project: Project): Animation {+ let expression = project.expressions.find(e => e.id === 'loading' && isGradientExpression(e)) ?? project.expressions.find(isGradientExpression)+ const existing = expression && project.animations.find(a => a.steps.length === 1 && a.steps[0]!.expressionId === expression!.id)+ if (existing) return existing+ const needsWorking = (!expression || expression.poseExpressionId === 'working') && !project.expressions.some(e => e.id === 'working')+ if (project.animations.length >= 100 || project.expressions.length + (expression ? 0 : 1) + (needsWorking ? 1 : 0) > 100) throw new Error('Make room in the library before adding Loading. Projects support up to 100 expressions and animations.')+ if (!expression) {+ expression = defaultExpressions().find(e => e.id === 'loading')!+ if (project.expressions.some(e => e.id === expression!.id)) expression.id = uid('loading')+ project.expressions.push(expression)+ }+ if (expression.poseExpressionId === 'working' && !project.expressions.some(e => e.id === 'working')) {+ project.expressions.push(defaultExpressions().find(e => e.id === 'working')!)+ }+ const animation: Animation = { id: project.animations.some(a => a.id === 'loading') ? uid('loading') : 'loading', name: 'Loading', loop: true, steps: [{ id: uid('step'), expressionId: expression.id, duration: expressionDuration(expression) }] }+ project.animations.push(animation)+ return animation+}+export function definitionOf(project: Project, character: Character, animationIds?: string[]): Definition {+ const animations = project.animations.filter(a => !animationIds || animationIds.includes(a.id))+ const used = new Set(animations.flatMap(a => a.steps.map(s => s.expressionId)))+ // A selected Loading export also carries the expression playing alongside it.+ for (const id of used) {+ const source = project.expressions.find(e => e.id === id)?.poseExpressionId+ if (source) used.add(source)+ }+ return clone({ version: 1, character, expressions: animationIds ? project.expressions.filter(e => used.has(e.id)) : project.expressions, animations })+}+const numericKeys = Object.keys(BASE_POSE).filter(k => typeof BASE_POSE[k as keyof Pose] === 'number') as (keyof Pose)[]+const faceKeys = ['eye', 'mouth', 'faceSet', 'brows', 'cheeks', 'tongue', 'teeth', 'drool'] as const+export function faceLayers(pose: Pose): FaceLayer[] {+ return [{ traits: Object.fromEntries(faceKeys.map(key => [key, pose[key]])) as FaceTraits, weight: 1 }]+}+export function mixFaceLayers(a: FaceLayer[], b: FaceLayer[], t: number): FaceLayer[] {+ const combined = new Map<string, FaceLayer>()+ for (const [layers, amount] of [[a, 1 - t], [b, t]] as const) for (const layer of layers) {+ const weight = layer.weight * amount+ if (weight <= 0) continue+ const key = JSON.stringify(layer.traits), prior = combined.get(key)+ if (prior) prior.weight += weight+ else combined.set(key, { traits: layer.traits, weight })+ }+ return [...combined.values()]+}+export function mixPose(a: Pose, b: Pose, t: number): Pose {+ const result = { ...(t < .5 ? a : b) }+ for (const key of numericKeys) {+ let delta = (b[key] as number) - (a[key] as number)+ if (key.startsWith('rotation')) delta = ((delta + 180) % 360 + 360) % 360 - 180+ ;(result as unknown as Record<string, unknown>)[key] = (a[key] as number) + delta * t+ }+ return result+}+const smooth = (t: number) => { const v = Math.max(0, Math.min(1, t)); return v * v * (3 - 2 * v) }+function featureAmount(a: unknown, b: unknown, blend: number) { return a === b ? 1 : blend < .5 ? 1 - smooth(blend * 2) : smooth((blend - .5) * 2) }+const mod = (t: number, d: number) => ((t % d) + d) % d+export function sampleExpression(expression: Expression, time: number, expressions: Expression[] = [], visited = new Set<string>()): { pose: Pose; beatIndex: number; propAmount: number; tearAmount: number; gradientRotation?: number; gradientMix?: number; faceLayers: FaceLayer[] } {+ const duration = expressionDuration(expression)+ let t = mod(time, duration)+ const gradient = isGradientExpression(expression)+ let gradientStart = 0+ for (let i = 0; i < expression.beats.length; i++) {+ const beat = expression.beats[i]!+ const beatDuration = safeDuration(beat.duration)+ if (t < beatDuration || i === expression.beats.length - 1) {+ const previous = expression.beats[(i - 1 + expression.beats.length) % expression.beats.length]!+ const transition = Math.min(.45, beatDuration * .4)+ const progress = Math.min(t / transition, 1)+ const eased = progress * progress * (3 - 2 * progress)+ const turn = Math.min(1, t / beatDuration)+ const turnEased = (1 - Math.cos(Math.PI * turn)) / 2+ const source = expressions.find(e => e.id === expression.poseExpressionId && !visited.has(e.id) && e.id !== expression.id)+ const face = source ? sampleExpression(source, mod(time, duration) / duration * expressionDuration(source), expressions, new Set([...visited, expression.id])) : undefined+ return { pose: face?.pose ?? mixPose(previous.pose, beat.pose, eased), faceLayers: face?.faceLayers ?? mixFaceLayers(faceLayers(previous.pose), faceLayers(beat.pose), eased), beatIndex: i, propAmount: face?.propAmount ?? featureAmount(previous.pose.prop, beat.pose.prop, eased), tearAmount: face?.tearAmount ?? featureAmount(previous.pose.tears, beat.pose.tears, eased), ...(gradient ? { gradientRotation: gradientStart + (beat.gradientAction === 'rotate' ? 360 * turnEased : 0), gradientMix: 1 } : {}) }+ }+ if (beat.gradientAction === 'rotate') gradientStart += 360+ t -= beatDuration+ }+ return { pose: p(), faceLayers: faceLayers(p()), beatIndex: 0, propAmount: 1, tearAmount: 1 }+}+export function sampleDefinition(def: Definition, animationId: string, time: number, expressionId?: string): Sample {+ const speedTime = Math.max(0, time) * def.character.speed+ const animation = def.animations.find(a => a.id === animationId) ?? def.animations[0]+ let expression = def.expressions.find(e => e.id === expressionId) ?? def.expressions[0]!+ let local = speedTime, stepIndex = 0+ let previousExpression: Expression | undefined+ let blend = 1+ if (!expressionId && animation?.steps.length) {+ const total = animationDuration(animation)+ local = animation.loop ? mod(speedTime, total) : Math.min(speedTime, total - .00001)+ for (let i = 0; i < animation.steps.length; i++) {+ const step = animation.steps[i]!+ const stepDuration = safeDuration(step.duration)+ if (local < stepDuration || i === animation.steps.length - 1) {+ expression = def.expressions.find(e => e.id === step.expressionId) ?? expression+ stepIndex = i+ if (animation.steps.length > 1 && (i > 0 || animation.loop)) {+ const prev = animation.steps[(i - 1 + animation.steps.length) % animation.steps.length]!+ previousExpression = def.expressions.find(e => e.id === prev.expressionId)+ blend = Math.min(1, local / Math.min(.35, stepDuration * .2))+ }+ local = local / stepDuration * expressionDuration(expression)+ break+ }+ local -= stepDuration+ }+ }+ const sample = sampleExpression(expression, local, def.expressions)+ if (previousExpression && blend < 1) {+ const previous = sampleExpression(previousExpression, expressionDuration(previousExpression) - .00001, def.expressions)+ const eased = smooth(blend)+ const oldProp = previous.pose.prop, oldTears = previous.pose.tears+ sample.propAmount *= featureAmount(oldProp, sample.pose.prop, eased)+ sample.tearAmount *= featureAmount(oldTears, sample.pose.tears, eased)+ sample.pose = mixPose(previous.pose, sample.pose, eased)+ sample.faceLayers = mixFaceLayers(previous.faceLayers, sample.faceLayers, eased)+ if (previous.gradientRotation !== undefined || sample.gradientRotation !== undefined) {+ const from = previous.gradientRotation ?? 0, to = sample.gradientRotation ?? 0+ // Align the previous completed turn to the next expression's starting angle.+ // Keep the incoming turn unwrapped so crossing 180 degrees cannot flip it.+ const alignedFrom = from - Math.round(from / 360) * 360+ sample.gradientRotation = alignedFrom + (to - alignedFrom) * eased+ const fromMix = previous.gradientMix ?? 0+ sample.gradientMix = fromMix + ((sample.gradientMix ?? 0) - fromMix) * eased+ }+ }+ // All secondary motion uses the cycle period, so exported loops close exactly.+ const period = expressionId ? expressionDuration(expression) : animation ? animationDuration(animation) : expressionDuration(expression)+ const phase = 2 * Math.PI * mod(speedTime, period) / period+ const blinkCount = Math.max(1, Math.round(period / def.character.blinkInterval))+ const blinkPhase = mod(speedTime + period * .17, period / blinkCount)+ const gradientOnly = isGradientExpression(expression) && !expression.poseExpressionId+ const blink = !gradientOnly && def.character.blink && blinkPhase < .19 ? Math.sin(blinkPhase / .19 * Math.PI) ** 2 : 0+ return { ...sample, expressionId: expression.id, stepIndex, blink, effectPhase: mod(speedTime, period) / period * Math.max(1, Math.round(period / 2.4)), bob: gradientOnly ? 0 : Math.sin(phase) * def.character.motion, breathe: gradientOnly ? 0 : Math.cos(phase) * def.character.motion }+}++function obj(v: unknown): Record<string, unknown> { if (!v || typeof v !== 'object' || Array.isArray(v)) throw new Error('This file is not a ClipLab project.'); return v as Record<string, unknown> }+function num(v: unknown, fallback: number, low: number, high: number) { return typeof v === 'number' && Number.isFinite(v) ? Math.min(high, Math.max(low, v)) : fallback }+function str(v: unknown, fallback: string, max = 80) { return typeof v === 'string' && v.trim() ? v.trim().slice(0, max) : fallback }+function color(v: unknown, fallback: string) { return typeof v === 'string' && /^#[0-9a-f]{6}$/i.test(v) ? v : fallback }+function choice<T extends string>(v: unknown, options: T[], fallback: T) { return options.includes(v as T) ? v as T : fallback }+function boolean(v: unknown, fallback: boolean) { return typeof v === 'boolean' ? v : fallback }+function parsePose(value: unknown): Pose {+ const v = obj(value), pose = { ...BASE_POSE }+ const ranges: Record<string, [number, number]> = { blush: [0, 1], mouthStroke: [.5, 2.2], leftX: [-60, 60], rightX: [-60, 60], leftY: [-60, 60], rightY: [-60, 60], leftRotation: [-90, 90], rightRotation: [-90, 90], eyeSize: [.35, 2], eyeHeight: [.15, 2], spacing: [.5, 1.6], eyeTilt: [-45, 45], leftScale: [.3, 1.8], rightScale: [.3, 1.8], gazeX: [-1, 1], gazeY: [-1, 1], mouthWidth: [.3, 1.7], mouthOpen: [.1, 1], faceScale: [.6, 1.4], faceY: [-.3, .3], rotationX: [-180, 180], rotationY: [-180, 180], rotationZ: [-180, 180], squash: [.8, 1.2] }+ for (const key of numericKeys) { const [lo, hi] = ranges[key]!; (pose as unknown as Record<string, unknown>)[key] = num(v[key], BASE_POSE[key] as number, lo, hi) }+ return { ...pose, faceSet: choice(v.faceSet, ['set-1', 'set-2'], 'set-1'), brows: choice(v.brows, ['none', 'raised', 'worried', 'angry'], 'none'), eye: choice(v.eye, EYES, 'dot'), mouth: choice(v.mouth, MOUTHS, 'smile'), prop: choice(v.prop, PROPS, 'none'), tongue: boolean(v.tongue, false), teeth: boolean(v.teeth, false), drool: boolean(v.drool, false), cheeks: boolean(v.cheeks, false), tears: boolean(v.tears, false) }+}+export function parseCharacter(value: unknown): Character {+ const v = obj(value), d = defaultProject().characters[0]!+ return { ...d, id: str(v.id, uid('character')), name: str(v.name, 'Character'), shape: choice(v.shape, ['capsule', 'cap', 'sphere'], 'capsule'), color: color(v.color, d.color), color2: color(v.color2, d.color2), gradient: boolean(v.gradient, true), gradientAngle: num(v.gradientAngle, 20, -180, 180), toon: boolean(v.toon, d.toon), trueFront: boolean(v.trueFront, false), lockPosition: boolean(v.lockPosition, false), eyeColor: color(v.eyeColor, d.eyeColor), iris: boolean(v.iris, false), elevated: boolean(v.elevated, false), elevation: num(v.elevation, .065, .005, .2), shadow: boolean(v.shadow, true), motion: num(v.motion, .45, 0, 1), speed: num(v.speed, 1, .25, 3), blink: boolean(v.blink, true), blinkInterval: num(v.blinkInterval, 4.2, 1, 12), followCursor: boolean(v.followCursor, false), followRotation: boolean(v.followRotation, false) }+}+export function parseProject(value: unknown): Project {+ const v = obj(value)+ if (v.version !== 1 || !Array.isArray(v.expressions) || !Array.isArray(v.animations)) throw new Error('Choose a ClipLab version 1 project or character definition.')+ const charactersRaw = Array.isArray(v.characters) ? v.characters : v.character ? [v.character] : []+ if (!charactersRaw.length || charactersRaw.length > 30 || !v.expressions.length || v.expressions.length > 100 || !v.animations.length || v.animations.length > 100) throw new Error('The project has an unsupported number of characters or sequences.')+ const expressions = v.expressions.map((item, index): Expression => {+ const e = obj(item)+ if (!Array.isArray(e.beats) || !e.beats.length || e.beats.length > 32) throw new Error('Each expression needs 1–32 beats.')+ return { id: str(e.id, `expression-${index}`), name: str(e.name, 'Expression'), description: str(e.description, '', 160), ...(typeof e.poseExpressionId === 'string' && e.poseExpressionId ? { poseExpressionId: e.poseExpressionId } : {}), beats: e.beats.map((item, i) => { const b = obj(item); return { id: str(b.id, `beat-${i}`), name: str(b.name, `Beat ${i + 1}`), duration: num(b.duration, 1.5, .2, 15), pose: parsePose(b.pose), ...(b.gradientAction === 'rotate' || b.gradientAction === 'hold' ? { gradientAction: b.gradientAction } : {}) } }) }+ })+ if (new Set(expressions.map(e => e.id)).size !== expressions.length) throw new Error('Expression names in the file must have unique IDs.')+ for (const expression of expressions) {+ const seen = new Set([expression.id])+ let sourceId = expression.poseExpressionId+ while (sourceId) {+ const source = expressions.find(e => e.id === sourceId)+ if (!source) throw new Error('An expression refers to missing face motion.')+ if (seen.has(sourceId)) throw new Error('Face motion expressions cannot refer back to themselves.')+ seen.add(sourceId); sourceId = source.poseExpressionId+ }+ }+ const animations = v.animations.map((item, index): Animation => {+ const a = obj(item)+ if (!Array.isArray(a.steps) || !a.steps.length || a.steps.length > 64) throw new Error('Each animation needs 1–64 steps.')+ return { id: str(a.id, `animation-${index}`), name: str(a.name, 'Animation'), loop: boolean(a.loop, true), steps: a.steps.map((item, i) => { const s = obj(item); if (!expressions.some(e => e.id === s.expressionId)) throw new Error('An animation refers to a missing expression.'); return { id: str(s.id, `step-${i}`), expressionId: s.expressionId as string, duration: num(s.duration, 3, .2, 30) } }) }+ })+ const characters = charactersRaw.map(parseCharacter)+ if (new Set(characters.map(c => c.id)).size !== characters.length || new Set(animations.map(a => a.id)).size !== animations.length) throw new Error('Characters and animations need unique IDs.')+ return { version: 1, name: str(v.name, 'My character studio'), characters, expressions, animations, ...(typeof v.defaultsRevision === 'number' ? { defaultsRevision: num(v.defaultsRevision, 2, 0, 1000) } : {}) }+}++/** Upgrade only untouched studio defaults, once; portable definitions stay literal. */+export function upgradeStudioDefaults(project: Project): Project {+ if ((project.defaultsRevision ?? 0) >= 2) return project+ const defaults = defaultExpressions()+ for (const expression of project.expressions) {+ const preset = defaults.find(e => e.id === expression.id)+ if (!preset) continue+ for (const beat of expression.beats) if (beat.pose.faceScale === 1 && preset.beats.some(b => b.id === beat.id)) beat.pose.faceScale = .75+ if (expression.id === 'loading' && !expression.poseExpressionId && expression.beats.length === 2 && expression.beats.every(beat => {+ const original = preset.beats.find(b => b.id === beat.id)+ return original && original.gradientAction === beat.gradientAction && Object.keys(BASE_POSE).every(key => beat.pose[key as keyof Pose] === BASE_POSE[key as keyof Pose])+ }) && project.expressions.some(e => e.id === 'working')) expression.poseExpressionId = 'working'+ }+ project.defaultsRevision = 2+ return project+}diff --git a/packages/shared/src/cliplab/palette-tokens.ts b/packages/shared/src/cliplab/palette-tokens.tsnew file mode 100644index 0000000000..e8a547c9f4--- /dev/null+++ b/packages/shared/src/cliplab/palette-tokens.ts@@ -0,0 +1,75 @@+// Generated from ui/src/index.css by scripts/sync-agent-palette-tokens.mjs.+export const CAP_V1_COLORS = {+ "bubblegum-sky": {+ "a": "#8bd4ff",+ "b": "#ff51bf"+ },+ "pink-lemonade": {+ "a": "#ff26a8",+ "b": "#fff78a"+ },+ "orchid-peach": {+ "a": "#e771ff",+ "b": "#ffd87c"+ },+ "coral-mint": {+ "a": "#beffe8",+ "b": "#ff797b"+ },+ "lime-lagoon": {+ "a": "#b4ffa4",+ "b": "#26dfff"+ },+ "arctic-blue": {+ "a": "#97fff3",+ "b": "#0084ff"+ },+ "solar-flare": {+ "a": "#ecca5c",+ "b": "#fe3c3f"+ },+ "violet-ember": {+ "a": "#ff5c43",+ "b": "#6262ff"+ },+ "deep-tide": {+ "a": "#003d60",+ "b": "#32fffc"+ },+ "coral-current": {+ "a": "#26e2ff",+ "b": "#ff6666"+ },+ "golden-hour": {+ "a": "#ffcd4f",+ "b": "#fde5ba"+ },+ "tangerine-cobalt": {+ "a": "#ffad32",+ "b": "#4169ff"+ },+ "electric-grove": {+ "a": "#b4ff32",+ "b": "#008d58"+ },+ "flamingo-jade": {+ "a": "#ff4f9a",+ "b": "#36edaa"+ },+ "cherry-pop": {+ "a": "#ff69db",+ "b": "#d51c46"+ },+ "turquoise-cherry": {+ "a": "#37f0db",+ "b": "#ff4f64"+ },+ "ultraviolet-tide": {+ "a": "#7516cf",+ "b": "#00e8d1"+ },+ "muted-dream": {+ "a": "#a6aaad",+ "b": "#44464a"+ }+} as const;diff --git a/packages/shared/src/cliplab/renderer.ts b/packages/shared/src/cliplab/renderer.tsnew file mode 100644index 0000000000..bd6cb6fd6b--- /dev/null+++ b/packages/shared/src/cliplab/renderer.ts@@ -0,0 +1,463 @@+// Vendored from ClipLab a050f724; see PROVENANCE.md and LICENSE.+import * as THREE from 'three'+import { BASE_POSE, detailAt, type Character, type Detail, type FaceLayer, type Pose, type Sample, type Shape } from './model.js'+import { clampGaze, gazeAtPoint, irisOffset, localGaze, type EyeGazes, type Gaze, type PointerLook } from './gaze.js'+import { drawMorphBrow, drawMorphEye, drawMorphMouth, drawDrool, droolAnchor, mouthGeometry, traitWeight } from './face-morph.js'++export interface RenderOptions {+ width: number; height: number; displaySize?: number; background?: string | null+ cursor?: { x: number; y: number }; rotation?: { x: number; y: number; z: number }; zoom?: number; framing?: 'portrait' | 'character'; pixelRatio?: number+ pointerLook?: PointerLook; eyeGazes?: EyeGazes; reducedMotion?: boolean+}+/** Cursor pitch owns the vertical look direction, independent of the resting tilt. */+export function characterRotation(character: Pick<Character, 'trueFront' | 'followRotation'>, pose: Pick<Pose, 'rotationX' | 'rotationY' | 'rotationZ'>, rotation = { x: -5, y: -12, z: -7 }, cursor: Gaze = { x: 0, y: 0 }) {+ if (character.trueFront) return { x: 0, y: 0, z: 0 }+ return {+ x: character.followRotation ? -cursor.y * 16 : rotation.x + pose.rotationX,+ y: rotation.y + pose.rotationY + (character.followRotation ? cursor.x * 28 : 0),+ z: rotation.z + pose.rotationZ+ }+}+/** One rounded light region; the body-following toggle activates+ * a subtle light-source shift. The shared eased cursor keeps motion smooth. */+export function toonLightOffset(character: Pick<Character, 'followRotation'>, cursor: Gaze = { x: 0, y: 0 }, reducedMotion = false): Gaze {+ const look = !reducedMotion && character.followRotation ? clampGaze(cursor) : { x: 0, y: 0 }+ return { x: -.015 + look.x * .045, y: .015 + look.y * .045 }+}+/** Size adaptation is render-only; larger sizes restore the authored appearance. */+export function faceForSize(character: Character, sample: Sample, size: number) {+ const simpleEyes = size > 16 && size <= 48+ const frontOnly = size <= 24+ const flatFill = size < 48+ return {+ character: simpleEyes || flatFill ? { ...character, ...(simpleEyes ? { iris: false } : {}), ...(flatFill ? { toon: false, shadow: false } : {}), ...(frontOnly ? { trueFront: true, lockPosition: true, followRotation: false } : {}) } : character,+ sample: simpleEyes || frontOnly ? { ...sample, pose: { ...sample.pose, faceScale: sample.pose.faceScale * (simpleEyes ? 1.3 : 1), eyeSize: sample.pose.eyeSize * (size === 24 ? 1.2 : 1), ...(frontOnly ? { squash: 1 } : {}), ...(size === 24 ? { gazeX: -4, gazeY: 0, leftX: 0, rightX: 0, leftY: 0, rightY: 0, spacing: BASE_POSE.spacing * .7, faceY: BASE_POSE.faceY } : {}) } } : sample,+ simpleEyes+ }+}+export const bodyHeight = (shape: Shape) => shape === 'capsule' ? 2 : 1+export function radiusAt(shape: Shape, y: number): number {+ if (shape === 'sphere') return Math.sqrt(Math.max(0, .25 - y * y))+ if (shape === 'capsule') { const dy = Math.max(Math.abs(y) - .5, 0); return Math.sqrt(Math.max(0, .25 - dy * dy)) }+ if (y >= 0) return Math.sqrt(Math.max(0, .25 - y * y))+ if (y >= -.43) return .5+ return .43 + Math.sqrt(Math.max(0, .07 ** 2 - (y + .43) ** 2))+}+function geometryFor(shape: Shape, squareBottom = false): THREE.BufferGeometry {+ if (shape === 'sphere') return new THREE.SphereGeometry(.5, 80, 64)+ if (shape === 'capsule') return new THREE.CapsuleGeometry(.5, 1, 24, 80)+ const points = [new THREE.Vector2(0, -.5), new THREE.Vector2(squareBottom ? .5 : .43, -.5)]+ for (let i = 1; !squareBottom && i <= 12; i++) { const a = -Math.PI / 2 + i / 12 * Math.PI / 2; points.push(new THREE.Vector2(.43 + .07 * Math.cos(a), -.43 + .07 * Math.sin(a))) }+ points.push(new THREE.Vector2(.5, 0))+ for (let i = 1; i <= 32; i++) { const a = i / 32 * Math.PI / 2; points.push(new THREE.Vector2(.5 * Math.cos(a), .5 * Math.sin(a))) }+ return new THREE.LatheGeometry(points, 80)+}+const vertexShader = `+ uniform vec3 fillScale;+ uniform vec3 fillOffset;+ varying vec3 vPosition;+ void main() {+ vPosition = position * fillScale + fillOffset;+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);+ }+`+const fragmentShader = `+ uniform vec3 colorA;+ uniform vec3 colorB;+ uniform float gradientOn;+ uniform float toonOn;+ uniform float insetFill;+ uniform float angle;+ uniform float bodyHeight;+ varying vec3 vPosition;+ void main() {+ float t = clamp(0.5 + vPosition.y / bodyHeight * cos(angle) + vPosition.x * sin(angle), 0.0, 1.0);+ vec3 color = mix(colorA, mix(colorB, colorA, t), gradientOn);+ // The light fill uses an inset copy of the silhouette, with one crisp shade step.+ float shade = mix(0.8, 1.0, insetFill);+ gl_FragColor = vec4(color * mix(1.0, shade, toonOn), 1.0);+ #include <colorspace_fragment>+ }+`+function heart(ctx: CanvasRenderingContext2D, x: number, y: number, r: number) {+ ctx.beginPath(); ctx.moveTo(x, y + r)+ ctx.bezierCurveTo(x - r * 2, y - r * .1, x - r, y - r * 1.5, x, y - r * .55)+ ctx.bezierCurveTo(x + r, y - r * 1.5, x + r * 2, y - r * .1, x, y + r); ctx.closePath(); ctx.fill()+}+function star(ctx: CanvasRenderingContext2D, x: number, y: number, r: number, points = 5) {+ ctx.beginPath()+ for (let i = 0; i < points * 2; i++) { const a = i / (points * 2) * Math.PI * 2 - Math.PI / 2; const d = i % 2 ? r * .46 : r; const px = x + Math.cos(a) * d, py = y + Math.sin(a) * d; i ? ctx.lineTo(px, py) : ctx.moveTo(px, py) }+ ctx.closePath(); ctx.fill()+}++const faceAspect = .76 / .57+const smoothstep = (a: number, b: number, x: number) => { const t = Math.max(0, Math.min(1, (x - a) / (b - a))); return t * t * (3 - 2 * t) }+const fract = (v: number) => ((v % 1) + 1) % 1+export function effectEnvelope(phase: number) { const t = fract(phase); return smoothstep(0, .18, t) * (1 - smoothstep(.72, 1, t)) }+export function eyeRadius(pose: Pose, character: Character, detail: Detail, side: number) { return (detail === 'eyes' ? 29 : 27) * pose.eyeSize * (side < 0 ? pose.leftScale : pose.rightScale) * (character.iris ? 1.2 : 1) }++export function projectedEye(character: Character, pose: Pose, blink: number, side: number, matrix: THREE.Matrix4, camera: THREE.Camera, layers?: FaceLayer[]) {+ const radius = eyeRadius(pose, character, 'full', side)+ const cx = 256 + side * 103 * pose.spacing + (side < 0 ? pose.leftX : pose.rightX)+ const cy = 197 - (side < 0 ? pose.leftY : pose.rightY)+ const angle = (pose.eyeTilt * side + (side < 0 ? pose.leftRotation : pose.rightRotation)) * Math.PI / 180+ const h = Math.max(.12, 1 - blink) * pose.eyeHeight * (1 - .35 * (layers ? traitWeight(layers, t => t.eye === 'soft') : pose.eye === 'soft' ? 1 : 0))+ const shell = character.elevated ? 1 + character.elevation : 1.003+ const project = (dx: number, dy: number) => {+ const tx = cx + Math.cos(angle) * dx - Math.sin(angle) * dy * h+ const ty = cy + faceAspect * (Math.sin(angle) * dx + Math.cos(angle) * dy * h)+ const x = (tx / 512 - .5) * .76 * pose.faceScale+ const y = (.5 - ty / 512) * .57 * pose.faceScale + (character.shape === 'capsule' ? -.14 : -.025) + pose.faceY+ const r = shell * radiusAt(character.shape, y / shell)+ return new THREE.Vector3(x, y, Math.sqrt(Math.max(.001, r * r - x * x))).applyMatrix4(matrix).project(camera)+ }+ const center = project(0, 0)+ // Central differences follow the tangent of the curved face at this eye.+ const right = project(radius * .1, 0).sub(project(-radius * .1, 0)).multiplyScalar(5).add(center)+ const up = project(0, -radius * .1).sub(project(0, radius * .1)).multiplyScalar(5).add(center)+ return { center, right, up }+}++/** Resting highlights are local to the face, so they remain up-left when tilted. */+function irisRestGaze(character: Pick<Character, 'iris' | 'followCursor'>, gaze: Gaze, reducedMotion = false): Gaze {+ if (!character.iris) return gaze+ if (reducedMotion) return { x: -.22, y: .22 }+ return character.followCursor ? gaze : { x: gaze.x - .22, y: gaze.y + .22 }+}++export function resolveEyeGazes(character: Character, pose: Pose, blink: number, matrix: THREE.Matrix4, camera: THREE.Camera, gaze: Gaze, pointer?: PointerLook, layers?: FaceLayer[]): EyeGazes {+ const eye = (side: number) => {+ const base = localGaze({ x: pose.gazeX + gaze.x, y: pose.gazeY + gaze.y }, pose.eyeTilt * side + (side < 0 ? pose.leftRotation : pose.rightRotation))+ if (!pointer?.weight) return base+ const { center, right, up } = projectedEye(character, pose, blink, side, matrix, camera, layers)+ const look = gazeAtPoint(pointer, center, right, up), weight = Math.max(0, Math.min(1, pointer.weight))+ return { x: base.x + (look.x - base.x) * weight, y: base.y + (look.y - base.y) * weight }+ }+ return { left: eye(-1), right: eye(1) }+}+function drop(ctx: CanvasRenderingContext2D, x: number, y: number, r: number) {+ ctx.beginPath(); ctx.moveTo(x, y - r * 1.5); ctx.bezierCurveTo(x - r * .25, y - r * .8, x - r, y - r * .2, x - r, y + r * .35); ctx.bezierCurveTo(x - r, y + r * 1.65, x + r, y + r * 1.65, x + r, y + r * .35); ctx.bezierCurveTo(x + r, y - r * .2, x + r * .25, y - r * .8, x, y - r * 1.5); ctx.fill()+}+export function drawFace(ctx: CanvasRenderingContext2D, pose: Pose, character: Character, blink: number, detail: Detail, gaze: { x: number; y: number }, effects: { phase?: number; tearAmount?: number; eyeGazes?: EyeGazes; faceLayers?: FaceLayer[]; simpleEyes?: boolean } = {}) {+ ctx.clearRect(0, 0, 512, 512)+ if (detail === 'body') return+ const ink = character.eyeColor, eyeY = detail === 'eyes' ? 254 : 197, spacing = 103 * pose.spacing+ const internalGaze = character.iris && detail === 'full'+ const gx = internalGaze ? 0 : (pose.gazeX + gaze.x) * 20, gy = internalGaze ? 0 : -(pose.gazeY + gaze.y) * 15+ const layers = effects.faceLayers+ const pupilAmount = !effects.simpleEyes && detail === 'full' ? layers ? traitWeight(layers, t => t.eye === 'pupil') : pose.eye === 'pupil' ? 1 : 0 : 0+ ctx.lineCap = 'round'; ctx.lineJoin = 'round'+ for (const side of [-1, 1]) {+ const r = eyeRadius(pose, character, detail, side)+ const eyeGaze = side < 0 ? effects.eyeGazes?.left : effects.eyeGazes?.right+ const pupilEyes = !effects.simpleEyes && pose.eye === 'pupil' && detail === 'full'+ const x = 256 + side * spacing + gx * (1 - pupilAmount) + (side < 0 ? pose.leftX : pose.rightX), y = eyeY + gy * (1 - pupilAmount) - (side < 0 ? pose.leftY : pose.rightY)+ if (detail === 'full' && pose.blush > 0) {+ ctx.save(); ctx.globalAlpha = pose.blush * .8; ctx.fillStyle = '#ff647a'; ctx.beginPath(); ctx.ellipse(x + side * 20, y + 56, 31, 24 * faceAspect, 0, 0, Math.PI * 2); ctx.fill(); ctx.restore()+ }+ const localRotation = side < 0 ? pose.leftRotation : pose.rightRotation+ // Equal world units in X/Y: the face mesh is wider than it is tall.+ ctx.save(); ctx.translate(x, y); ctx.scale(1, faceAspect); ctx.rotate((pose.eyeTilt * side + localRotation) * Math.PI / 180)+ ctx.fillStyle = ink; ctx.strokeStyle = ink; ctx.lineWidth = Math.max(13, r * .43)+ const happyMouth = ['open', 'grin', 'smile', 'u-smile'].includes(pose.mouth)+ const closed = ['closed', 'arc-up', 'arc-down'].includes(pose.eye) || (pose.eye === 'wink' && side > 0) || (detail === 'eyes' && ['open', 'grin'].includes(pose.mouth) && pose.eye === 'dot')+ if (effects.simpleEyes) {+ // Keep literal round dots even at eyes-only sizes or between styled beats.+ ctx.fillStyle = '#000000'; ctx.scale(1, Math.max(.12, 1 - blink))+ ctx.beginPath(); ctx.arc(0, 0, r, 0, Math.PI * 2); ctx.fill()+ } else if (layers) {+ const look = eyeGaze ?? localGaze({ x: pose.gazeX + gaze.x, y: pose.gazeY + gaze.y }, pose.eyeTilt * side + localRotation)+ drawMorphEye(ctx, pose, layers, r, side, blink, detail, ink, character.iris, look)+ } else if (pose.faceSet === 'set-2' && pose.eye === 'wink' && side > 0) {+ ctx.beginPath(); ctx.moveTo(r * .7, -r * .65); ctx.lineTo(-r * .55, 0); ctx.lineTo(r * .7, r * .65); ctx.stroke()+ } else if (closed) {+ const up = pose.eye === 'arc-up' || (pose.eye !== 'arc-down' && happyMouth)+ ctx.beginPath(); ctx.arc(0, 0, r, up ? Math.PI : 0, up ? Math.PI * 2 : Math.PI); ctx.stroke()+ } else if (pose.eye === 'squint') {+ ctx.beginPath(); ctx.moveTo(-r * side * .7, -r * .8); ctx.lineTo(r * side * .6, 0); ctx.lineTo(-r * side * .7, r * .8); ctx.stroke()+ } else if (blink > .7) {+ ctx.beginPath(); ctx.moveTo(-r, 0); ctx.lineTo(r, 0); ctx.stroke()+ } else {+ const h = Math.max(.12, 1 - blink) * pose.eyeHeight * (pose.eye === 'soft' ? .65 : 1)+ ctx.scale(1, h)+ if (pose.cheeks) {+ // The cheek is transparent, revealing the live shaded body beneath the eye.+ ctx.beginPath(); ctx.rect(-r * 2, -r * 2, r * 4, r * 4); ctx.moveTo(r * .82, r * 1.13); ctx.arc(0, r * 1.13, r * .82, 0, Math.PI * 2); ctx.clip('evenodd')+ }+ if (pose.eye === 'star') star(ctx, 0, 0, r * 1.2)+ else if (pose.eye === 'heart') { if (pose.faceSet === 'set-2' && detail === 'full') ctx.fillStyle = '#ff3f58'; heart(ctx, 0, 0, r) }+ else if (pose.eye === 'half-lidded') { ctx.beginPath(); ctx.arc(0, 0, r, 0, Math.PI); ctx.closePath(); ctx.fill() }+ else if (pupilEyes) {+ const outer = r * 1.5+ ctx.fillStyle = '#fffef9'; ctx.beginPath(); ctx.arc(0, 0, outer, 0, Math.PI * 2); ctx.fill(); ctx.clip()+ const look = eyeGaze ?? { x: pose.gazeX + gaze.x, y: pose.gazeY + gaze.y }+ ctx.fillStyle = ink; ctx.beginPath(); ctx.arc(look.x * outer * .52, -look.y * outer * .52, outer * .4, 0, Math.PI * 2); ctx.fill()+ }+ else { ctx.beginPath(); ctx.arc(0, 0, r, 0, Math.PI * 2); ctx.fill() }+ if (internalGaze && !pupilEyes && pose.eye !== 'half-lidded') {+ // The eye path also clips star/heart shapes and intersects cheek cutouts.+ ctx.clip()+ const dot = irisOffset(r, eyeGaze ?? { x: pose.gazeX + gaze.x, y: pose.gazeY + gaze.y }, eyeGaze ? 0 : pose.eyeTilt * side + localRotation, pose.cheeks)+ ctx.fillStyle = '#ffffff'; ctx.beginPath(); ctx.arc(dot.x, dot.y, r * .28, 0, Math.PI * 2); ctx.fill()+ }+ }+ ctx.restore()+ if (detail === 'full' && layers) {+ ctx.save(); ctx.translate(x, y - r * (1.45 + .35 * pupilAmount)); ctx.scale(1, faceAspect)+ drawMorphBrow(ctx, layers, r, side, ink); ctx.restore()+ } else if (detail === 'full' && pose.brows !== 'none') {+ ctx.save(); ctx.translate(x, y - (pupilEyes ? r * 1.8 : r * 1.45)); ctx.scale(1, faceAspect); ctx.strokeStyle = ink; ctx.lineWidth = 12; ctx.beginPath()+ if (pose.brows === 'raised') { ctx.arc(0, 10, r * .85, Math.PI * 1.15, Math.PI * 1.85) }+ else if (pose.brows === 'worried') { ctx.moveTo(side * r, 2); ctx.quadraticCurveTo(-side * r * .1, 10, -side * r * .75, -16) }+ else { ctx.moveTo(side * r, -10); ctx.lineTo(-side * r * .75, 8) }+ ctx.stroke(); ctx.restore()+ }+ if (pose.tears && detail === 'full') {+ const phase = fract((effects.phase ?? .35) + (side < 0 ? .46 : 0)), alpha = effectEnvelope(phase) * (effects.tearAmount ?? 1)+ ctx.save(); ctx.translate(x + side * (r + 18), y + 23 + phase * phase * 123); ctx.scale(1, faceAspect); ctx.rotate(-side * .2); ctx.globalAlpha = alpha; ctx.fillStyle = '#f6fdff'; drop(ctx, 0, 0, 12 + phase * 3); ctx.restore()+ }+ }+ if (detail === 'eyes') return+ if (layers) {+ ctx.save(); ctx.translate(256 + gx * .25, 293 + gy * .25); ctx.scale(1, faceAspect)+ drawMorphMouth(ctx, pose, layers, ink); ctx.restore(); return+ }+ const x = 256 + gx * .25, y = (pose.mouth === 'cry' ? 329 : 293) + gy * .25+ const broad = ['open', 'grin', 'cry'].includes(pose.mouth), w = (broad ? 124 : pose.mouth === 'oh' ? 51 : 61) * pose.mouthWidth+ const line = 17 * pose.mouthStroke+ ctx.save(); ctx.translate(x, y); ctx.scale(1, faceAspect); ctx.fillStyle = ink; ctx.strokeStyle = ink; ctx.lineWidth = line; ctx.beginPath()+ if (pose.mouth === 'smile') { ctx.arc(0, -10, w, Math.PI * .18, Math.PI * .82); ctx.stroke() }+ else if (pose.mouth === 'u-smile') { ctx.arc(0, -8, w * .56, 0, Math.PI); ctx.stroke() }+ else if (pose.mouth === 'frown') { ctx.arc(0, 39, w, Math.PI * 1.2, Math.PI * 1.8); ctx.stroke() }+ else if (pose.mouth === 'line' || pose.mouth === 'sleep') { ctx.moveTo(-w * .58, 0); ctx.lineTo(w * .58, 0); ctx.stroke() }+ else if (pose.mouth === 'kiss') { ctx.moveTo(-w * .25, -21); ctx.bezierCurveTo(w * .48, -34, w * .53, -2, 0, 0); ctx.bezierCurveTo(w * .53, 2, w * .48, 34, -w * .25, 21); ctx.stroke() }+ else if (pose.mouth === 'tongue-out') {+ ctx.beginPath(); ctx.moveTo(-w, -9); ctx.quadraticCurveTo(0, -2, w, -9); ctx.stroke()+ ctx.fillStyle = '#ff526c'; ctx.beginPath(); ctx.moveTo(-w * .6, 5); ctx.lineTo(w * .6, 5); ctx.bezierCurveTo(w * .88, 85 * pose.mouthOpen + 28, -w * .88, 85 * pose.mouthOpen + 28, -w * .6, 5); ctx.fill()+ }+ else if (pose.mouth === 'wave') { ctx.moveTo(-w, 4); ctx.bezierCurveTo(-w * .35, -25, w * .35, 25, w, -4); ctx.stroke() }+ else {+ const h = (broad ? 48 : 22) + 72 * pose.mouthOpen+ if (pose.mouth === 'oh') ctx.arc(0, 14, w * (.55 + .3 * pose.mouthOpen), 0, Math.PI * 2)+ else if (pose.mouth === 'cry') { ctx.moveTo(-w, 30); ctx.bezierCurveTo(-w * 1.1, -h, w * 1.1, -h, w, 30); ctx.quadraticCurveTo(w, 44, w * .76, 38); ctx.quadraticCurveTo(0, 24, -w * .76, 38); ctx.quadraticCurveTo(-w, 44, -w, 30) }+ else { const tilt = pose.mouth === 'grin' ? 24 : 0; ctx.moveTo(-w, -11); ctx.quadraticCurveTo(0, 5, w, -11 - tilt); ctx.bezierCurveTo(w * 1.02, h, -w * 1.02, h, -w, -11) }+ ctx.closePath(); ctx.fill(); ctx.save(); ctx.clip()+ if (pose.tongue) { ctx.fillStyle = '#f37b83'; ctx.beginPath(); ctx.ellipse(10, h * .65, w * .65, h * .34, -.1, 0, Math.PI * 2); ctx.fill() }+ if (pose.teeth) { ctx.fillStyle = '#fffef8'; ctx.beginPath(); ctx.roundRect(-w * .76, -23, w * 1.52, 30, 12); ctx.fill() }+ ctx.restore()+ // Rebuild the outer path after the clipped interior details changed the canvas path.+ ctx.beginPath()+ if (pose.mouth === 'oh') ctx.arc(0, 14, w * (.55 + .3 * pose.mouthOpen), 0, Math.PI * 2)+ else if (pose.mouth === 'cry') { ctx.moveTo(-w, 30); ctx.bezierCurveTo(-w * 1.1, -h, w * 1.1, -h, w, 30); ctx.quadraticCurveTo(w, 44, w * .76, 38); ctx.quadraticCurveTo(0, 24, -w * .76, 38); ctx.quadraticCurveTo(-w, 44, -w, 30) }+ else { const tilt = pose.mouth === 'grin' ? 24 : 0; ctx.moveTo(-w, -11); ctx.quadraticCurveTo(0, 5, w, -11 - tilt); ctx.bezierCurveTo(w * 1.02, h, -w * 1.02, h, -w, -11) }+ ctx.closePath(); ctx.strokeStyle = ink; ctx.stroke()+ }+ if (pose.drool) {+ const anchor = droolAnchor(mouthGeometry(pose).outline, w)+ if (pose.mouth === 'cry') anchor.y -= 27+ drawDrool(ctx, anchor)+ }+ ctx.restore()+}++export function drawProp(ctx: CanvasRenderingContext2D, prop: Pose['prop'], color: string, phase?: number) {+ ctx.clearRect(0, 0, 256, 256)+ const count = ['zzz', 'sparkle', 'heart'].includes(prop) ? 3 : 1+ for (let i = 0; i < count; i++) {+ const p = fract((phase ?? .34) + i * .29), ease = p * p+ ctx.save(); ctx.globalAlpha = phase === undefined ? 1 : effectEnvelope(p)+ ctx.translate(prop === 'zzz' ? 45 + i * 64 + ease * 36 : count === 1 ? 128 : 51 + i * 69, prop === 'zzz' ? 204 - i * 58 - ease * 54 : count === 1 ? 132 - ease * 26 : 198 - i * 60 - ease * 38)+ const scale = phase === undefined ? 1 : .62 + .38 * smoothstep(0, .38, p)+ ctx.scale(scale, scale); ctx.fillStyle = color; ctx.strokeStyle = color; ctx.lineWidth = 11; ctx.lineCap = 'round'; ctx.lineJoin = 'round'+ if (prop === 'zzz') { const r = 14 + i * 5; ctx.beginPath(); ctx.moveTo(-r, -r); ctx.lineTo(r, -r); ctx.lineTo(-r, r); ctx.lineTo(r, r); ctx.stroke() }+ else if (prop === 'sparkle') star(ctx, 0, 0, 23 + i * 4, 4)+ else if (prop === 'heart') heart(ctx, 0, 0, 17 + i * 3)+ else if (prop === 'question') { ctx.font = 'bold 144px sans-serif'; ctx.textAlign = 'center'; ctx.fillText('?', 0, 48) }+ else if (prop === 'sweat') drop(ctx, 0, 0, 38)+ else if (prop === 'crown') { ctx.beginPath(); ctx.moveTo(-78, 42); ctx.lineTo(-94, -45); ctx.lineTo(-35, -3); ctx.lineTo(0, -67); ctx.lineTo(35, -3); ctx.lineTo(94, -45); ctx.lineTo(78, 42); ctx.closePath(); ctx.fill() }+ ctx.restore()+ }+}++export class CharacterRenderer {+ readonly canvas: HTMLCanvasElement | null+ readonly gl: THREE.WebGLRenderer | null+ private scene = new THREE.Scene()+ private camera = new THREE.OrthographicCamera(-1, 1, 1, -1, .1, 30)+ private root = new THREE.Group()+ private body: THREE.Mesh<THREE.BufferGeometry, THREE.ShaderMaterial>+ private lightFill: THREE.Mesh<THREE.BufferGeometry, THREE.ShaderMaterial>+ private face: THREE.Mesh<THREE.PlaneGeometry, THREE.MeshBasicMaterial>+ private faceCanvas: HTMLCanvasElement | null = null+ private faceCtx: CanvasRenderingContext2D | null = null+ private faceTexture: THREE.CanvasTexture | null = null+ private propCanvas: HTMLCanvasElement | null = null+ private propCtx: CanvasRenderingContext2D | null = null+ private propTexture: THREE.CanvasTexture | null = null+ private prop: THREE.Sprite+ private shadow: THREE.Mesh<THREE.CircleGeometry, THREE.MeshBasicMaterial>+ private shape: Shape = 'capsule'+ private squareBottom = false+ private lastFaceKey = ''+ private resolvedEyes: EyeGazes | undefined+ private lastProp = ''+ private disposed = false+ private options: RenderOptions+ private captured?: { character: Character; sample: Sample; gaze: Gaze; simpleEyes: boolean }+ constructor(canvas: HTMLCanvasElement | null, options: RenderOptions) {+ this.canvas = canvas; this.options = options+ this.gl = null+ if (canvas) {+ this.faceCanvas = document.createElement('canvas')+ this.propCanvas = document.createElement('canvas')+ this.gl = new THREE.WebGLRenderer({ canvas, antialias: true, alpha: true, preserveDrawingBuffer: true, powerPreference: 'low-power' })+ this.gl.outputColorSpace = THREE.SRGBColorSpace+ this.gl.setPixelRatio(options.pixelRatio ?? Math.min(Math.max(window.devicePixelRatio || 1, 1) * 2, 4))+ this.faceCanvas.width = this.faceCanvas.height = 1024+ this.faceCtx = this.faceCanvas.getContext('2d')!+ this.faceCtx.scale(2, 2)+ this.faceTexture = new THREE.CanvasTexture(this.faceCanvas); this.faceTexture.colorSpace = THREE.SRGBColorSpace+ this.faceTexture.generateMipmaps = true; this.faceTexture.minFilter = THREE.LinearMipmapLinearFilter+ this.propCanvas.width = this.propCanvas.height = 512; this.propCtx = this.propCanvas.getContext('2d')!; this.propCtx.scale(2, 2)+ this.propTexture = new THREE.CanvasTexture(this.propCanvas); this.propTexture.colorSpace = THREE.SRGBColorSpace+ }+ const material = new THREE.ShaderMaterial({+ uniforms: { colorA: { value: new THREE.Color() }, colorB: { value: new THREE.Color() }, gradientOn: { value: 1 }, toonOn: { value: 1 }, insetFill: { value: 0 }, fillScale: { value: new THREE.Vector3(1, 1, 1) }, fillOffset: { value: new THREE.Vector3() }, angle: { value: 0 }, bodyHeight: { value: 2 } }, vertexShader, fragmentShader+ })+ this.body = new THREE.Mesh(geometryFor('capsule'), material)+ const fillMaterial = material.clone(); fillMaterial.depthTest = false; fillMaterial.depthWrite = false; fillMaterial.uniforms.insetFill!.value = 1+ this.lightFill = new THREE.Mesh(new THREE.CapsuleGeometry(.42, .94, 24, 80), fillMaterial); this.lightFill.renderOrder = 1+ this.face = new THREE.Mesh(new THREE.PlaneGeometry(1, 1, 56, 40), new THREE.MeshBasicMaterial({ map: this.faceTexture, transparent: true, alphaTest: .008, depthWrite: false, side: THREE.FrontSide, toneMapped: false }))+ this.face.geometry.setAttribute('faceValid', new THREE.BufferAttribute(new Float32Array(this.face.geometry.attributes.position!.count).fill(1), 1))+ this.face.material.onBeforeCompile = shader => {+ shader.vertexShader = 'attribute float faceValid; varying float vFaceValid;\n' + shader.vertexShader.replace('#include <begin_vertex>', '#include <begin_vertex>\nvFaceValid = faceValid;')+ shader.fragmentShader = 'varying float vFaceValid;\n' + shader.fragmentShader.replace('void main() {', 'void main() {\nif (vFaceValid < 0.99) discard;')+ }+ this.prop = new THREE.Sprite(new THREE.SpriteMaterial({ map: this.propTexture, transparent: true, depthWrite: false, toneMapped: false }))+ this.shadow = new THREE.Mesh(new THREE.CircleGeometry(.35, 64), new THREE.MeshBasicMaterial({ color: '#809299', transparent: true, opacity: .2, depthWrite: false }))+ this.root.add(this.body, this.lightFill, this.face, this.prop); this.scene.add(this.root, this.shadow)+ this.camera.position.set(0, 0, 8); this.camera.lookAt(0, 0, 0)+ this.resize(options.width, options.height, options.displaySize)+ }+ resize(width: number, height: number, displaySize?: number) {+ this.options = { ...this.options, width: Math.max(1, width), height: Math.max(1, height), displaySize: displaySize ?? Math.min(width, height) }+ this.gl?.setSize(this.options.width, this.options.height, false)+ }+ render(character: Character, sample: Sample, options: Partial<RenderOptions> = {}, gaze = { x: 0, y: 0 }) {+ if (this.disposed) return+ this.options = { ...this.options, ...options }+ const displaySize = this.options.displaySize ?? Math.min(this.options.width, this.options.height)+ const appearance = faceForSize(character, sample, displaySize)+ character = appearance.character; sample = appearance.sample+ const squareBottom = character.shape === 'cap' && displaySize <= 24+ if (character.shape !== this.shape || squareBottom !== this.squareBottom) { this.shape = character.shape; this.squareBottom = squareBottom; this.body.geometry.dispose(); this.body.geometry = geometryFor(this.shape, squareBottom); this.lightFill.geometry.dispose(); this.lightFill.geometry = this.shape === 'capsule' ? new THREE.CapsuleGeometry(.42, .94, 24, 80) : geometryFor(this.shape) }+ const { pose } = sample+ const height = bodyHeight(this.shape)+ const detail = detailAt(displaySize)+ const u = this.body.material.uniforms+ ;(u.colorA!.value as THREE.Color).set(character.color); (u.colorB!.value as THREE.Color).set(character.color2)+ u.gradientOn!.value = character.gradient ? 1 : (sample.gradientMix ?? (sample.gradientRotation !== undefined ? 1 : 0)); u.toonOn!.value = character.toon ? 1 : 0+ u.angle!.value = (character.gradientAngle + (sample.gradientRotation ?? 0)) * Math.PI / 180; u.bodyHeight!.value = height+ const rotation = characterRotation(this.options.reducedMotion ? { ...character, followRotation: false } : character, pose, this.options.rotation, this.options.cursor)+ this.root.rotation.set(rotation.x * Math.PI / 180, rotation.y * Math.PI / 180, rotation.z * Math.PI / 180, 'YXZ')+ this.root.position.y = character.lockPosition ? 0 : sample.bob * .025 * height+ const stretch = pose.squash + (character.lockPosition ? 0 : sample.breathe * .008)+ this.root.scale.set(1 / Math.sqrt(stretch), stretch, 1 / Math.sqrt(stretch))+ this.lightFill.visible = character.toon+ const fillScale = this.shape === 'capsule' ? 1 : .85+ this.lightFill.scale.setScalar(fillScale)+ this.root.updateMatrixWorld(true)+ // Shift the inset toward the pointer in the camera plane, not the tilted+ // body's axes. Bound travel by the narrowest stretch to retain a dark rim.+ const lightTarget = toonLightOffset(character, this.options.cursor, this.options.reducedMotion)+ const lightScale = Math.min(this.root.scale.x, this.root.scale.y, this.root.scale.z)+ const lightOffset = new THREE.Vector3(lightTarget.x * lightScale, lightTarget.y * lightScale, 0).applyMatrix4(new THREE.Matrix4().copy(this.root.matrixWorld).invert())+ .sub(new THREE.Vector3().applyMatrix4(new THREE.Matrix4().copy(this.root.matrixWorld).invert()))+ this.lightFill.position.copy(lightOffset)+ const fu = this.lightFill.material.uniforms+ for (const name of ['colorA', 'colorB']) (fu[name]!.value as THREE.Color).copy(u[name]!.value as THREE.Color)+ for (const name of ['gradientOn', 'toonOn', 'angle', 'bodyHeight']) fu[name]!.value = u[name]!.value+ ;(fu.fillScale!.value as THREE.Vector3).setScalar(fillScale); (fu.fillOffset!.value as THREE.Vector3).copy(lightOffset)+ const zoom = displaySize <= 128 ? 1 : this.options.zoom ?? 1+ const aspect = this.options.width / this.options.height+ // Small assets use a tight body fit instead of the companion preview padding.+ const padding = this.options.framing === 'character' ? .82 : displaySize <= 128 ? .55 : .72+ let half = Math.max(height * padding, padding / aspect) / zoom+ if (displaySize === 48 || displaySize === 96) {+ // A sphere bounds every rotation, avoiding angle-dependent zoom changes.+ if (!this.body.geometry.boundingSphere) this.body.geometry.computeBoundingSphere()+ const sphere = this.body.geometry.boundingSphere!+ const radius = (sphere.radius + sphere.center.length()) * Math.max(1, this.root.scale.x, this.root.scale.y, this.root.scale.z)+ const safeHalf = (radius + this.root.position.length()) / .9+ half = Math.max(half, safeHalf, safeHalf / aspect)+ }+ this.camera.left = -half * aspect; this.camera.right = half * aspect; this.camera.top = half; this.camera.bottom = -half; this.camera.updateProjectionMatrix()+ this.camera.updateMatrixWorld(true)+ this.face.visible = detail !== 'body'+ // Pointer directions stay relative to the screen when the character rolls or turns.+ const reduced = !!this.options.reducedMotion+ const screenGaze = reduced ? { x: 0, y: 0 } : gaze+ const turnGaze = !reduced && !character.followCursor && character.followRotation && !character.trueFront ? this.options.cursor ?? { x: 0, y: 0 } : { x: 0, y: 0 }+ const local = character.iris ? new THREE.Vector3(screenGaze.x + turnGaze.x * .5, screenGaze.y + turnGaze.y * .5, 0).applyQuaternion(this.root.quaternion.clone().invert()) : screenGaze+ const faceGaze = displaySize === 24 ? { x: 0, y: 0 } : irisRestGaze(character, local, reduced)+ this.resolvedEyes = !appearance.simpleEyes && detail === 'full' && (character.iris || pose.eye === 'pupil' || sample.faceLayers?.some(l => l.traits.eye === 'pupil')) ? (!reduced ? this.options.eyeGazes : undefined) ?? resolveEyeGazes(character, reduced ? { ...pose, gazeX: 0, gazeY: 0 } : pose, sample.blink, this.root.matrixWorld, this.camera, faceGaze, !reduced && character.followCursor ? this.options.pointerLook : undefined, sample.faceLayers) : undefined+ const key = JSON.stringify([pose, sample.faceLayers, character.eyeColor, character.iris, appearance.simpleEyes, sample.blink.toFixed(3), pose.tears ? sample.effectPhase?.toFixed(2) : 0, sample.tearAmount, detail, faceGaze.x.toFixed(3), faceGaze.y.toFixed(3), this.resolvedEyes])+ if (this.faceCtx && this.faceTexture && key !== this.lastFaceKey) { drawFace(this.faceCtx, pose, character, sample.blink, detail, faceGaze, { phase: sample.effectPhase, tearAmount: sample.tearAmount, eyeGazes: this.resolvedEyes, faceLayers: sample.faceLayers, simpleEyes: appearance.simpleEyes }); this.faceTexture.needsUpdate = true; this.lastFaceKey = key }+ const vertices = this.face.geometry.attributes.position!+ const uv = this.face.geometry.attributes.uv!+ const valid = this.face.geometry.attributes.faceValid!+ const shell = character.elevated ? 1 + character.elevation : 1.003+ const scale = pose.faceScale+ const offset = (this.shape === 'capsule' ? -.14 : -.025) + pose.faceY+ for (let i = 0; i < vertices.count; i++) {+ const x = (uv.getX(i) - .5) * .76 * scale+ const y = (uv.getY(i) - .5) * .57 * scale + offset+ const r = shell * radiusAt(this.shape, y / shell)+ const z = Math.sqrt(Math.max(.001, r * r - x * x))+ vertices.setXYZ(i, x, y, z)+ valid.setX(i, x * x < r * r && Math.abs(y) < height / 2 * shell ? 1 : 0)+ }+ vertices.needsUpdate = true; valid.needsUpdate = true; this.face.geometry.computeBoundingSphere()+ this.prop.visible = detail === 'full' && pose.prop !== 'none'+ this.prop.material.depthTest = pose.prop !== 'zzz'+ this.prop.renderOrder = pose.prop === 'zzz' ? 2 : 0+ const propKey = `${pose.prop}:${sample.effectPhase?.toFixed(2) ?? 'still'}`+ if (this.propCtx && this.propTexture && propKey !== this.lastProp) { drawProp(this.propCtx, pose.prop, pose.prop === 'heart' ? '#ff768c' : pose.prop === 'sweat' ? '#b7e9ff' : '#ffd362', sample.effectPhase); this.propTexture.needsUpdate = true; this.lastProp = propKey }+ const propSize = this.shape === 'capsule' ? .42 : .32+ this.prop.scale.setScalar(propSize * (.7 + .3 * (sample.propAmount ?? 1))); this.prop.material.opacity = sample.propAmount ?? 1+ this.prop.position.set(pose.prop === 'crown' ? 0 : .56, pose.prop === 'crown' ? height / 2 + .08 : height * .29, .15)+ this.shadow.visible = character.shadow && detail === 'full'+ this.shadow.position.set(0, -height * .58, -.2)+ this.shadow.scale.set((1 - (character.lockPosition ? 0 : sample.bob) * .06) * (this.shape === 'capsule' ? 1 : .95), .12, 1)+ const bg = this.options.background+ if (bg) this.gl?.setClearColor(bg, 1); else this.gl?.setClearColor(0x000000, 0)+ this.scene.updateMatrixWorld(true)+ this.gl?.render(this.scene, this.camera)+ this.captured = { character, sample, gaze: faceGaze, simpleEyes: appearance.simpleEyes }+ }+ snapshotScene() {+ if (!this.captured) throw new Error('Render the character before taking a snapshot.')+ return { ...this.captured, options: this.options, camera: this.camera, body: this.body, lightFill: this.lightFill, face: this.face, prop: this.prop, shadow: this.shadow, eyeGazes: this.resolvedEyes }+ }+ orientation() { return this.root.quaternion.clone() }+ eyeGazes() { return this.resolvedEyes ? { left: { ...this.resolvedEyes.left }, right: { ...this.resolvedEyes.right } } : undefined }+ dispose() {+ if (this.disposed) return+ this.disposed = true+ this.body.geometry.dispose(); this.body.material.dispose(); this.lightFill.geometry.dispose(); this.lightFill.material.dispose(); this.face.geometry.dispose(); this.face.material.dispose()+ this.faceTexture?.dispose(); this.propTexture?.dispose(); this.prop.material.dispose(); this.shadow.geometry.dispose(); this.shadow.material.dispose()+ this.gl?.dispose(); this.gl?.forceContextLoss()+ }+}++let thumbRenderer: CharacterRenderer | undefined+const thumbs = new Map<string, string>()+export function thumbnail(character: Character, pose: Pose = BASE_POSE, size = 96): string {+ const key = JSON.stringify([character, pose, size])+ const cached = thumbs.get(key); if (cached) return cached+ try {+ if (!thumbRenderer) thumbRenderer = new CharacterRenderer(document.createElement('canvas'), { width: 192, height: 192, pixelRatio: 1, displaySize: size })+ thumbRenderer.render({ ...character, shadow: false }, { pose, blink: 0, bob: 0, breathe: 0, expressionId: '', beatIndex: 0, stepIndex: 0 }, { displaySize: size, rotation: { x: -3, y: -8, z: -5 }, zoom: 1.08 })+ const url = thumbRenderer.canvas!.toDataURL('image/png'); if (thumbs.size > 250) thumbs.clear(); thumbs.set(key, url); return url+ } catch { return '' }+}diff --git a/packages/shared/src/cliplab/runtime.ts b/packages/shared/src/cliplab/runtime.tsnew file mode 100644index 0000000000..e73b5b91ec--- /dev/null+++ b/packages/shared/src/cliplab/runtime.ts@@ -0,0 +1,82 @@+// ClipLab runtime adapted for Paperclip; geometry/animation model remain upstream.+// See PROVENANCE.md and LICENSE.+import { CharacterRenderer } from './renderer.js'+import { sampleDefinition, animationDuration, type Definition } from './model.js'+import { centeredGaze, easeGaze, pointerGaze } from './gaze.js'+export interface CharacterOptions {+ animation?: string; followCursor?: boolean; followRotation?: boolean;+ trackingRegion?: HTMLElement; trackingScope?: 'region' | 'page'; displaySize?: number; onComplete?: () => void; onError?: () => void;+}++/** One renderer; no frame callbacks or pointer listeners while hidden. */+export function createCharacter(target: HTMLElement, definition: Definition, options: CharacterOptions = {}) {+ const canvas = document.createElement('canvas')+ canvas.style.cssText = 'display:block;width:100%;height:100%;touch-action:pan-y;'+ canvas.setAttribute('aria-hidden', 'true')+ const renderer = new CharacterRenderer(canvas, { width: target.clientWidth || 256, height: target.clientHeight || 256, displaySize: options.displaySize, framing: 'character' })+ target.appendChild(canvas)+ let animation = options.animation ?? 'idle', elapsed = 0, last = 0, raf = 0+ let visible = false, destroyed = false, playing = true, tracking = false+ let gaze = centeredGaze(), goal = centeredGaze()+ const region = options.trackingScope === 'page' ? target.ownerDocument.documentElement : options.trackingRegion ?? target+ const reduced = window.matchMedia('(prefers-reduced-motion: reduce)')+ const coarse = window.matchMedia('(pointer: coarse)')+ const canRun = () => !destroyed && visible && !document.hidden && !reduced.matches+ const render = () => renderer.render({ ...definition.character, followCursor: options.followCursor !== false, followRotation: options.followRotation !== false }, sampleDefinition(definition, animation, elapsed), { cursor: gaze, reducedMotion: reduced.matches }, gaze)+ const pointer = (event: PointerEvent) => { if (event.pointerType !== 'touch') goal = pointerGaze(event, target.getBoundingClientRect()) }+ const leave = () => { goal = centeredGaze() }+ function track(enabled: boolean) {+ if (tracking === enabled) return+ tracking = enabled+ if (enabled) { region.addEventListener('pointermove', pointer, { passive: true }); region.addEventListener('pointerleave', leave) }+ else { region.removeEventListener('pointermove', pointer); region.removeEventListener('pointerleave', leave); goal = centeredGaze() }+ }+ function sync() {+ cancelAnimationFrame(raf); raf = 0+ track(canRun() && !coarse.matches && (options.followCursor !== false || options.followRotation !== false))+ if (canRun() && playing) { last = performance.now(); raf = requestAnimationFrame(frame) }+ }+ function frame(now: number) {+ if (!canRun()) { sync(); return }+ const seconds = Math.min((now - last) / 1000, .1); last = now+ elapsed += seconds; gaze = easeGaze(gaze, goal, seconds, false)+ try { render() } catch { playing = false; sync(); options.onError?.(); return }+ const selected = definition.animations.find(a => a.id === animation)+ if (selected && !selected.loop && elapsed * definition.character.speed >= animationDuration(selected)) {+ animation = 'idle'; elapsed = 0; options.onComplete?.()+ }+ raf = requestAnimationFrame(frame)+ }+ function renderSafely() {+ if (destroyed) return+ try { render() } catch { playing = false; sync(); options.onError?.() }+ }+ const resize = new ResizeObserver(() => {+ try { renderer.resize(target.clientWidth || 256, target.clientHeight || 256, options.displaySize); if (visible) renderSafely() }+ catch { playing = false; sync(); options.onError?.() }+ })+ const intersection = new IntersectionObserver(entries => { visible = entries[0]?.isIntersecting ?? false; sync() })+ const contextLost = (event: Event) => { event.preventDefault(); playing = false; sync(); options.onError?.() }+ function destroy() {+ if (destroyed) return+ destroyed = true; sync(); resize.disconnect(); intersection.disconnect()+ document.removeEventListener('visibilitychange', sync); reduced.removeEventListener('change', sync); coarse.removeEventListener('change', sync)+ canvas.removeEventListener('webglcontextlost', contextLost); renderer.dispose(); canvas.remove()+ }+ try {+ resize.observe(target); intersection.observe(target)+ document.addEventListener('visibilitychange', sync); reduced.addEventListener('change', sync); coarse.addEventListener('change', sync)+ canvas.addEventListener('webglcontextlost', contextLost)+ render()+ } catch (error) { destroy(); throw error }++ return {+ setAnimation(id: string) { if (animation === id) return; animation = id; elapsed = 0; renderSafely() },+ setDefinition(value: Definition) { definition = value; renderSafely() },+ seek(seconds: number) { elapsed = Math.max(0, seconds); renderSafely() },+ pause() { playing = false; sync() },+ play() { playing = true; sync() },+ destroy,++ }+}diff --git a/packages/shared/src/cliplab/static.ts b/packages/shared/src/cliplab/static.tsnew file mode 100644index 0000000000..14d3fb1140--- /dev/null+++ b/packages/shared/src/cliplab/static.ts@@ -0,0 +1,15 @@+import type { AgentAppearance, AgentAvatarSize, CharacterState } from "../agent-appearance.js";+import { characterDefinition, characterStill } from "./definition.js";+import { CharacterRenderer } from "./renderer.js";+import { snapshotSvg } from "./svg-snapshot.js";++/** Same geometry/face projection as the live character, without DOM or WebGL. */+export function renderAgentSvg(appearance: AgentAppearance, size: AgentAvatarSize, scale: 1 | 2, state: CharacterState = "rest", muted = false): string {+ const definition = characterDefinition(appearance, muted);+ const renderer = new CharacterRenderer(null, { width: size * scale, height: size * scale, displaySize: size });+ try {+ renderer.render({ ...definition.character, trueFront: true, lockPosition: true, followCursor: false, followRotation: false },+ characterStill(definition, state), { rotation: { x: 0, y: 0, z: 0 } });+ return snapshotSvg(renderer.snapshotScene(), "agent-");+ } finally { renderer.dispose(); }+}diff --git a/packages/shared/src/cliplab/svg-canvas.ts b/packages/shared/src/cliplab/svg-canvas.tsnew file mode 100644index 0000000000..2cf03183e7--- /dev/null+++ b/packages/shared/src/cliplab/svg-canvas.ts@@ -0,0 +1,109 @@+// Vendored from ClipLab a050f724; see PROVENANCE.md and LICENSE.+import { flatten, pathData, strokeOutline, type ProjectPoint } from './svg-path.js'+// A small vector recorder for the Canvas 2D operations used by ClipLab's faces.+// Paths stay editable; no bitmap or external asset is embedded in the SVG.+type Matrix = [number, number, number, number, number, number]+type Command = { op: string; points: number[] }+const identity = (): Matrix => [1, 0, 0, 1, 0, 0]+export const xml = (value: unknown) => String(value).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]!)+export const number = (n: number) => String(Math.round(n * 100000) / 100000)+const point = (m: Matrix, x: number, y: number) => [m[0] * x + m[2] * y + m[4], m[1] * x + m[3] * y + m[5]]+const inverse = (m: Matrix): Matrix => {+ const d = m[0] * m[3] - m[1] * m[2]+ return d ? [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d, (m[2] * m[5] - m[3] * m[4]) / d, (m[1] * m[4] - m[0] * m[5]) / d] : identity()+}+export class SvgCanvas {+ fillStyle = '#000000'; strokeStyle = '#000000'; lineWidth = 1; globalAlpha = 1+ lineCap = 'butt'; lineJoin = 'miter'; font = '10px sans-serif'; textAlign = 'start'+ private matrix = identity()+ private clips: string[] = []+ private stack: ReturnType<SvgCanvas['state']>[] = []+ private path: Command[] = []+ private nodes: string[] = []+ private definitions: string[] = []+ bounds = { left: Infinity, top: Infinity, right: -Infinity, bottom: -Infinity }+ constructor(private prefix: string, private project?: ProjectPoint) {}+ private state() { return { matrix: [...this.matrix] as Matrix, clips: [...this.clips], fillStyle: this.fillStyle, strokeStyle: this.strokeStyle, lineWidth: this.lineWidth, globalAlpha: this.globalAlpha, lineCap: this.lineCap, lineJoin: this.lineJoin, font: this.font, textAlign: this.textAlign } }+ save() { this.stack.push(this.state()) }+ restore() { const state = this.stack.pop(); if (state) Object.assign(this, state) }+ clearRect() { this.nodes = []; this.definitions = []; this.path = []; this.bounds = { left: Infinity, top: Infinity, right: -Infinity, bottom: -Infinity } }+ transform(a: number, b: number, c: number, d: number, e: number, f: number) {+ const m = this.matrix+ this.matrix = [m[0] * a + m[2] * b, m[1] * a + m[3] * b, m[0] * c + m[2] * d, m[1] * c + m[3] * d, m[0] * e + m[2] * f + m[4], m[1] * e + m[3] * f + m[5]]+ }+ translate(x: number, y: number) { this.transform(1, 0, 0, 1, x, y) }+ scale(x: number, y: number) { this.transform(x, 0, 0, y, 0, 0) }+ rotate(a: number) { this.transform(Math.cos(a), Math.sin(a), -Math.sin(a), Math.cos(a), 0, 0) }+ beginPath() { this.path = [] }+ closePath() { this.path.push({ op: 'Z', points: [] }) }+ private command(op: string, coords: number[]) {+ const points = []+ for (let i = 0; i < coords.length; i += 2) points.push(...point(this.matrix, coords[i]!, coords[i + 1]!))+ this.path.push({ op, points })+ }+ moveTo(x: number, y: number) { this.command('M', [x, y]) }+ lineTo(x: number, y: number) { this.command(this.path.length ? 'L' : 'M', [x, y]) }+ bezierCurveTo(...coords: [number, number, number, number, number, number]) { this.command('C', coords) }+ quadraticCurveTo(...coords: [number, number, number, number]) { this.command('Q', coords) }+ rect(x: number, y: number, w: number, h: number) { this.moveTo(x, y); this.lineTo(x + w, y); this.lineTo(x + w, y + h); this.lineTo(x, y + h); this.closePath() }+ roundRect(x: number, y: number, w: number, h: number, radius: number) {+ const r = Math.min(radius, Math.abs(w) / 2, Math.abs(h) / 2)+ this.moveTo(x + r, y); this.lineTo(x + w - r, y); this.arc(x + w - r, y + r, r, -Math.PI / 2, 0)+ this.lineTo(x + w, y + h - r); this.arc(x + w - r, y + h - r, r, 0, Math.PI / 2)+ this.lineTo(x + r, y + h); this.arc(x + r, y + h - r, r, Math.PI / 2, Math.PI)+ this.lineTo(x, y + r); this.arc(x + r, y + r, r, Math.PI, Math.PI * 1.5); this.closePath()+ }+ arc(x: number, y: number, radius: number, start: number, end: number, ccw = false) { this.ellipse(x, y, radius, radius, 0, start, end, ccw) }+ ellipse(x: number, y: number, rx: number, ry: number, rotation: number, start: number, end: number, ccw = false) {+ const tau = Math.PI * 2+ let delta = end - start+ if (!ccw) delta = delta >= tau ? tau : ((delta % tau) + tau) % tau+ else delta = delta <= -tau ? -tau : -(((-delta % tau) + tau) % tau)+ const at = (a: number) => [x + rx * Math.cos(a) * Math.cos(rotation) - ry * Math.sin(a) * Math.sin(rotation), y + rx * Math.cos(a) * Math.sin(rotation) + ry * Math.sin(a) * Math.cos(rotation)]+ const tangent = (a: number) => [-rx * Math.sin(a) * Math.cos(rotation) - ry * Math.cos(a) * Math.sin(rotation), -rx * Math.sin(a) * Math.sin(rotation) + ry * Math.cos(a) * Math.cos(rotation)]+ const first = at(start); this.lineTo(first[0]!, first[1]!)+ const segments = Math.max(1, Math.ceil(Math.abs(delta) / (Math.PI / 2)))+ for (let i = 0; i < segments; i++) {+ const a = start + delta * i / segments, b = start + delta * (i + 1) / segments, k = 4 / 3 * Math.tan((b - a) / 4)+ const p = at(a), q = at(b), u = tangent(a), v = tangent(b)+ this.bezierCurveTo(p[0]! + k * u[0]!, p[1]! + k * u[1]!, q[0]! - k * v[0]!, q[1]! - k * v[1]!, q[0]!, q[1]!)+ }+ }+ private data(matrix = identity()) {+ return this.path.map(c => {+ const coords = []+ for (let i = 0; i < c.points.length; i += 2) coords.push(...point(matrix, c.points[i]!, c.points[i + 1]!))+ return c.op + coords.map(number).join(' ')+ }).join(' ')+ }+ private add(node: string) { this.nodes.push(this.clips.reduceRight((value, id) => `<g clip-path="url(#${id})">${value}</g>`, node)) }+ private paint(stroke: boolean, rule = 'nonzero') {+ if (this.globalAlpha <= 0) return+ const expansion = stroke ? this.lineWidth * Math.max(Math.hypot(this.matrix[0], this.matrix[1]), Math.hypot(this.matrix[2], this.matrix[3])) / 2 : 0+ for (const c of this.path) for (let i = 0; i < c.points.length; i += 2) {+ this.bounds.left = Math.min(this.bounds.left, c.points[i]! - expansion); this.bounds.right = Math.max(this.bounds.right, c.points[i]! + expansion)+ this.bounds.top = Math.min(this.bounds.top, c.points[i + 1]! - expansion); this.bounds.bottom = Math.max(this.bounds.bottom, c.points[i + 1]! + expansion)+ }+ if (this.project) {+ const inv = inverse(this.matrix)+ const commands = this.path.map(c => ({ op: c.op, points: c.points.flatMap((_, i) => i % 2 ? [] : point(inv, c.points[i]!, c.points[i + 1]!)) }))+ const contours = flatten(commands)+ const outlines = stroke ? contours.flatMap(c => strokeOutline(c, this.lineWidth)) : contours.map(c => ({ ...c, closed: true }))+ const project: ProjectPoint = p => { const [x, y] = point(this.matrix, p.x, p.y); return this.project!({ x: x!, y: y! }) }+ this.add(`<path d="${pathData(outlines, project)}" opacity="${number(this.globalAlpha)}" fill="${xml(stroke ? this.strokeStyle : this.fillStyle)}" fill-rule="${rule}"/>`)+ return+ }+ this.add(`<path d="${this.data(inverse(this.matrix))}" transform="matrix(${this.matrix.map(number).join(' ')})" opacity="${number(this.globalAlpha)}" ${stroke ? `fill="none" stroke="${xml(this.strokeStyle)}" stroke-width="${number(this.lineWidth)}" stroke-linecap="${xml(this.lineCap)}" stroke-linejoin="${xml(this.lineJoin)}"` : `fill="${xml(this.fillStyle)}" fill-rule="${rule}"`}/>`)+ }+ fill(rule = 'nonzero') { this.paint(false, rule) }+ stroke() { this.paint(true) }+ clip(rule = 'nonzero') {+ const id = `${this.prefix}-clip-${this.definitions.length}`+ this.definitions.push(`<clipPath id="${id}" clipPathUnits="userSpaceOnUse"><path d="${this.project ? pathData(flatten(this.path).map(c => ({ ...c, closed: true })), this.project) : this.data()}" clip-rule="${rule}"/></clipPath>`); this.clips.push(id)+ }+ fillText(text: string, x: number, y: number) {+ const size = Number(this.font.match(/([\d.]+)px/)?.[1] ?? 10)+ this.add(`<text x="${number(x)}" y="${number(y)}" transform="matrix(${this.matrix.map(number).join(' ')})" font-family="sans-serif" font-size="${size}" font-weight="${this.font.includes('bold') ? 'bold' : 'normal'}" text-anchor="${this.textAlign === 'center' ? 'middle' : 'start'}" fill="${xml(this.fillStyle)}" opacity="${number(this.globalAlpha)}">${xml(text)}</text>`)+ }+ markup() { return `<defs>${this.definitions.join('')}</defs>${this.nodes.join('')}` }+}diff --git a/packages/shared/src/cliplab/svg-path.ts b/packages/shared/src/cliplab/svg-path.tsnew file mode 100644index 0000000000..ae72bcafa9--- /dev/null+++ b/packages/shared/src/cliplab/svg-path.ts@@ -0,0 +1,105 @@+// Vendored from ClipLab a050f724; see PROVENANCE.md and LICENSE.+/** Compact projected vector paths. Curves are flattened below a display pixel,+ * then simplified after projection; strokes become filled outlines before warping. */+export type Point = { x: number; y: number }+export type PathCommand = { op: string; points: number[] }+export type Contour = { points: Point[]; closed: boolean }+export type ProjectPoint = (point: Point) => Point+const distance = (a: Point, b: Point) => Math.hypot(a.x - b.x, a.y - b.y)+const middle = (a: Point, b: Point) => ({ x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 })+function lineDistance(p: Point, a: Point, b: Point) {+ const dx = b.x - a.x, dy = b.y - a.y, t = Math.max(0, Math.min(1, ((p.x - a.x) * dx + (p.y - a.y) * dy) / (dx * dx + dy * dy || 1)))+ return distance(p, { x: a.x + dx * t, y: a.y + dy * t })+}+export function simplify(points: Point[], tolerance = .06): Point[] {+ if (points.length <= 2) return points+ let max = tolerance, index = -1+ for (let i = 1; i < points.length - 1; i++) { const d = lineDistance(points[i]!, points[0]!, points.at(-1)!); if (d > max) { max = d; index = i } }+ return index < 0 ? [points[0]!, points.at(-1)!] : [...simplify(points.slice(0, index + 1), tolerance).slice(0, -1), ...simplify(points.slice(index), tolerance)]+}+export function flatten(commands: PathCommand[], tolerance = .08): Contour[] {+ const contours: Contour[] = []+ let current: Contour | undefined+ const append = (p: Point) => { if (!current) { current = { points: [], closed: false }; contours.push(current) } current.points.push(p) }+ function cubic(a: Point, b: Point, c: Point, d: Point, depth = 0) {+ if (depth >= 12 || Math.max(lineDistance(b, a, d), lineDistance(c, a, d)) <= tolerance) { append(d); return }+ const ab = middle(a, b), bc = middle(b, c), cd = middle(c, d), abc = middle(ab, bc), bcd = middle(bc, cd), mid = middle(abc, bcd)+ cubic(a, ab, abc, mid, depth + 1); cubic(mid, bcd, cd, d, depth + 1)+ }+ for (const command of commands) {+ const p = command.points, end = { x: p.at(-2)!, y: p.at(-1)! }, start = current?.points.at(-1) ?? end+ if (command.op === 'M') { current = undefined; append(end) }+ else if (command.op === 'Z') { if (current) current.closed = true }+ else if (command.op === 'C') cubic(start, { x: p[0]!, y: p[1]! }, { x: p[2]!, y: p[3]! }, end)+ else if (command.op === 'Q') cubic(start, { x: start.x + (p[0]! - start.x) * 2 / 3, y: start.y + (p[1]! - start.y) * 2 / 3 }, { x: end.x + (p[0]! - end.x) * 2 / 3, y: end.y + (p[1]! - end.y) * 2 / 3 }, end)+ else append(end)+ }+ return contours+}+function arc(center: Point, start: number, delta: number, radius: number) {+ const count = Math.max(1, Math.ceil(Math.abs(delta) / .18))+ return Array.from({ length: count + 1 }, (_, i) => ({ x: center.x + Math.cos(start + delta * i / count) * radius, y: center.y + Math.sin(start + delta * i / count) * radius }))+}+/** Round joins/caps, matching all line artwork in the character renderer. */+export function strokeOutline(contour: Contour, width: number): Contour[] {+ let points = contour.points.filter((p, i, all) => !i || distance(p, all[i - 1]!) > 1e-7)+ if (points.length > 1 && distance(points[0]!, points.at(-1)!) < 1e-7) points = points.slice(0, -1)+ if (points.length < 2) return []+ const r = width / 2, len = points.length+ const direction = (a: Point, b: Point) => { const l = distance(a, b); return { x: (b.x - a.x) / l, y: (b.y - a.y) / l } }+ const side = (sign: number) => points.flatMap((p, i) => {+ const before = direction(points[(i - 1 + len) % len]!, p), after = direction(p, points[(i + 1) % len]!)+ if (!contour.closed && (!i || i === len - 1)) { const d = i ? before : after; return [{ x: p.x - d.y * r * sign, y: p.y + d.x * r * sign }] }+ const turn = Math.atan2(before.x * after.y - before.y * after.x, before.x * after.x + before.y * after.y)+ if (turn * sign < -.001) return arc(p, Math.atan2(before.x * sign, -before.y * sign), turn, r)+ const denom = Math.max(.05, 1 + before.x * after.x + before.y * after.y)+ return [{ x: p.x - (before.y + after.y) * r * sign / denom, y: p.y + (before.x + after.x) * r * sign / denom }]+ })+ const left = side(1), right = side(-1)+ if (contour.closed) return [{ points: left, closed: true }, { points: right.reverse(), closed: true }]+ const first = direction(points[0]!, points[1]!), last = direction(points[len - 2]!, points[len - 1]!)+ return [{ closed: true, points: [...left, ...arc(points.at(-1)!, Math.atan2(last.x, -last.y), -Math.PI, r), ...right.reverse(), ...arc(points[0]!, Math.atan2(-first.x, first.y), -Math.PI, r)] }]+}+export function pathData(contours: Contour[], project: ProjectPoint = p => p, tolerance = .06) {+ const n = (value: number) => String(Math.round(value * 1000) / 1000)+ return contours.map(contour => {+ // Subdivide straight art-space edges too: the face shell is curved.+ const points: Point[] = []+ const all = contour.closed ? [...contour.points, contour.points[0]!] : contour.points+ function segment(a: Point, b: Point, depth = 0) {+ const pa = project(a), pb = project(b), mid = middle(a, b), pm = project(mid)+ if (depth < 10 && (lineDistance(pm, pa, pb) > tolerance || distance(a, b) > 12)) { segment(a, mid, depth + 1); segment(mid, b, depth + 1) }+ else points.push(pb)+ }+ if (!all.length) return ''+ points.push(project(all[0]!)); for (let i = 1; i < all.length; i++) segment(all[i - 1]!, all[i]!)+ return simplify(points, tolerance).map((p, i) => `${i ? 'L' : 'M'}${n(p.x)} ${n(p.y)}`).join('') + (contour.closed ? 'Z' : '')+ }).join('')+}+/** Union a triangle/polygon tessellation by cancelling shared edges, keeping only+ * the boundary loops. The output has no interior mesh edges or per-triangle layers. */+export function boundaryContours(polygons: Point[][]): Contour[] {+ const key = (p: Point) => `${Math.round(p.x * 1e5)},${Math.round(p.y * 1e5)}`+ const edges = new Map<string, { a: Point; b: Point; start: string; end: string }>()+ for (const poly of polygons) for (let i = 0; i < poly.length; i++) {+ const a = poly[i]!, b = poly[(i + 1) % poly.length]!, start = key(a), end = key(b)+ if (start === end) continue+ const reverse = `${end}/${start}`, forward = `${start}/${end}`+ if (edges.has(reverse)) edges.delete(reverse); else edges.set(forward, { a, b, start, end })+ }+ const starts = new Map<string, Set<string>>()+ for (const [id, e] of edges) { const set = starts.get(e.start) ?? new Set<string>(); set.add(id); starts.set(e.start, set) }+ const contours: Contour[] = []+ while (edges.size) {+ const first = edges.values().next().value!, points = [first.a]+ let next: string | undefined = `${first.start}/${first.end}`+ while (next) {+ const e = edges.get(next); if (!e) break+ edges.delete(next); starts.get(e.start)!.delete(next); points.push(e.b)+ if (e.end === first.start) break+ next = starts.get(e.end)?.values().next().value+ }+ if (points.length > 2) contours.push({ points, closed: true })+ }+ return contours+}diff --git a/packages/shared/src/cliplab/svg-snapshot.ts b/packages/shared/src/cliplab/svg-snapshot.tsnew file mode 100644index 0000000000..201f7616b8--- /dev/null+++ b/packages/shared/src/cliplab/svg-snapshot.ts@@ -0,0 +1,145 @@+// Vendored from ClipLab a050f724; see PROVENANCE.md and LICENSE.+import * as THREE from 'three'+import { drawFace, drawProp, type CharacterRenderer } from './renderer.js'+import { detailAt } from './model.js'+import { SvgCanvas, number as n, xml } from './svg-canvas.js'+import { boundaryContours, pathData, type Point, type ProjectPoint } from './svg-path.js'++type Snapshot = ReturnType<CharacterRenderer['snapshotScene']>+type Vertex = { x: number; y: number; z: number; t: number }+type Triangle = { points: Vertex[]; indices: number[] }+const cross = (a: Pick<Vertex, 'x' | 'y'>, b: Pick<Vertex, 'x' | 'y'>, c: Pick<Vertex, 'x' | 'y'>) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)+function hull(points: Vertex[]) {+ const sorted = [...points].sort((a, b) => a.x - b.x || a.y - b.y)+ const half = (items: Vertex[]) => { const out: Vertex[] = []; for (const p of items) { while (out.length > 1 && cross(out.at(-2)!, out.at(-1)!, p) <= 0) out.pop(); out.push(p) } return out }+ return [...half(sorted).slice(0, -1), ...half([...sorted].reverse()).slice(0, -1)]+}+function clip(points: Vertex[], threshold: number, above: boolean) {+ const out: Vertex[] = []+ for (let i = 0; i < points.length; i++) {+ const a = points[i]!, b = points[(i + 1) % points.length]!, insideA = above ? a.z >= threshold : a.z <= threshold, insideB = above ? b.z >= threshold : b.z <= threshold+ if (insideA) out.push(a)+ if (insideA !== insideB) {+ const f = (threshold - a.z) / (b.z - a.z)+ out.push({ x: a.x + (b.x - a.x) * f, y: a.y + (b.y - a.y) * f, z: a.z + (b.z - a.z) * f, t: a.t + (b.t - a.t) * f })+ }+ }+ return out+}+/** Best-fit planar gradient, weighted by visible projected area. A curved 3D+ * surface is not exactly representable by one SVG linear gradient; this keeps+ * the authored colors and a compact, editable fill at every camera angle. */+export function fitGradient(triangles: { points: Vertex[] }[]) {+ let weight = 0, x = 0, y = 0, t = 0+ const samples: { p: Vertex; w: number }[] = []+ for (const { points } of triangles) {+ const w = Math.abs(cross(points[0]!, points[1]!, points[2]!)) / 6+ for (const p of points) { samples.push({ p, w }); weight += w; x += p.x * w; y += p.y * w; t += p.t * w }+ }+ if (!weight) return { x: 0, y: 0, t: .5, gx: 0, gy: 0 }+ x /= weight; y /= weight; t /= weight+ let xx = 0, xy = 0, yy = 0, xt = 0, yt = 0+ for (const { p, w } of samples) { const dx = p.x - x, dy = p.y - y, dt = p.t - t; xx += dx * dx * w; xy += dx * dy * w; yy += dy * dy * w; xt += dx * dt * w; yt += dy * dt * w }+ const det = xx * yy - xy * xy+ return { x, y, t, gx: det ? (xt * yy - yt * xy) / det : 0, gy: det ? (yt * xx - xt * xy) / det : 0 }+}+/** Warp each facial outline through the same UV mesh as the live renderer.+ * This emits the artwork once instead of repeating it in every mesh triangle. */+export function faceProjector(face: Snapshot['face'], project: (point: THREE.Vector3) => Point): ProjectPoint {+ const { widthSegments: nx, heightSegments: ny } = face.geometry.parameters+ const position = face.geometry.getAttribute('position')+ return p => {+ const u = p.x / 512 * nx, v = p.y / 512 * ny+ const ix = Math.max(0, Math.min(nx - 1, Math.floor(u))), iy = Math.max(0, Math.min(ny - 1, Math.floor(v))), fx = u - ix, fy = v - iy+ const a = ix + iy * (nx + 1), b = a + nx + 1, c = b + 1, d = a + 1+ const indices = fx + fy <= 1 ? [a, d, b] : [c, b, d], weights = fx + fy <= 1 ? [1 - fx - fy, fx, fy] : [fx + fy - 1, 1 - fx, 1 - fy]+ const value = new THREE.Vector3()+ indices.forEach((index, i) => value.addScaledVector(new THREE.Vector3().fromBufferAttribute(position, index), weights[i]!))+ return project(value.applyMatrix4(face.matrixWorld))+ }+}++export function snapshotSvg(snapshot: Snapshot, prefix = `cliplab-${crypto.randomUUID()}-`): string {+ const { character, sample, camera, options, body, lightFill, face, prop, shadow } = snapshot+ const { width, height } = options+ const defs: string[] = [], contents: string[] = []+ const project = (p: THREE.Vector3) => { const v = p.clone().project(camera); return { x: (v.x + 1) * width / 2, y: (1 - v.y) * height / 2, z: v.z, t: 0 } }+ const triangles = (mesh: THREE.Mesh, shading = false): { triangles: Triangle[]; vertices: Vertex[] } => {+ const geometry = mesh.geometry, position = geometry.getAttribute('position'), index = geometry.index+ const material = mesh.material as THREE.ShaderMaterial, uniforms = shading ? material.uniforms : undefined+ const angle = uniforms?.angle?.value ?? 0, bodyHeight = uniforms?.bodyHeight?.value ?? 1+ const scale = uniforms?.fillScale?.value as THREE.Vector3 | undefined, offset = uniforms?.fillOffset?.value as THREE.Vector3 | undefined+ const vertices: Vertex[] = []+ for (let i = 0; i < position.count; i++) {+ const local = new THREE.Vector3().fromBufferAttribute(position, i), v = project(local.clone().applyMatrix4(mesh.matrixWorld))+ if (shading) {+ local.multiply(scale ?? new THREE.Vector3(1, 1, 1)).add(offset ?? new THREE.Vector3())+ v.t = .5 + local.y / bodyHeight * Math.cos(angle) + local.x * Math.sin(angle)+ }+ vertices.push(v)+ }+ const triangles: Triangle[] = []+ for (let i = 0; i < (index?.count ?? position.count); i += 3) {+ const indices = [0, 1, 2].map(j => index ? index.getX(i + j) : i + j), points = indices.map(i => vertices[i]!)+ if (cross(points[0]!, points[1]!, points[2]!) < -1e-8) triangles.push({ points, indices })+ }+ return { triangles, vertices }+ }+ const shadedColor = (color: THREE.Color, shade: number) => '#' + color.clone().multiplyScalar(shade).getHexString()+ const outline = (vertices: Vertex[]) => pathData([{ points: hull(vertices), closed: true }])+ const surface = (mesh: THREE.Mesh<THREE.BufferGeometry, THREE.ShaderMaterial>, label: string) => {+ const data = triangles(mesh, true), u = mesh.material.uniforms+ const colorA = u.colorA!.value as THREE.Color, colorB = (u.colorB!.value as THREE.Color).clone().lerp(colorA, 1 - u.gradientOn!.value)+ const shade = u.toonOn!.value && !u.insetFill!.value ? .8 : 1+ const gradient = fitGradient(data.triangles), { x, y, t, gx, gy } = gradient, length = gx * gx + gy * gy+ let fill = shadedColor(colorA, shade)+ if (u.gradientOn!.value > 0 && !colorA.equals(colorB)) {+ if (length < 1e-18) fill = shadedColor(colorB.clone().lerp(colorA, Math.max(0, Math.min(1, t))), shade)+ else {+ const id = `${label}-gradient`+ defs.push(`<linearGradient id="${id}" gradientUnits="userSpaceOnUse" color-interpolation="linearRGB" x1="${n(x - gx * t / length)}" y1="${n(y - gy * t / length)}" x2="${n(x + gx * (1 - t) / length)}" y2="${n(y + gy * (1 - t) / length)}"><stop stop-color="${shadedColor(colorB, shade)}"/><stop offset="1" stop-color="${shadedColor(colorA, shade)}"/></linearGradient>`)+ fill = `url(#${id})`+ }+ }+ contents.push(`<g id="${label}" data-name="${label === 'body' ? 'Outer body' : 'Inner body'}"><path fill="${fill}" d="${outline(data.vertices)}"/></g>`)+ return data+ }+ if (options.background) contents.push(`<rect width="${width}" height="${height}" fill="${xml(options.background)}"/>`)+ if (shadow.visible) {+ const material = shadow.material, data = triangles(shadow)+ contents.push(`<g id="ground-shadow" data-name="Shadow"><path d="${outline(data.vertices)}" fill="#${material.color.getHexString()}" opacity="${n(material.opacity)}"/></g>`)+ }+ const bodyData = surface(body, 'body')+ if (lightFill.visible) surface(lightFill, 'candle-light')+ const transparent: { z: number; markup: string }[] = []+ if (face.visible) {+ const art = new SvgCanvas('face', faceProjector(face, project))+ drawFace(art as unknown as CanvasRenderingContext2D, sample.pose, character, sample.blink, detailAt(options.displaySize ?? Math.min(width, height)), snapshot.gaze, { phase: sample.effectPhase, tearAmount: sample.tearAmount, eyeGazes: snapshot.eyeGazes, faceLayers: sample.faceLayers, simpleEyes: snapshot.simpleEyes })+ const valid = face.geometry.getAttribute('faceValid'), data = triangles(face)+ const visible = data.triangles.filter(t => t.indices.every(i => valid.getX(i) >= .99))+ defs.push(`<clipPath id="face-visible"><path d="${pathData(boundaryContours(visible.map(t => t.points)))}"/></clipPath>`)+ if (!face.geometry.boundingSphere) face.geometry.computeBoundingSphere()+ const center = project(face.geometry.boundingSphere!.center.clone().applyMatrix4(face.matrixWorld))+ transparent.push({ z: center.z, markup: `<g clip-path="url(#face-visible)">${art.markup()}</g>` })+ }+ if (prop.visible && prop.material.opacity > 0) {+ const art = new SvgCanvas('prop'), name = sample.pose.prop+ drawProp(art as unknown as CanvasRenderingContext2D, name, name === 'heart' ? '#ff768c' : name === 'sweat' ? '#b7e9ff' : '#ffd362', sample.effectPhase)+ const center = project(prop.getWorldPosition(new THREE.Vector3())), scale = prop.getWorldScale(new THREE.Vector3())+ const w = scale.x * width / (camera.right - camera.left), h = scale.y * height / (camera.top - camera.bottom)+ const foreground = !prop.material.depthTest+ if (!foreground) {+ const occlusion = pathData(boundaryContours(bodyData.triangles.map(t => clip(t.points, center.z, false)).filter(p => p.length >= 3)))+ defs.push(`<mask id="prop-occlusion" maskUnits="userSpaceOnUse" x="0" y="0" width="${width}" height="${height}"><rect width="${width}" height="${height}" fill="white"/><path d="${occlusion}" fill="black"/></mask>`)+ }+ transparent.push({ z: foreground ? -Infinity : center.z, markup: `<g id="supporting-elements" data-name="Supporting elements"${foreground ? '' : ' mask="url(#prop-occlusion)"'} opacity="${n(prop.material.opacity)}"><g transform="translate(${n(center.x - w / 2)} ${n(center.y - h / 2)}) scale(${n(w / 256)} ${n(h / 256)})">${art.markup()}</g></g>` })+ }+ if (transparent.length) contents.push(`<g id="face" data-name="Facial expression">${transparent.sort((a, b) => b.z - a.z).map(layer => layer.markup).join('')}</g>`)+ const metadata = { format: 'cliplab-svg-snapshot', gradientProjection: 'planar-fit', character, pose: sample.pose, gradientRotation: sample.gradientRotation ?? 0, effectiveGradientAngle: character.gradientAngle + (sample.gradientRotation ?? 0), rotation: options.rotation, cursor: options.cursor }+ // Multiple downloaded characters can safely be placed inline in the same page.+ const artwork = (`<defs>${defs.join('')}</defs>${contents.join('')}`)+ .replace(/\bid="([^"]+)"/g, (_, id: string) => `id="${prefix}${id}"`)+ .replace(/url\(#([^)]+)\)/g, (_, id: string) => `url(#${prefix}${id})`)+ .replace(/href="#([^"]+)"/g, (_, id: string) => `href="#${prefix}${id}"`)+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" role="img"><title>${xml(character.name)} — ClipLab snapshot</title><metadata>${xml(JSON.stringify(metadata))}</metadata>${artwork}</svg>`+}diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.tsindex a4e58a58fa..f860952386 100644--- a/packages/shared/src/index.ts+++ b/packages/shared/src/index.ts@@ -2760,6 +2760,7 @@ export type { ExecutionProjection, ExecutionReconciliation, ExecutionBlocker } fexport { EXECUTION_RECONCILIATION_CAUSES, requiresExecutionReconciliation } from "./types/execution-projection.js";+export * from "./agent-appearance.js";export * from "./ai-connections.js";export * from "./types/email.js";export * from "./validators/email.js";diff --git a/packages/shared/src/types/agent.ts b/packages/shared/src/types/agent.tsindex 736eed8a2b..e775c5b994 100644--- a/packages/shared/src/types/agent.ts+++ b/packages/shared/src/types/agent.ts@@ -1,3 +1,4 @@+import type { AgentAppearance } from "../agent-appearance.js";import type { AiConnectionLoginIntent } from "../ai-connections.js";import type {AgentAdapterType,@@ -81,6 +82,8 @@ export interface Agent {role: AgentRole;title: string | null;icon: string | null;+ appearance?: AgentAppearance | null;+ avatarUrl?: string;status: AgentStatus;reportsTo: string | null;capabilities: string | null;diff --git a/packages/shared/src/types/company-portability.ts b/packages/shared/src/types/company-portability.tsindex 1d41dd07cc..7c3bc6cc75 100644--- a/packages/shared/src/types/company-portability.ts+++ b/packages/shared/src/types/company-portability.ts@@ -1,3 +1,4 @@+import type { AgentAppearance } from "../agent-appearance.js";import type { AgentEnvConfig } from "./secrets.js";import type { RoutineVariable } from "./routine.js";import type { IssueCommentAuthorType, PermissionKey } from "../constants.js";@@ -217,6 +218,7 @@ export interface CompanyPortabilityAgentManifestEntry {role: string;title: string | null;icon: string | null;+ appearance?: AgentAppearance | null;capabilities: string | null;reportsToSlug: string | null;reportsToExistingAgentId: string | null;diff --git a/packages/shared/src/types/cost.ts b/packages/shared/src/types/cost.tsindex 88e2af361d..4e55098094 100644--- a/packages/shared/src/types/cost.ts+++ b/packages/shared/src/types/cost.ts@@ -1,3 +1,4 @@+import type { AgentAppearance } from "../agent-appearance.js";import type { BillingType, CostStatus } from "../constants.js";export interface CostEvent {@@ -47,6 +48,8 @@ export interface IssueCostSummary {export interface CostByAgent {agentId: string;agentName: string | null;+ agentAppearance?: AgentAppearance | null;+ avatarUrl?: string;agentStatus: string | null;costCents: number;inputTokens: number;@@ -94,6 +97,8 @@ export interface CostByBiller {export interface CostByAgentModel {agentId: string;agentName: string | null;+ agentAppearance?: AgentAppearance | null;+ avatarUrl?: string;provider: string;biller: string;billingType: BillingType;diff --git a/packages/shared/src/types/secrets.ts b/packages/shared/src/types/secrets.tsindex 4c32af0ebf..05b07bce05 100644--- a/packages/shared/src/types/secrets.ts+++ b/packages/shared/src/types/secrets.ts@@ -1,3 +1,4 @@+import type { AgentAppearance } from "../agent-appearance.js";import type {SecretAccessOutcome,SecretBindingTargetType,@@ -364,6 +365,8 @@ export type SecretProposalStatus =/** Minimal agent reference surfaced on a proposal (proposer / binding target). */export interface SecretProposalAgentRef {+ appearance?: AgentAppearance | null;+ avatarUrl?: string;id: string;name: string;/** lucide icon slug, if the agent has one. */diff --git a/packages/shared/src/types/work-timeline.ts b/packages/shared/src/types/work-timeline.tsindex 7973100ddc..8ebfc5cd6c 100644--- a/packages/shared/src/types/work-timeline.ts+++ b/packages/shared/src/types/work-timeline.ts@@ -1,3 +1,4 @@+import type { AgentAppearance } from "../agent-appearance.js";/*** Work Timeline (Gantt) types — shared between the aggregation service* (`server/src/services/work-timeline.ts`) and the UI page@@ -15,6 +16,8 @@ export interface WorkTimelineActor {type: TimelineActorType;name: string;avatar?: string | null;+ appearance?: AgentAppearance | null;+ avatarUrl?: string;}export interface WorkTimelineSpan {diff --git a/packages/shared/src/validators/agent.ts b/packages/shared/src/validators/agent.tsindex dfe8c963e4..40fa05fd37 100644--- a/packages/shared/src/validators/agent.ts+++ b/packages/shared/src/validators/agent.ts@@ -1,3 +1,4 @@+import { agentAppearanceSchema } from "../agent-appearance.js";import { aiConnectionBindingSchema } from "../ai-connections.js";import { z } from "zod";import {@@ -80,6 +81,7 @@ export const createAgentSchema = z.object({role: z.enum(AGENT_ROLES).optional().default("general"),title: z.string().optional().nullable(),icon: z.enum(AGENT_ICON_NAMES).optional().nullable(),+ appearance: agentAppearanceSchema.optional(),reportsTo: z.string().guid().optional().nullable(),capabilities: z.string().optional().nullable(),desiredSkills: z.array(agentDesiredSkillSelectionSchema).optional(),diff --git a/packages/shared/src/validators/company-portability.ts b/packages/shared/src/validators/company-portability.tsindex d5817ceaa5..8244c3d4ec 100644--- a/packages/shared/src/validators/company-portability.ts+++ b/packages/shared/src/validators/company-portability.ts@@ -1,3 +1,4 @@+import { agentAppearanceSchema } from "../agent-appearance.js";import { z } from "zod";import { PERMISSION_KEYS } from "../constants.js";import {@@ -77,6 +78,7 @@ export const portabilityAgentManifestEntrySchema = z.object({role: z.string().min(1),title: z.string().nullable(),icon: z.string().nullable(),+ appearance: agentAppearanceSchema.nullable().optional(),capabilities: z.string().nullable(),reportsToSlug: z.string().min(1).nullable(),adapterType: z.string().min(1),diff --git a/scripts/__tests__/storybook-deploy.test.mjs b/scripts/__tests__/storybook-deploy.test.mjsindex 9bade4ce87..01b2b25272 100644--- a/scripts/__tests__/storybook-deploy.test.mjs+++ b/scripts/__tests__/storybook-deploy.test.mjs@@ -233,3 +233,43 @@ test('public verification rejects a permanently stale branch URL or wrong sourcewrong === 'branch' ? /does not point to this build/ : /wrong source commit/);}});++import { createHash } from 'node:crypto';+import { verifyAvatarImages } from '../../.github/scripts/verify-storybook.cjs';+function avatarVerificationFixture(change = {}) {+ const png = Buffer.alloc(24);+ Buffer.from('89504e470d0a1a0a', 'hex').copy(png);+ png.writeUInt32BE(48, 16); png.writeUInt32BE(48, 20);+ const entry = { path: 'agent-avatar-images/cap-v1/bubblegum-sky/rest-24-2.png', pixels: 48,+ sha256: createHash('sha256').update(png).digest('hex'), ...change.entry };+ const requested = [];+ return { requested, fetch: async (url) => {+ requested.push(String(url));+ if (String(url).endsWith('manifest.json')) return Response.json({ schemaVersion: 1, images: [entry] });+ return new Response(change.body ?? png, { status: change.status ?? 200,+ headers: { 'content-type': change.type ?? 'image/png' } });+ } };+}+test('public avatar verification checks relative PNG paths, bytes and density dimensions', async () => {+ const fixture = avatarVerificationFixture();+ const d = storybookDestination(input);+ await verifyAvatarImages({ buildUrl: d.buildUrl, fetch: fixture.fetch });+ assert.ok(fixture.requested.every(url => url.startsWith(d.buildUrl.replace('index.html', ''))));+ assert.equal(fixture.requested.length, 2);+});+test('public avatar verification rejects missing, HTML, corrupt or wrong-density images', async () => {+ for (const change of [{ status: 403 }, { type: 'text/html' }, { body: 'broken PNG' },+ { entry: { pixels: 24 } }, { entry: { sha256: '0'.repeat(64) } },+ { entry: { path: '../../api/agent-avatars/portrait.png' } }]) {+ await assert.rejects(verifyAvatarImages({ buildUrl: storybookDestination(input).buildUrl,+ fetch: avatarVerificationFixture(change).fetch }), /Avatar|avatar/);+ }+});+test('deployment metadata opts into avatar verification and fails on missing images', async () => {+ const d = storybookDestination(input);+ await assert.rejects(verifyStorybook({ branchUrl: d.url, buildUrl: d.buildUrl, sha: d.sha, attempts: 1,+ fetch: async url => String(url).endsWith('deployment.json')+ ? Response.json({ sha: d.sha, avatarManifest: 'agent-avatar-images/manifest.json' })+ : String(url) === d.url ? new Response(branchIndex(d.buildUrl)) : new Response('', { status: 403 }),+ }), /Avatar manifest returned HTTP 403/);+});diff --git a/scripts/serve-storybook-static.mjs b/scripts/serve-storybook-static.mjsindex 50d5c93526..d5563db774 100644--- a/scripts/serve-storybook-static.mjs+++ b/scripts/serve-storybook-static.mjs@@ -1,7 +1,9 @@#!/usr/bin/env node-// Tiny dependency-free static file server for the built Storybook-// (ui/storybook-static). Used by the visual snapshot suite's webServer so we-// don't add an http-server dependency.+// Built Storybook plus the real, public on-demand avatar endpoint.+// Uses an isolated disposable cache; no company database or credentials.+import { createRequire } from "node:module";+import { mkdtemp, rm } from "node:fs/promises";+import { tmpdir } from "node:os";import { createServer } from "node:http";import { createReadStream, existsSync, statSync } from "node:fs";import { extname, join, normalize, resolve } from "node:path";@@ -54,8 +56,20 @@ const MIME = {".mp4": "video/mp4",};+const serverRequire = createRequire(new URL("../server/package.json", import.meta.url));+const { register } = await import(serverRequire.resolve("tsx/esm/api"));+register();+const express = serverRequire("express");+const { agentAvatarRoutes } = await import("../server/src/routes/agent-avatars.ts");+const { createAgentAvatarService } = await import("../server/src/services/agent-avatars.ts");+const { createLocalDiskStorageProvider } = await import("../server/src/storage/local-disk-provider.ts");+const cache = await mkdtemp(join(tmpdir(), "paperclip-storybook-avatars-"));+const avatars = createAgentAvatarService(createLocalDiskStorageProvider(cache));+const api = express();+api.use("/api", agentAvatarRoutes(avatars));const server = createServer((req, res) => {const url = new URL(req.url ?? "/", `http://localhost:${port}`);+ if (url.pathname.startsWith("/api/agent-avatars/")) { api(req, res); return; }let filePath = normalize(join(root, decodeURIComponent(url.pathname)));if (!filePath.startsWith(root)) {res.writeHead(403).end("forbidden");@@ -78,3 +92,12 @@ const server = createServer((req, res) => {server.listen(port, () => {console.log(`storybook-static served at http://localhost:${port}`);});++async function shutdown() {+ server.close();+ server.closeAllConnections();+ await avatars.close();+ await rm(cache, { recursive: true, force: true });+}+process.once("SIGTERM", shutdown);+process.once("SIGINT", shutdown);diff --git a/scripts/storybook-agent-avatar-assets.d.mts b/scripts/storybook-agent-avatar-assets.d.mtsnew file mode 100644index 0000000000..0db850645a--- /dev/null+++ b/scripts/storybook-agent-avatar-assets.d.mts@@ -0,0 +1,5 @@+export function storybookAgentAvatarAssets(): {+ name: string;+ apply: "build";+ generateBundle(this: { emitFile(asset: { type: "asset"; fileName: string; source: string | Uint8Array }): unknown }): Promise<void>;+};diff --git a/scripts/storybook-agent-avatar-assets.mjs b/scripts/storybook-agent-avatar-assets.mjsnew file mode 100644index 0000000000..736bcb2864--- /dev/null+++ b/scripts/storybook-agent-avatar-assets.mjs@@ -0,0 +1,43 @@+import { createRequire } from "node:module";+import { createHash } from "node:crypto";++/** Build-only: reuse the API worker and finite preset contract, never a browser renderer. */+export function storybookAgentAvatarAssets() {+ return {+ name: "storybook-agent-avatar-assets",+ apply: "build",+ async generateBundle() {+ const serverRequire = createRequire(new URL("../server/package.json", import.meta.url));+ const { tsImport } = await import(serverRequire.resolve("tsx/esm/api"));+ const { createAgentAvatarPool } = await tsImport("../server/src/services/agent-avatar-pool.ts", import.meta.url);+ const { AGENT_PALETTE_IDS, AGENT_AVATAR_SIZES, CHARACTER_STATES, appearanceForPalette } =+ await tsImport("../packages/shared/src/agent-appearance.ts", import.meta.url);+ const { agentAvatarUrl } = await tsImport("../ui/storybook/fixtures/agent-avatar-url.ts", import.meta.url);+ const requests = [false, true].flatMap(muted =>+ (muted ? [AGENT_PALETTE_IDS[0]] : AGENT_PALETTE_IDS).flatMap(palette =>+ CHARACTER_STATES.flatMap(pose => AGENT_AVATAR_SIZES.flatMap(size =>+ [1, 2].map(scale => ({ appearance: appearanceForPalette(palette), size, scale, pose, muted }))))));+ const pool = createAgentAvatarPool(2);+ const images = [];+ let next = 0;+ try {+ await Promise.all(Array.from({ length: 2 }, async () => {+ while (next < requests.length) {+ const request = requests[next++];+ const source = await pool.render(request);+ const { appearance, size, scale, pose, muted } = request;+ const fileName = agentAvatarUrl(appearance, size, scale, pose, muted).slice(2);+ this.emitFile({ type: "asset", fileName, source });+ images.push({ path: fileName, sha256: createHash("sha256").update(source).digest("hex"), pixels: size * scale });+ }+ }));+ } finally {+ await pool.close();+ }+ images.sort((a, b) => a.path.localeCompare(b.path));+ this.emitFile({ type: "asset", fileName: "agent-avatar-images/manifest.json",+ source: JSON.stringify({ schemaVersion: 1, images }) });+ console.log(`Packaged ${images.length} agent avatar PNGs using the API renderer.`);+ },+ };+}diff --git a/scripts/sync-agent-palette-tokens.mjs b/scripts/sync-agent-palette-tokens.mjsnew file mode 100644index 0000000000..89511ebb2c--- /dev/null+++ b/scripts/sync-agent-palette-tokens.mjs@@ -0,0 +1,13 @@+import fs from "node:fs";+import { fileURLToPath } from "node:url";+const css = fs.readFileSync(new URL("../ui/src/index.css", import.meta.url), "utf8");+const values = {};+for (const [, name, channel, color] of css.matchAll(/--agent-cap-v1-([a-z-]+)-(a|b):\s*(#[0-9a-f]{6});/g)) {+ (values[name] ??= {})[channel] = color;+}+if (Object.keys(values).length !== 18 || Object.values(values).some(v => !v.a || !v.b)) throw new Error("Incomplete cap-v1 palette tokens");+const output = "// Generated from ui/src/index.css by scripts/sync-agent-palette-tokens.mjs.\nexport const CAP_V1_COLORS = " + JSON.stringify(values, null, 2) + " as const;\n";+const target = new URL("../packages/shared/src/cliplab/palette-tokens.ts", import.meta.url);+if (process.argv.includes("--check")) {+ if (fs.readFileSync(target, "utf8") !== output) throw new Error("Run node scripts/sync-agent-palette-tokens.mjs");+} else fs.writeFileSync(target, output);diff --git a/server/src/__tests__/agent-avatars.test.ts b/server/src/__tests__/agent-avatars.test.tsnew file mode 100644index 0000000000..9e5e9f3892--- /dev/null+++ b/server/src/__tests__/agent-avatars.test.ts@@ -0,0 +1,150 @@+import { afterEach, describe, expect, it, vi } from "vitest";+import { mkdtemp, rm } from "node:fs/promises";+import os from "node:os";+import { Readable } from "node:stream";+import { S3Client, PutObjectCommand, HeadObjectCommand, GetObjectCommand, DeleteObjectCommand } from "@aws-sdk/client-s3";+import { createS3StorageProvider } from "../storage/s3-provider.js";+import path from "node:path";+import express from "express";+import type { Server } from "node:http";+import sharp from "sharp";+import { AGENT_PALETTE_IDS, appearanceForPalette } from "@paperclipai/shared";+import { createLocalDiskStorageProvider } from "../storage/local-disk-provider.js";+import { createAgentAvatarService, avatarCacheKey, type AgentAvatarRequest } from "../services/agent-avatars.js";+import { createAgentAvatarPool } from "../services/agent-avatar-pool.js";+import { agentAvatarRoutes } from "../routes/agent-avatars.js";++const request: AgentAvatarRequest = { appearance: appearanceForPalette("arctic-blue"), size: 24, scale: 2, pose: "rest", muted: false };+const cleanups: Array<() => Promise<unknown>> = [];+afterEach(async () => { await Promise.all(cleanups.splice(0).map(fn => fn())); });+async function consume(stream: Readable) {+ for await (const _ of stream) { /* Finish reads before deleting their cache files. */ }+}+async function storage() {+ const dir = await mkdtemp(path.join(os.tmpdir(), "agent-avatar-test-"));+ cleanups.push(() => rm(dir, { recursive: true, force: true }));+ return createLocalDiskStorageProvider(dir);+}+async function serve(service: ReturnType<typeof createAgentAvatarService>) {+ const app = express(); app.use("/api", agentAvatarRoutes(service));+ const server = await new Promise<Server>(resolve => { const running = app.listen(0, "127.0.0.1", () => resolve(running)); });+ cleanups.push(() => new Promise<void>((resolve, reject) => server.close(error => error ? reject(error) : resolve())));+ return `http://127.0.0.1:${(server.address() as { port: number }).port}/api/agent-avatars/cap-v1/arctic-blue/rest.png`;+}+describe("on-demand agent avatars", () => {+ it("coalesces cold requests, survives restarts and regenerates deleted cache entries", async () => {+ const provider = await storage();+ const render = vi.fn(async () => Buffer.from("png-bytes"));+ const service = createAgentAvatarService(provider, render);+ const results = await Promise.all(Array.from({ length: 10 }, () => service.get(request)));+ expect(render).toHaveBeenCalledTimes(1);+ expect(new Set(results.map(result => result.etag)).size).toBe(1);+ await Promise.all(results.map(async result => { for await (const _ of result.stream) { /* consume */ } }));+ await consume((await createAgentAvatarService(provider, render).get(request)).stream);+ expect(render).toHaveBeenCalledTimes(1);+ await provider.deleteObject({ objectKey: avatarCacheKey(request) });+ await consume((await service.get(request)).stream);+ expect(render).toHaveBeenCalledTimes(2);+ });+ it("limits cold keys per client while admitting warm hits, joiners and other clients", async () => {+ let release!: () => void;+ const blocked = new Promise<void>(resolve => { release = resolve; });+ const render = vi.fn(async () => { await blocked; return Buffer.from("png"); });+ const provider = await storage();+ const service = createAgentAvatarService(provider, render);+ const keys = AGENT_PALETTE_IDS.flatMap(palette => ([16, 20, 24] as const).map(size => ({ ...request, appearance: appearanceForPalette(palette), size })));+ const pending = keys.slice(0, 32).map(key => service.get(key, "one"));+ try {+ await vi.waitFor(() => expect(render).toHaveBeenCalledTimes(32));+ await expect(service.get(keys[32], "one")).rejects.toThrow("Too many cold avatar requests");+ pending.push(service.get(keys[0], "one")); // Same cold key is free.+ pending.push(service.get(keys[32], "two")); // Another client still has room.+ await vi.waitFor(() => expect(render).toHaveBeenCalledTimes(33));+ } finally { release(); }+ for (const result of await Promise.all(pending)) await consume(result.stream);+ await consume((await service.get(keys[0], "one")).stream);+ expect(render).toHaveBeenCalledTimes(33);+ await consume((await service.get(keys[33], "one")).stream); // Completed renders release slots.+ expect(render).toHaveBeenCalledTimes(34);+ });+ it("returns retryable admission errors without caching them", async () => {+ const service = createAgentAvatarService(await storage(), async () => Buffer.from("png"));+ const { AvatarAdmissionError } = await import("../services/agent-avatars.js");+ vi.spyOn(service, "get").mockRejectedValueOnce(new AvatarAdmissionError(12));+ const url = await serve(service);+ const denied = await fetch(url);+ expect(denied.status).toBe(429);+ expect(denied.headers.get("retry-after")).toBe("12");+ expect(denied.headers.get("cache-control")).toBe("no-store");+ await denied.text();+ const retry = await fetch(url); expect(retry.status).toBe(200); await retry.arrayBuffer();+ });+ it("uses the configured S3 prefix and reuses bytes across service instances", async () => {+ const objects = new Map<string, Buffer>();+ const send = vi.spyOn(S3Client.prototype, "send").mockImplementation(async (command: any) => {+ const key = command.input.Key as string;+ expect(command.input.Bucket).toBe("avatar-test");+ expect(key).toMatch(/^paperclip\/generated-agent-avatars\/cap-v1\//);+ if (command instanceof PutObjectCommand) { objects.set(key, Buffer.from(command.input.Body as Uint8Array)); return {}; }+ if (command instanceof DeleteObjectCommand) { objects.delete(key); return {}; }+ const bytes = objects.get(key);+ if (!bytes) throw Object.assign(new Error("missing"), { name: "NoSuchKey" });+ if (command instanceof HeadObjectCommand) return { ContentLength: bytes.length };+ if (command instanceof GetObjectCommand) return { Body: Readable.from(bytes), ContentLength: bytes.length };+ throw new Error("Unexpected S3 command");+ });+ try {+ const provider = createS3StorageProvider({ bucket: "avatar-test", region: "us-east-1", prefix: "paperclip" });+ const render = vi.fn(async () => Buffer.from("s3-avatar"));+ const first = await createAgentAvatarService(provider, render).get(request);+ const second = await createAgentAvatarService(provider, render).get(request);+ expect(second.etag).toEqual(first.etag);+ const firstBytes: Buffer[] = [], secondBytes: Buffer[] = [];+ for await (const chunk of first.stream) firstBytes.push(Buffer.from(chunk));+ for await (const chunk of second.stream) secondBytes.push(Buffer.from(chunk));+ expect(Buffer.concat(secondBytes)).toEqual(Buffer.concat(firstBytes));+ expect(render).toHaveBeenCalledTimes(1);+ await provider.deleteObject({ objectKey: avatarCacheKey(request) });+ await consume((await createAgentAvatarService(provider, render).get(request)).stream);+ expect(render).toHaveBeenCalledTimes(2);+ } finally { send.mockRestore(); }+ });+ it("renders a PNG in an isolated worker without DOM or WebGL", async () => {+ const pool = createAgentAvatarPool(1); cleanups.push(() => pool.close());+ const png = await pool.render(request);+ expect(await sharp(png).metadata()).toMatchObject({ width: 48, height: 48, format: "png", hasAlpha: true });+ }, 20_000);+ it("serves public images with content ETags and validates the finite request space", async () => {+ const render = vi.fn(async () => Buffer.from("png-bytes"));+ const url = await serve(createAgentAvatarService(await storage(), render));+ const first = await fetch(url + "?size=24&scale=2");+ expect(first.status).toBe(200);+ expect(first.headers.get("content-type")).toContain("image/png");+ expect(first.headers.get("cache-control")).toContain("immutable");+ await first.arrayBuffer();+ const second = await fetch(url + "?size=24&scale=2", { headers: { "If-None-Match": first.headers.get("etag")! } });+ expect(second.status).toBe(304);+ for (const suffix of ["?size=99999", "?scale=3", "?color=red", "?size=24&size=32"]) {+ const invalid = await fetch(url + suffix); expect(invalid.status).toBe(400); await invalid.text();+ }+ expect(render).toHaveBeenCalledTimes(1);+ });+ it("settles stream disposal on a 304 even if the cached file disappears during open", async () => {+ const service = createAgentAvatarService(await storage(), async () => Buffer.from("png"));+ const stream = new Readable({+ read() {},+ destroy(_error, callback) { setImmediate(() => callback(new Error("cached file removed during open"))); },+ });+ vi.spyOn(service, "get").mockResolvedValueOnce({ stream, byteSize: 3, etag: '"cached"' });+ const url = await serve(service);+ const response = await fetch(url, { headers: { "If-None-Match": '"cached"' } });+ expect(response.status).toBe(304);+ expect(stream.closed).toBe(true);+ });+ it("does not cache rendering failures and permits retry", async () => {+ const render = vi.fn().mockRejectedValueOnce(new Error("unavailable")).mockResolvedValue(Buffer.from("png"));+ const url = await serve(createAgentAvatarService(await storage(), render));+ const first = await fetch(url); expect(first.status).toBe(503); expect(first.headers.get("cache-control")).toBe("no-store"); await first.text();+ const retry = await fetch(url); expect(retry.status).toBe(200); await retry.arrayBuffer();+ });+});diff --git a/server/src/__tests__/agent-hire-idempotency-routes.test.ts b/server/src/__tests__/agent-hire-idempotency-routes.test.tsindex 1f5b06cc9b..8d2740f40f 100644--- a/server/src/__tests__/agent-hire-idempotency-routes.test.ts+++ b/server/src/__tests__/agent-hire-idempotency-routes.test.ts@@ -136,6 +136,8 @@ describeEmbeddedPostgres("agent hire idempotency within a run", () => {expect(second.status, JSON.stringify(second.body)).toBe(200);expect(second.body.idempotent).toBe(true);expect(second.body.agent?.id).toBe(createdId);+ expect(first.body.agent?.appearance).toMatchObject({ schemaVersion: 1, characterVersion: "cap-v1" });+ expect(second.body.agent?.appearance).toEqual(first.body.agent?.appearance);// The retry must not have auto-renamed a duplicate to "Sam 2".expect(second.body.agent?.name).toBe("Sam");diff --git a/server/src/__tests__/agent-persona-persistence.test.ts b/server/src/__tests__/agent-persona-persistence.test.tsnew file mode 100644index 0000000000..fb39304ddb--- /dev/null+++ b/server/src/__tests__/agent-persona-persistence.test.ts@@ -0,0 +1,53 @@+import { randomUUID } from "node:crypto";+import { readFile } from "node:fs/promises";+import { afterAll, beforeAll, describe, expect, it } from "vitest";+import { eq, sql } from "drizzle-orm";+import { agents, companies, createDb } from "@paperclipai/db";+import { agentAppearanceSchema, appearanceForPalette, legacyAgentAppearance } from "@paperclipai/shared";+import { startEmbeddedPostgresTestDatabase } from "./helpers/embedded-postgres.js";+import { agentService } from "../services/agents.js";++describe("persisted agent personas", () => {+ let database: Awaited<ReturnType<typeof startEmbeddedPostgresTestDatabase>>;+ let db: ReturnType<typeof createDb>;+ let companyId: string;+ beforeAll(async () => {+ database = await startEmbeddedPostgresTestDatabase("agent-persona-persistence-");+ db = createDb(database.connectionString);+ companyId = randomUUID();+ await db.insert(companies).values({ id: companyId, name: "Persona test", issuePrefix: "CAP" });+ }, 30_000);+ afterAll(async () => { await database?.cleanup(); });+ it("randomizes once, accepts a saved draft and preserves identity across edits and revision rollback", async () => {+ const service = agentService(db);+ const random = await service.create(companyId, { name: "Random", role: "engineer", adapterType: "process" });+ expect(agentAppearanceSchema.safeParse(random.appearance).success).toBe(true);+ const appearance = appearanceForPalette("arctic-blue");+ const original = await service.create(companyId, { name: "Draft", role: "engineer", adapterType: "process", appearance });+ expect(original.appearance).toEqual(appearance);+ const updated = await service.update(original.id, { name: "Renamed" }, { recordRevision: { source: "test" } });+ expect(updated?.appearance).toEqual(appearance);+ const [revision] = await service.listConfigRevisions(original.id);+ await service.update(original.id, { name: "Changed again", status: "paused" });+ const restored = await service.rollbackConfigRevision(original.id, revision.id, {});+ expect(restored?.appearance).toEqual(appearance);+ expect((await agentService(db).getById(original.id))?.avatarUrl).toContain("/arctic-blue/rest.png?size=512");+ const [row] = await db.select().from(agents).where(eq(agents.id, original.id));+ expect(row.appearance).toEqual(appearance);+ });+ it("backfills legacy IDs with exactly the same persisted identity as the runtime fallback", async () => {+ const ids = Array.from({ length: 20 }, () => randomUUID());+ await db.insert(agents).values(ids.map((id, i) => ({ id, companyId, name: `Legacy ${i}`, role: "engineer", appearance: null, icon: "bot" })));+ const migration = await readFile(new URL("../../../packages/db/src/migrations/0280_unique_genesis.sql", import.meta.url), "utf8");+ // Replaying the entire migration must preserve saved choices and tolerate+ // an already-created column from an earlier worktree migration number.+ for (let replay = 0; replay < 2; replay++) {+ for (const statement of migration.split("--> statement-breakpoint")) await db.execute(sql.raw(statement));+ }+ for (const id of ids) {+ const [row] = await db.select().from(agents).where(eq(agents.id, id));+ expect(row.appearance).toEqual(legacyAgentAppearance(id));+ expect(row.icon).toBe("bot");+ }+ });+});diff --git a/server/src/__tests__/agents-pending-approval-config.test.ts b/server/src/__tests__/agents-pending-approval-config.test.tsindex 3bb906334a..2977ae4d57 100644--- a/server/src/__tests__/agents-pending-approval-config.test.ts+++ b/server/src/__tests__/agents-pending-approval-config.test.ts@@ -99,6 +99,7 @@ describeEmbeddedPostgres("pending approval agent config integrity", () => {budgetMonthlyCents: 1234,metadata: { source: "hire-form" },agentId: pending.id,+ appearance: pending.appearance,},decisionNote: null,decidedByUserId: null,@@ -143,6 +144,7 @@ describeEmbeddedPostgres("pending approval agent config integrity", () => {await expect(agentSvc.getById(pending.id)).resolves.toMatchObject({status: "idle",+ appearance: pending.appearance,name: "Pending Coder",role: "engineer",title: "Software Engineer",diff --git a/server/src/__tests__/company-portability.test.ts b/server/src/__tests__/company-portability.test.tsindex 354e084ca5..70141793f4 100644--- a/server/src/__tests__/company-portability.test.ts+++ b/server/src/__tests__/company-portability.test.ts@@ -1727,6 +1727,22 @@ describe("company portability", () => {expect(exported.warnings.filter((warning) => warning.includes("could not be exported portably"))).toHaveLength(1);});+ it("round-trips the saved visual persona through the portable bundle", async () => {+ const appearance = { schemaVersion: 1, characterVersion: "cap-v1", paletteId: "arctic-blue" };+ const source = await agentSvc.list();+ agentSvc.list.mockResolvedValue(source.map((agent: Record<string, unknown>) => ({ ...agent, appearance })));+ const portability = companyPortabilityService({} as any);+ const include = { company: true, agents: true, projects: false, issues: false, skills: false };+ const exported = await portability.exportBundle("company-1", { include });+ expect(asTextFile(exported.files[".paperclip.yaml"])).toContain("arctic-blue");+ agentSvc.list.mockResolvedValue([]);+ agentSvc.create.mockImplementation(async (_companyId: string, input: Record<string, unknown>) => ({ ...input, id: `imported-${input.name}` }));+ await portability.importBundle({ source: { type: "inline", files: exported.files, rootPath: exported.rootPath }, include,+ target: { mode: "new_company", newCompanyName: "Imported personas" }, collisionStrategy: "rename", agents: "all" }, "user-1");+ expect(agentSvc.create).toHaveBeenCalled();+ for (const [, input] of agentSvc.create.mock.calls) expect(input).toMatchObject({ appearance });+ });+it("reads env inputs back from .paperclip.yaml during preview import", async () => {const portability = companyPortabilityService({} as any);diff --git a/server/src/__tests__/openapi-routes.test.ts b/server/src/__tests__/openapi-routes.test.tsindex 83c700df28..c3670a67bb 100644--- a/server/src/__tests__/openapi-routes.test.ts+++ b/server/src/__tests__/openapi-routes.test.ts@@ -19,6 +19,7 @@ const apiPrefixes: Record<string, string> = {"activity.ts": "/api","adapters.ts": "/api","agents.ts": "/api",+ "agent-avatars.ts": "/api","announcements.ts": "/api","ai-connections.ts": "/api","attention.ts": "/api",diff --git a/server/src/app.ts b/server/src/app.tsindex 8898f0a3d0..9f1bf9c765 100644--- a/server/src/app.ts+++ b/server/src/app.ts@@ -1,3 +1,4 @@+import { agentAvatarRoutes } from "./routes/agent-avatars.js";import { aiConnectionRoutes } from "./routes/ai-connections.js";import { projectToolRoutes } from "./routes/project-tools.js";import { emailChannelService } from "./services/email-channels.js";@@ -623,6 +624,7 @@ export async function createApp(// Mount API routesconst api = Router();+ api.use(agentAvatarRoutes());api.use(boardMutationGuard());api.use("/health",diff --git a/server/src/routes/agent-avatars.ts b/server/src/routes/agent-avatars.tsnew file mode 100644index 0000000000..3e5c66ffc6--- /dev/null+++ b/server/src/routes/agent-avatars.ts@@ -0,0 +1,58 @@+import { finished, pipeline } from "node:stream/promises";+import { Router } from "express";+import { z } from "zod";+import { AGENT_PALETTE_IDS, AGENT_AVATAR_SIZES, CHARACTER_STATES, appearanceForPalette, type AgentAvatarSize } from "@paperclipai/shared";+import { AvatarAdmissionError, createAgentAvatarService } from "../services/agent-avatars.js";+import { createStorageProviderFromConfig } from "../storage/provider-registry.js";+import { loadConfig } from "../config.js";+import { logger } from "../middleware/logger.js";++const requestSchema = z.object({+ version: z.literal("cap-v1"),+ palette: z.enum([...AGENT_PALETTE_IDS, "muted-dream"]),+ pose: z.enum(CHARACTER_STATES),+ size: z.string().regex(/^\d+$/).default("512").transform(Number).refine(n => (AGENT_AVATAR_SIZES as readonly number[]).includes(n)),+ scale: z.enum(["1", "2"]).default("1"),+}).strict();++/** Public preset artwork only. No agent lookup or tenant data is exposed. */+export function agentAvatarRoutes(injected?: ReturnType<typeof createAgentAvatarService>) {+ const router = Router();+ let service = injected;+ router.get("/agent-avatars/:version/:palette/:file", async (req, res) => {+ const file = String(req.params.file);+ const parsed = requestSchema.safeParse({ ...req.query, version: req.params.version, palette: req.params.palette, pose: file.endsWith(".png") ? file.slice(0, -4) : file });+ if (!file.endsWith(".png") || !parsed.success || Object.keys(req.query).some(key => key !== "size" && key !== "scale")) {+ res.setHeader("Cache-Control", "no-store");+ res.status(400).json({ error: "Unsupported avatar version, palette, pose, size, or scale" }); return;+ }+ const { palette, pose, size, scale } = parsed.data;+ try {+ service ??= createAgentAvatarService(createStorageProviderFromConfig(loadConfig()));+ const { stream, byteSize, etag } = await service.get({ appearance: appearanceForPalette(palette === "muted-dream" ? AGENT_PALETTE_IDS[0] : palette), muted: palette === "muted-dream", pose, size: size as AgentAvatarSize, scale: Number(scale) as 1 | 2 }, req.ip || req.socket.remoteAddress || "unknown");+ res.setHeader("Cache-Control", "public, max-age=31536000, immutable");+ res.setHeader("ETag", etag);+ res.setHeader("X-Content-Type-Options", "nosniff");+ res.type("png");+ const validators = req.get("if-none-match")?.split(",").map(value => value.trim().replace(/^W\//, ""));+ if (validators?.some(value => value === "*" || value === etag)) {+ // ReadStream opens asynchronously. Await disposal so a concurrent cache+ // deletion cannot emit an unhandled open error after the 304 is sent.+ stream.destroy();+ await finished(stream, { cleanup: true }).catch(() => {});+ res.status(304).end(); return;+ }+ res.setHeader("Content-Length", byteSize);+ await pipeline(stream, res);+ } catch (error) {+ if (!(error instanceof AvatarAdmissionError)) logger.warn({ err: error }, "Could not render agent avatar");+ if (res.headersSent || res.destroyed) { res.destroy(); return; }+ res.removeHeader("Content-Length");+ res.removeHeader("ETag");+ res.setHeader("Cache-Control", "no-store");+ res.setHeader("Retry-After", String(error instanceof AvatarAdmissionError ? error.retryAfterSeconds : 5));+ res.status(error instanceof AvatarAdmissionError ? 429 : 503).json({ error: "Avatar temporarily unavailable" });+ }+ });+ return router;+}diff --git a/server/src/routes/agents.ts b/server/src/routes/agents.tsindex e72f983476..159942a147 100644--- a/server/src/routes/agents.ts+++ b/server/src/routes/agents.ts@@ -1,3 +1,4 @@+import { resolveAgentAppearance, agentAvatarUrl } from "@paperclipai/shared";import { listOpenRouterModels } from "../services/openrouter-models.js";import { prepareManagedAiRuntime, assertManagedAiProjectAuth, stripAiAuthBindings } from "../services/ai-connection-runtime.js";import { ADAPTER_AUTH_MISSING_CHECK_CODE, AI_CONNECTION_CAPABILITIES, aiConnectionBindingSchema, type AiConnectionBinding } from "@paperclipai/shared";@@ -3992,6 +3993,7 @@ export function agentRoutes(id: agentsTable.id,companyId: agentsTable.companyId,agentName: agentsTable.name,+ agentAppearance: agentsTable.appearance,role: agentsTable.role,title: agentsTable.title,status: agentsTable.status,@@ -4590,6 +4592,7 @@ export function agentRoutes(role: normalizedHireInput.role,title: normalizedHireInput.title ?? null,icon: normalizedHireInput.icon ?? null,+ appearance: agent.appearance,reportsTo: normalizedHireInput.reportsTo ?? null,capabilities: normalizedHireInput.capabilities ?? null,adapterType: requestedAdapterType,@@ -6604,6 +6607,7 @@ export function agentRoutes(createdAt: heartbeatRuns.createdAt,agentId: heartbeatRuns.agentId,agentName: agentsTable.name,+ agentAppearance: agentsTable.appearance,adapterType: agentsTable.adapterType,logBytes: heartbeatRuns.logBytes,livenessState: heartbeatRuns.livenessState,@@ -6654,6 +6658,8 @@ export function agentRoutes(const projections = await executionProjectionsForRuns(db, companyId, rows.map(run => run.id));res.json(await runRedactions.redactForRuns(companyId, await Promise.all(rows.map(async (run) => ({...heartbeat.decorateActiveRunStatus(run),+ agentAppearance: resolveAgentAppearance(run.agentAppearance, run.agentId),+ avatarUrl: agentAvatarUrl(resolveAgentAppearance(run.agentAppearance, run.agentId), 512),execution: projections.get(run.id) ?? null,outputSilence: await heartbeat.buildRunOutputSilence(run),})))));@@ -6663,6 +6669,8 @@ export function agentRoutes(const projections = await executionProjectionsForRuns(db, companyId, liveRuns.map(run => run.id));res.json(await runRedactions.redactForRuns(companyId, await Promise.all(liveRuns.map(async (run) => ({...heartbeat.decorateActiveRunStatus(run),+ agentAppearance: resolveAgentAppearance(run.agentAppearance, run.agentId),+ avatarUrl: agentAvatarUrl(resolveAgentAppearance(run.agentAppearance, run.agentId), 512),execution: projections.get(run.id) ?? null,outputSilence: await heartbeat.buildRunOutputSilence(run),})))));@@ -7242,6 +7250,7 @@ export function agentRoutes(createdAt: heartbeatRuns.createdAt,agentId: heartbeatRuns.agentId,agentName: agentsTable.name,+ agentAppearance: agentsTable.appearance,adapterType: agentsTable.adapterType,logBytes: heartbeatRuns.logBytes,livenessState: heartbeatRuns.livenessState,@@ -7269,6 +7278,8 @@ export function agentRoutes(const projections = await executionProjectionsForRuns(db, issue.companyId, liveRuns.map(run => run.id));res.json(await Promise.all(liveRuns.map(async (run) => ({...heartbeat.decorateActiveRunStatus(run, { companyId: issue.companyId, issueId: issue.id }),+ agentAppearance: resolveAgentAppearance(run.agentAppearance, run.agentId),+ avatarUrl: agentAvatarUrl(resolveAgentAppearance(run.agentAppearance, run.agentId), 512),execution: projections.get(run.id) ?? null,outputSilence: await heartbeat.buildRunOutputSilence({ ...run, companyId: issue.companyId }),}))));@@ -7331,6 +7342,8 @@ export function agentRoutes(execution: await executionProjectionForRun(db, issue.companyId, run.id),agentId: agent.id,agentName: agent.name,+ agentAppearance: agent.appearance,+ avatarUrl: agent.avatarUrl,adapterType: agent.adapterType,outputSilence: await heartbeat.buildRunOutputSilence({ ...run, companyId: issue.companyId }),});diff --git a/server/src/routes/openapi.ts b/server/src/routes/openapi.tsindex 7f5c582153..e1fb0fcf18 100644--- a/server/src/routes/openapi.ts+++ b/server/src/routes/openapi.ts@@ -14,6 +14,10 @@ import {emailConnectionSchema,emailSendSchema,// Agent+ AGENT_PALETTE_IDS,+ AGENT_AVATAR_SIZES,+ CHARACTER_STATES,+ agentAppearanceSchema,createAgentSchema,createAgentHireSchema,updateAgentSchema,@@ -1270,6 +1274,7 @@ const RUNTIME_TOOLS_OPERATIONS = new Set([]);const PUBLIC_OPERATIONS = new Set([+ "GET /api/agent-avatars/{version}/{palette}/{file}","GET /api/health","GET /api/openapi.json","GET /api/board-claim/{token}",@@ -2668,6 +2673,33 @@ for (const route of [// ─── Agents ──────────────────────────────────────────────────────────────────+registry.register("AgentAppearance", agentAppearanceSchema);+registry.registerPath({+ method: "get",+ path: "/api/agent-avatars/{version}/{palette}/{file}",+ tags: ["agents"],+ summary: "Render or retrieve a public preset agent portrait",+ description: "On-demand PNG artwork; no agent or company lookup. Logical size determines face detail independently of density. Successful URLs are immutable for one year and return a content-derived ETag. Cache entries regenerate after deletion.",+ request: {+ params: z.object({+ version: z.literal("cap-v1"),+ palette: z.enum([...AGENT_PALETTE_IDS, "muted-dream"]),+ file: z.enum(CHARACTER_STATES.map(pose => `${pose}.png`)),+ }),+ query: z.object({+ size: z.enum(AGENT_AVATAR_SIZES.map(String)).optional().default("512"),+ scale: z.enum(["1", "2"]).optional().default("1"),+ }).strict(),+ },+ responses: {+ 200: { description: "PNG portrait; Cache-Control: public, max-age=31536000, immutable; ETag: SHA-256 of PNG bytes", content: { "image/png": { schema: { type: "string", format: "binary" } } } },+ 304: { description: "If-None-Match matches the cached content ETag" },+ 400: r.badRequest,+ 429: { description: "Cold-render admission limit for this client; Cache-Control: no-store; Retry-After in seconds. Cached portraits remain available." },+ 503: { description: "Retryable rendering/storage failure; Cache-Control: no-store; Retry-After: 5" },+ },+});+registry.registerPath({method: "get",path: "/api/companies/{companyId}/built-in-agents",diff --git a/server/src/services/agent-avatar-pool.ts b/server/src/services/agent-avatar-pool.tsnew file mode 100644index 0000000000..bda5ab4a82--- /dev/null+++ b/server/src/services/agent-avatar-pool.ts@@ -0,0 +1,79 @@+import { Worker } from "node:worker_threads";+import type { AgentAvatarRequest } from "./agent-avatars.js";++type Job = { request: AgentAvatarRequest; resolve: (png: Buffer) => void; reject: (error: Error) => void };+/** Lazy, bounded workers isolate geometry/rasterization from the API event loop. */+export function createAgentAvatarPool(concurrency = 2, maxQueue = 64) {+ const queue: Job[] = [];+ let active = 0;+ const idle: Worker[] = [];+ const timers = new Map<Worker, ReturnType<typeof setTimeout>>();+ const workers = new Set<Worker>();+ let closed = false;+ function spawn() {+ const source = new URL(import.meta.url).pathname.endsWith(".ts");+ const url = new URL(source ? "./agent-avatar-worker.ts" : "./agent-avatar-worker.js", import.meta.url);+ const worker = source+ ? new Worker(`import(${JSON.stringify(import.meta.resolve('tsx/esm/api'))}).then(({tsImport}) => tsImport(${JSON.stringify(url.href)}, ${JSON.stringify(import.meta.url)}));`, { eval: true })+ : new Worker(url);+ workers.add(worker);+ // Idle worker failures must not become uncaught events or leave dead slots.+ worker.on("error", () => {});+ worker.on("exit", () => {+ const index = idle.indexOf(worker);+ if (index >= 0) idle.splice(index, 1);+ clearTimeout(timers.get(worker)); timers.delete(worker); workers.delete(worker);+ });+ return worker;+ }+ function drain() {+ while (!closed && active < concurrency && queue.length) {+ const job = queue.shift()!;+ let worker: Worker;+ try { worker = idle.pop() ?? spawn(); }+ catch (error) { job.reject(error instanceof Error ? error : new Error(String(error))); continue; }+ clearTimeout(timers.get(worker)); timers.delete(worker);+ worker.ref(); active++;+ let finished = false;+ const timeout = setTimeout(() => finish(new Error("Avatar rendering timed out")), 15_000);+ const onError = (error: Error) => finish(error);+ const onExit = () => finish(new Error("Avatar worker exited"));+ const onMessage = (result: { png?: Uint8Array; error?: string }) => {+ finish(result.png ? undefined : new Error(result.error ?? "Avatar rendering failed"), result.png);+ };+ function finish(error?: Error, png?: Uint8Array) {+ if (finished) return;+ finished = true; clearTimeout(timeout); active--;+ worker.off("message", onMessage); worker.off("error", onError); worker.off("exit", onExit);+ if (error || closed) {+ workers.delete(worker); void worker.terminate();+ job.reject(error ?? new Error("Avatar pool closed"));+ } else {+ job.resolve(Buffer.from(png!));+ worker.unref(); idle.push(worker);+ const timer = setTimeout(() => {+ const index = idle.indexOf(worker);+ if (index >= 0) idle.splice(index, 1);+ timers.delete(worker); workers.delete(worker); void worker.terminate();+ }, 30_000);+ timer.unref(); timers.set(worker, timer);+ }+ drain();+ }+ worker.once("message", onMessage); worker.once("error", onError); worker.once("exit", onExit);+ try { worker.postMessage(job.request); } catch (error) { finish(error instanceof Error ? error : new Error(String(error))); }+ }+ }+ return {+ render(request: AgentAvatarRequest): Promise<Buffer> {+ if (closed || queue.length >= maxQueue) return Promise.reject(new Error("Avatar renderer is busy"));+ return new Promise((resolve, reject) => { queue.push({ request, resolve, reject }); drain(); });+ },+ async close() {+ closed = true;+ for (const job of queue.splice(0)) job.reject(new Error("Avatar pool closed"));+ for (const timer of timers.values()) clearTimeout(timer);+ await Promise.all([...workers].map(worker => worker.terminate()));+ },+ };+}diff --git a/server/src/services/agent-avatar-worker.ts b/server/src/services/agent-avatar-worker.tsnew file mode 100644index 0000000000..bdb47d7bd6--- /dev/null+++ b/server/src/services/agent-avatar-worker.ts@@ -0,0 +1,14 @@+import { parentPort } from "node:worker_threads";+import sharp from "sharp";+import { renderAgentSvg } from "@paperclipai/shared/cliplab/static";+import type { AgentAvatarRequest } from "./agent-avatars.js";++parentPort!.on("message", async (request: AgentAvatarRequest) => {+ try {+ const svg = renderAgentSvg(request.appearance, request.size, request.scale, request.pose, request.muted);+ const png = await sharp(Buffer.from(svg)).png().toBuffer();+ parentPort!.postMessage({ png });+ } catch (error) {+ parentPort!.postMessage({ error: error instanceof Error ? error.message : "Avatar rendering failed" });+ }+});diff --git a/server/src/services/agent-avatars.ts b/server/src/services/agent-avatars.tsnew file mode 100644index 0000000000..66715f0023--- /dev/null+++ b/server/src/services/agent-avatars.ts@@ -0,0 +1,77 @@+import { createHash } from "node:crypto";+import type { AgentAppearance, AgentAvatarSize, CharacterState } from "@paperclipai/shared";+import type { StorageProvider } from "../storage/types.js";+import { createInviteRateLimiter } from "./invite-rate-limit.js";+import { createAgentAvatarPool } from "./agent-avatar-pool.js";++export interface AgentAvatarRequest {+ appearance: AgentAppearance;+ size: AgentAvatarSize;+ scale: 1 | 2;+ pose: CharacterState;+ muted: boolean;+}+export function avatarCacheKey(request: AgentAvatarRequest) {+ const { appearance, size, scale, pose, muted } = request;+ return `generated-agent-avatars/${appearance.characterVersion}/${muted ? "muted-dream" : appearance.paletteId}/${pose}-${size}-${scale}.png`;+}+export class AvatarAdmissionError extends Error {+ constructor(public readonly retryAfterSeconds: number) { super("Too many cold avatar requests"); }+}+type CacheMetadata = { sha256: string; byteSize: number };+export function createAgentAvatarService(storage: StorageProvider, render?: (request: AgentAvatarRequest) => Promise<Buffer>) {+ const pool = render ? undefined : createAgentAvatarPool();+ const pending = new Map<string, Promise<CacheMetadata>>();+ // Only cold keys consume admission; warm images and single-flight joiners+ // remain available. Leave at least half the pool queue for other clients.+ const activeByClient = new Map<string, number>();+ const limiter = createInviteRateLimiter({ maxRequests: 256 });+ async function ensure(request: AgentAvatarRequest, key: string, client: string): Promise<CacheMetadata> {+ const metadataKey = `${key}.json`;+ const [image, metadata] = await Promise.all([+ storage.headObject({ objectKey: key }), storage.headObject({ objectKey: metadataKey }),+ ]);+ if (image.exists && metadata.exists) {+ const object = await storage.getObject({ objectKey: metadataKey });+ const chunks: Buffer[] = [];+ for await (const chunk of object.stream) chunks.push(Buffer.from(chunk));+ try {+ const cached = JSON.parse(Buffer.concat(chunks).toString()) as CacheMetadata;+ if (/^[a-f0-9]{64}$/.test(cached.sha256) && cached.byteSize > 0 && cached.byteSize === image.contentLength) return cached;+ } catch { /* Disposable metadata: regenerate a corrupt or old cache entry. */ }+ }+ const active = activeByClient.get(client) ?? 0;+ if (active >= 32) throw new AvatarAdmissionError(5);+ const admission = limiter.consume(client);+ if (!admission.allowed) throw new AvatarAdmissionError(admission.retryAfterSeconds);+ activeByClient.set(client, active + 1);+ try {+ const bytes = await (render ?? pool!.render)(request);+ const result = { sha256: createHash("sha256").update(bytes).digest("hex"), byteSize: bytes.length };+ // Both providers publish whole objects atomically. Publish metadata last so+ // readers never consider an unfinished image a completed cache entry.+ await storage.putObject({ objectKey: key, body: bytes, contentLength: bytes.length, contentType: "image/png" });+ const encoded = Buffer.from(JSON.stringify(result));+ await storage.putObject({ objectKey: metadataKey, body: encoded, contentLength: encoded.length, contentType: "application/json" });+ return result;+ } finally {+ const remaining = (activeByClient.get(client) ?? 1) - 1;+ if (remaining) activeByClient.set(client, remaining);+ else activeByClient.delete(client);+ }+ }+ return {+ async get(request: AgentAvatarRequest, client = "unknown") {+ const key = avatarCacheKey(request);+ let result = pending.get(key);+ if (!result) {+ result = ensure(request, key, client).finally(() => pending.delete(key));+ pending.set(key, result);+ }+ const metadata = await result;+ const object = await storage.getObject({ objectKey: key });+ return { stream: object.stream, byteSize: metadata.byteSize, etag: `"${metadata.sha256}"` };+ },+ async close() { await pool?.close(); },+ };+}diff --git a/server/src/services/agents.ts b/server/src/services/agents.tsindex b0f8bd2ca3..c0dd80270d 100644--- a/server/src/services/agents.ts+++ b/server/src/services/agents.ts@@ -1,3 +1,4 @@+import { agentAppearanceSchema, randomAgentAppearance, resolveAgentAppearance, agentAvatarUrl } from "@paperclipai/shared";import { createHash, randomBytes } from "node:crypto";import { and, desc, eq, gte, inArray, lt, ne, or, sql } from "drizzle-orm";import type { Db } from "@paperclipai/db";@@ -68,6 +69,7 @@ const CONFIG_REVISION_FIELDS = ["role","title","icon",+ "appearance","reportsTo","capabilities","adapterType",@@ -167,6 +169,7 @@ function buildConfigSnapshot(role: row.role,title: row.title,icon: row.icon,+ appearance: row.appearance,reportsTo: row.reportsTo,capabilities: row.capabilities,adapterType: row.adapterType,@@ -202,6 +205,7 @@ function configPatchFromApprovalPayload(payload: Record<string, unknown>) {const patch: Partial<typeof agents.$inferInsert> = {};if (typeof payload.name === "string") patch.name = payload.name;if (typeof payload.role === "string") patch.role = payload.role;+ if (payload.appearance != null) patch.appearance = agentAppearanceSchema.parse(payload.appearance);if (Object.prototype.hasOwnProperty.call(payload, "title")) {patch.title = typeof payload.title === "string" ? payload.title : null;}@@ -374,8 +378,11 @@ export function agentService(db: Db) {const eligibilityAgents = allCompanyRows.map(toEligibilityAgent);return rows.map((row) => {const base = normalizeAgentBaseRow(row);+ const appearance = resolveAgentAppearance(row.appearance, row.id);return {...base,+ appearance,+ avatarUrl: agentAvatarUrl(appearance),orgChainHealth: getAgentWorkEligibility({agent: toEligibilityAgent(row),agents: eligibilityAgents,@@ -913,6 +920,7 @@ export function agentService(db: Db) {.values({...data,name: uniqueName,+ appearance: data.appearance == null ? randomAgentAppearance() : agentAppearanceSchema.parse(data.appearance),companyId,role,adapterType,diff --git a/server/src/services/approvals.ts b/server/src/services/approvals.tsindex a21845fa4e..3da5dd6f8f 100644--- a/server/src/services/approvals.ts+++ b/server/src/services/approvals.ts@@ -1,3 +1,4 @@+import { agentAppearanceSchema } from "@paperclipai/shared";import { and, asc, eq, inArray, sql } from "drizzle-orm";import type { Db } from "@paperclipai/db";import { approvalComments, approvals } from "@paperclipai/db";@@ -160,6 +161,7 @@ export function approvalService(db: Db) {} else {const created = await agentsSvc.create(updated.companyId, {name: String(payload.name ?? "New Agent"),+ appearance: payload.appearance == null ? undefined : agentAppearanceSchema.parse(payload.appearance),role: String(payload.role ?? "general"),title: typeof payload.title === "string" ? payload.title : null,reportsTo: typeof payload.reportsTo === "string" ? payload.reportsTo : null,diff --git a/server/src/services/company-portability.ts b/server/src/services/company-portability.tsindex 23ec71f0fe..7c7501f631 100644--- a/server/src/services/company-portability.ts+++ b/server/src/services/company-portability.ts@@ -1,3 +1,4 @@+import { agentAppearanceSchema } from "@paperclipai/shared";import { createHash, randomUUID } from "node:crypto";import { promises as fs } from "node:fs";import { execFile } from "node:child_process";@@ -702,6 +703,7 @@ type ProjectLike = {targetDate: string | null;color: string | null;icon: string | null;+ appearance?: import("@paperclipai/shared").AgentAppearance | null;status: string;env: Record<string, unknown> | null;executionWorkspacePolicy: Record<string, unknown> | null;@@ -3238,6 +3240,7 @@ function buildManifestFromPackageFiles(role: asString(extension.role) ?? asString(frontmatter.role) ?? "agent",title,icon: asString(extension.icon),+ appearance: extension.appearance == null ? undefined : agentAppearanceSchema.parse(extension.appearance),capabilities: asString(extension.capabilities),reportsToSlug: asString(frontmatter.reportsTo) ?? asString(extension.reportsTo),reportsToExistingAgentId: asString(extension.reportsToExistingAgentId),@@ -4254,6 +4257,7 @@ export function companyPortabilityService(db: Db, storage?: StorageService) {const extension = stripEmptyValues({role: agent.role !== "agent" ? agent.role : undefined,icon: agent.icon ?? null,+ appearance: agent.appearance,capabilities: agent.capabilities ?? null,adapter: {type: agent.adapterType,@@ -5592,6 +5596,7 @@ export function companyPortabilityService(db: Db, storage?: StorageService) {role: manifestAgent.role,title: manifestAgent.title,icon: manifestAgent.icon,+ ...(manifestAgent.appearance ? { appearance: manifestAgent.appearance } : {}),capabilities: manifestAgent.capabilities,reportsTo: null,adapterType: normalizedAdapter.adapterType,diff --git a/server/src/services/costs.ts b/server/src/services/costs.tsindex 781d0cae11..700e347dc9 100644--- a/server/src/services/costs.ts+++ b/server/src/services/costs.ts@@ -1,3 +1,4 @@+import { agentAvatarUrl, resolveAgentAppearance } from "@paperclipai/shared";import { and, desc, eq, gte, isNotNull, isNull, lt, lte, sql } from "drizzle-orm";import { alias } from "drizzle-orm/pg-core";import type { Db } from "@paperclipai/db";@@ -282,10 +283,11 @@ export function costService(db: Db, budgetHooks: BudgetServiceHooks = {}) {if (range?.from) conditions.push(gte(costEvents.occurredAt, range.from));if (range?.to) conditions.push(lte(costEvents.occurredAt, range.to));- return db+ const rows = await db.select({agentId: costEvents.agentId,agentName: agents.name,+ agentAppearance: agents.appearance,agentStatus: agents.status,costCents: sumAsNumber(costEvents.costCents),inputTokens: sumAsNumber(costEvents.inputTokens),@@ -305,8 +307,12 @@ export function costService(db: Db, budgetHooks: BudgetServiceHooks = {}) {.from(costEvents).leftJoin(agents, eq(costEvents.agentId, agents.id)).where(and(...conditions))- .groupBy(costEvents.agentId, agents.name, agents.status)+ .groupBy(costEvents.agentId, agents.name, agents.appearance, agents.status).orderBy(desc(sumAsNumber(costEvents.costCents)));+ return rows.map(row => {+ const appearance = resolveAgentAppearance(row.agentAppearance, row.agentId);+ return { ...row, agentAppearance: appearance, avatarUrl: agentAvatarUrl(appearance, 512) };+ });},byProvider: async (companyId: string, range?: CostDateRange) => {@@ -431,10 +437,11 @@ export function costService(db: Db, budgetHooks: BudgetServiceHooks = {}) {// the (companyId, agentId, occurredAt) composite index covers this well.// order by provider + model for stable db-level ordering; cost-desc sort// within each agent's sub-rows is done client-side in the ui memo.- return db+ const rows = await db.select({agentId: costEvents.agentId,agentName: agents.name,+ agentAppearance: agents.appearance,provider: costEvents.provider,biller: costEvents.biller,billingType: costEvents.billingType,@@ -450,12 +457,17 @@ export function costService(db: Db, budgetHooks: BudgetServiceHooks = {}) {.groupBy(costEvents.agentId,agents.name,+ agents.appearance,costEvents.provider,costEvents.biller,costEvents.billingType,costEvents.model,).orderBy(costEvents.provider, costEvents.biller, costEvents.billingType, costEvents.model);+ return rows.map(row => {+ const appearance = resolveAgentAppearance(row.agentAppearance, row.agentId);+ return { ...row, agentAppearance: appearance, avatarUrl: agentAvatarUrl(appearance, 512) };+ });},byProject: async (companyId: string, range?: CostDateRange) => {diff --git a/server/src/services/secret-proposals.ts b/server/src/services/secret-proposals.tsindex c8364a4566..f3b29ae862 100644--- a/server/src/services/secret-proposals.ts+++ b/server/src/services/secret-proposals.ts@@ -1,3 +1,4 @@+import { withAgentAppearance } from "@paperclipai/shared";import { and, count, desc, eq, gte, inArray, lte, or, sql } from "drizzle-orm";import type { Db } from "@paperclipai/db";import {@@ -479,10 +480,10 @@ export function createSecretProposalsService(db: Db) {async function enrich(proposal: Proposal) {const [proposer, target, originIssue, secret, secretProposal] = await Promise.all([- db.select({ id: agents.id, name: agents.name, icon: agents.icon }).from(agents)+ db.select({ id: agents.id, name: agents.name, icon: agents.icon, appearance: agents.appearance }).from(agents).where(eq(agents.id, proposal.proposedByAgentId)).then((rows) => rows[0] ?? null),proposal.targetId- ? db.select({ id: agents.id, name: agents.name, icon: agents.icon }).from(agents)+ ? db.select({ id: agents.id, name: agents.name, icon: agents.icon, appearance: agents.appearance }).from(agents).where(eq(agents.id, proposal.targetId)).then((rows) => rows[0] ?? null): Promise.resolve(null),proposal.originIssueId@@ -510,8 +511,8 @@ export function createSecretProposalsService(db: Db) {...safe,secretName: secret?.name ?? null,secretProposalName: secretProposal?.proposedName ?? null,- proposedBy: proposer,- target,+ proposedBy: withAgentAppearance(proposer),+ target: target ? withAgentAppearance(target) : null,originIssue,};}diff --git a/server/src/services/work-timeline.ts b/server/src/services/work-timeline.tsindex 7eb35a4614..59676cb33a 100644--- a/server/src/services/work-timeline.ts+++ b/server/src/services/work-timeline.ts@@ -1,3 +1,4 @@+import { withAgentAppearance } from "@paperclipai/shared";import { and, asc, desc, eq, gte, inArray, isNull, lte, or, sql } from "drizzle-orm";import type { Db } from "@paperclipai/db";import {@@ -430,7 +431,7 @@ export function workTimelineService(db: Db) {const [agentRows, userRows] = await Promise.all([agentIds.length > 0? db- .select({ id: agents.id, name: agents.name, icon: agents.icon })+ .select({ id: agents.id, name: agents.name, icon: agents.icon, appearance: agents.appearance }).from(agents).where(and(eq(agents.companyId, companyId), inArray(agents.id, maybeUuidList(agentIds)))): [],@@ -763,7 +764,8 @@ export function workTimelineService(db: Db) {const [type, rawId] = id.split(":", 2) as [TimelineActorType, string];if (type === "agent") {const agent = actorMaps.agents.get(rawId);- return { id, type, name: agent?.name ?? "Unknown agent", avatar: agent?.icon ?? null };+ const identity = withAgentAppearance(agent ?? { id: rawId });+ return { id, type, name: agent?.name ?? "Unknown agent", avatar: identity.avatarUrl, appearance: identity.appearance, avatarUrl: identity.avatarUrl };}if (type === "user") {const user = actorMaps.users.get(rawId);diff --git a/tests/storybook-visual/agent-personas.config.ts b/tests/storybook-visual/agent-personas.config.tsnew file mode 100644index 0000000000..bfda1740b6--- /dev/null+++ b/tests/storybook-visual/agent-personas.config.ts@@ -0,0 +1,13 @@+import { defineConfig } from "@playwright/test";+import visualConfig from "./playwright.config";+export default defineConfig({+ webServer: process.env.PAPERCLIP_PERSONA_STORYBOOK_URL ? undefined : visualConfig.webServer,+ testDir: ".", testMatch: "agent-personas.spec.ts", workers: 1, retries: 0, timeout: 45_000,+ outputDir: "./test-results/agent-personas", reporter: [["list"]],+ snapshotPathTemplate: "{testDir}/.snapshots/agent-personas/{arg}{ext}",+ use: {+ browserName: "chromium", baseURL: process.env.PAPERCLIP_PERSONA_STORYBOOK_URL ?? "http://localhost:6106",+ viewport: { width: 1200, height: 900 }, deviceScaleFactor: 1, reducedMotion: "reduce",+ launchOptions: { args: ["--use-angle=swiftshader", "--enable-unsafe-swiftshader"] },+ },+});diff --git a/tests/storybook-visual/agent-personas.spec.ts b/tests/storybook-visual/agent-personas.spec.tsnew file mode 100644index 0000000000..555a8e653e--- /dev/null+++ b/tests/storybook-visual/agent-personas.spec.ts@@ -0,0 +1,156 @@+import { test, expect, type Page } from "@playwright/test";+async function story(page: Page, id: string, args = "", theme = "dark") {+ await page.goto(`/iframe.html?id=agents-personas--${id}&viewMode=story&globals=theme:${theme}${args ? `&args=${args}` : ""}`);+ await page.locator("#storybook-root").waitFor();+ await expect.poll(() => page.locator("#storybook-root").evaluate(element => element.childElementCount)).toBeGreaterThan(0);+}+async function imagesLoaded(page: Page) {+ await page.locator("#storybook-root img").evaluateAll(images => images.forEach(image => image.setAttribute("loading", "eager")));+ await expect.poll(() => page.locator("#storybook-root img").evaluateAll(images => images.every(image => (image as HTMLImageElement).complete && (image as HTMLImageElement).naturalWidth > 0))).toBe(true);+}+for (const theme of ["light", "dark"]) {+ for (const id of ["palettes", "sizes", "expressions", "app-placements", "gray-before-connection"]) {+ test(`${id} on ${theme}`, async ({ page }) => {+ await page.emulateMedia({ reducedMotion: "reduce" });+ await story(page, id, "", theme); await imagesLoaded(page);+ expect(await page.evaluate(() => matchMedia("(prefers-reduced-motion: reduce)").matches)).toBe(true);+ await expect(page.locator("canvas")).toHaveCount(0);+ await expect(page.locator("#storybook-root")).toHaveScreenshot(`${id}-${theme}.png`, { animations: "disabled", maxDiffPixels: 0 });+ });+ }+}+test("500 avatars load images without WebGL, live modules or avatar frame loops", async ({ page }) => {+ await page.emulateMedia({ reducedMotion: "no-preference" });+ await page.addInitScript(() => {+ (window as any).__personaProbe = { webgl: 0, frames: 0 };+ const getContext = HTMLCanvasElement.prototype.getContext;+ HTMLCanvasElement.prototype.getContext = function (kind: string, ...args: any[]) {+ if (kind.includes("webgl")) (window as any).__personaProbe.webgl++;+ return (getContext as any).call(this, kind, ...args);+ } as any;+ const raf = window.requestAnimationFrame;+ window.requestAnimationFrame = callback => {+ if (/\/(runtime|renderer)-/.test(new Error().stack ?? "")) (window as any).__personaProbe.frames++;+ return raf(callback);+ };+ });+ const liveDownloads: string[] = [];+ page.on("request", req => { if (/\/(runtime|renderer)-[^/]+\.js/.test(req.url())) liveDownloads.push(req.url()); });+ await story(page, "five-hundred-static-avatars"); await imagesLoaded(page);+ await expect(page.locator("#storybook-root img")).toHaveCount(500);+ await expect(page.locator("canvas")).toHaveCount(0);+ expect(await page.evaluate(() => (window as any).__personaProbe)).toEqual({ webgl: 0, frames: 0 });+ expect(liveDownloads).toEqual([]);+});+test("image failures and slow cold responses preserve dimensions", async ({ page }) => {+ let release!: () => void;+ const held = new Promise<void>(resolve => { release = resolve; });+ await page.route("**/agent-avatar-images/**", async route => { await held; await route.abort(); });+ await story(page, "cache-miss-loading");+ const image = page.locator("#storybook-root img");+ const before = await image.boundingBox();+ expect(before?.width).toBe(64); expect(before?.height).toBe(64);+ release();+ await expect(page.locator("#storybook-root")).toContainText("CS");+ const fallback = page.locator("#storybook-root span").filter({ hasText: /^CS$/ }).first();+ expect((await fallback.boundingBox())?.width).toBe(64);+});+test("one live renderer and static fallback after context loss", async ({ page }) => {+ await page.emulateMedia({ reducedMotion: "no-preference" });+ await story(page, "one-live-renderer");+ await expect(page.locator("canvas")).toHaveCount(1);+ await story(page, "render-failure");+ await expect(page.locator("canvas")).toHaveCount(1);+ await page.getByRole("button", { name: "Simulate WebGL loss" }).click();+ await expect(page.locator("canvas")).toHaveCount(0); await imagesLoaded(page);+});+test("repeated mounting releases the WebGL canvas", async ({ page }) => {+ await page.emulateMedia({ reducedMotion: "no-preference" });+ await story(page, "mount-and-unmount");+ for (let i = 0; i < 3; i++) {+ await expect(page.locator("canvas")).toHaveCount(1);+ await page.getByRole("button", { name: "Toggle character" }).click();+ await expect(page.locator("canvas")).toHaveCount(0);+ await page.getByRole("button", { name: "Toggle character" }).click();+ }+});+const snapshotCases = [+ ...[16, 24, 48, 256].flatMap(size => [1, 2].map(density => ({ size, density, state: "rest" }))),+ ...["idle", "listening", "thinking", "working", "success", "confused", "sleepy", "loading"].map(state => ({ size: 128, density: 2, state })),+];+for (const { size, density, state } of snapshotCases) {+ test(`front-facing SVG and WebGL ${state} at ${size}px density ${density}`, async ({ browser, baseURL }) => {+ const context = await browser.newContext({ deviceScaleFactor: density, reducedMotion: "reduce", baseURL });+ const page = await context.newPage();+ await story(page, "snapshot-agreement", `size:${size};state:${state};density:${density}`); await imagesLoaded(page);+ await expect(page.locator("canvas")).toHaveCount(1);+ await expect(page.locator("#storybook-root")).toHaveScreenshot(`snapshot-pair-${size}-${density}-${state}.png`, { scale: "device", maxDiffPixels: 0 });+ // Same transparent silhouette. Small antialiasing differences are expected+ // between sharp's SVG rasterizer and WebGL's multisample rasterizer.+ const difference = await page.evaluate(async () => {+ const image = document.querySelector('#storybook-root img') as HTMLImageElement;+ const live = document.querySelector('#live-frame canvas, [data-testid="live-frame"] canvas') as HTMLCanvasElement;+ const width = live.width, height = live.height;+ const a = document.createElement("canvas"); a.width = width; a.height = height;+ const b = document.createElement("canvas"); b.width = width; b.height = height;+ const ac = a.getContext("2d")!, bc = b.getContext("2d")!;+ ac.drawImage(image, 0, 0, width, height); bc.drawImage(live, 0, 0, width, height);+ const aa = ac.getImageData(0, 0, width, height).data, bb = bc.getImageData(0, 0, width, height).data;+ let silhouette = 0, colorError = 0, opaque = 0;+ for (let i = 0; i < aa.length; i += 4) {+ if ((aa[i + 3] > 128) !== (bb[i + 3] > 128)) silhouette++;+ if (aa[i + 3] > 240 && bb[i + 3] > 240) { for (let c = 0; c < 3; c++) colorError += Math.abs(aa[i + c] - bb[i + c]); opaque++; }+ }+ return { silhouette: silhouette / (width * height), meanColorError: colorError / (opaque * 3) };+ });+ expect(difference.silhouette).toBeLessThan(0.04);+ expect(difference.meanColorError).toBeLessThan(20);+ await context.close();+ });+}++const fullPages = ["all-agents", "agent-overview", "task", "company-dashboard", "meet-your-next-agent", "new-agent-connection"];+for (const id of fullPages) {+ test(`full app page: ${id}`, async ({ page }) => {+ await page.emulateMedia({ reducedMotion: "reduce" });+ await page.clock.setFixedTime(new Date("2026-09-10T18:00:00Z"));+ await page.goto(`/iframe.html?id=agents-personas-full-pages--${id}&viewMode=story&globals=theme:dark`);+ await expect(page.locator("main")).toBeVisible();+ await expect(page.locator("main")).not.toContainText("This page hit an error");+ await expect(page.locator('img[src*="/agent-avatar-images/"]').first()).toBeAttached();+ if (id === "company-dashboard") await expect(page.getByText("Live now", { exact: true })).toBeVisible();+ await imagesLoaded(page);+ await expect(page.locator("canvas")).toHaveCount(0);+ await expect(page).toHaveScreenshot(`full-page-${id}.png`, { animations: "disabled", maxDiffPixels: 0 });+ });+}+for (const density of [1, 2]) {+ test(`onboarding supersamples and stays inside the canvas at density ${density}`, async ({ browser, baseURL }) => {+ const context = await browser.newContext({ viewport: { width: 1200, height: 900 }, deviceScaleFactor: density, reducedMotion: "no-preference", baseURL });+ const page = await context.newPage();+ await page.goto("/iframe.html?id=agents-personas-full-pages--meet-your-next-agent&viewMode=story");+ await expect(page.locator("canvas")).toHaveCount(1);+ const canvas = page.locator("canvas");+ const dimensions = await canvas.evaluate(c => ({ pixels: (c as HTMLCanvasElement).width, display: c.getBoundingClientRect().width }));+ expect(dimensions.display).toBe(192);+ expect(dimensions.pixels).toBe(dimensions.display * density * 2);+ for (const [x, y] of [[5, 5], [1195, 5], [1195, 895], [5, 895]]) {+ await page.mouse.move(x, y);+ // Let gaze settle at each page corner, well outside the character region.+ await page.waitForTimeout(350);+ const edgeAlpha = await canvas.evaluate(c => {+ const source = c as HTMLCanvasElement;+ const copy = document.createElement("canvas"); copy.width = source.width; copy.height = source.height;+ const ctx = copy.getContext("2d")!; ctx.drawImage(source, 0, 0);+ const pixels = ctx.getImageData(0, 0, copy.width, copy.height).data;+ let maximum = 0;+ for (let y = 0; y < copy.height; y++) for (let x = 0; x < copy.width; x++) {+ if (x < 2 || y < 2 || x >= copy.width - 2 || y >= copy.height - 2) maximum = Math.max(maximum, pixels[(y * copy.width + x) * 4 + 3]);+ }+ return maximum;+ });+ expect(edgeAlpha).toBe(0);+ }+ await context.close();+ });+}diff --git a/tests/storybook-visual/playwright.config.ts b/tests/storybook-visual/playwright.config.tsindex ac11aaf1b9..679f048f4f 100644--- a/tests/storybook-visual/playwright.config.ts+++ b/tests/storybook-visual/playwright.config.ts@@ -14,6 +14,17 @@ const snapshotDir = process.env.STORYBOOK_VISUAL_SNAPSHOT_DIR// 0 baseline downloaded by scripts/storybook-visual-baseline.mjs.export default defineConfig({testDir: ".",+ projects: [+ { name: "stories", testIgnore: "agent-personas.spec.ts" },+ {+ name: "agent-personas", testMatch: "agent-personas.spec.ts", fullyParallel: false,+ snapshotPathTemplate: `${snapshotDir}/agent-personas/{arg}{ext}`,+ use: {+ viewport: { width: 1200, height: 900 },+ launchOptions: { args: ["--use-angle=swiftshader", "--enable-unsafe-swiftshader"] },+ },+ },+ ],outputDir: "./test-results",timeout: 60_000,retries: 1,diff --git a/ui/src/api/heartbeats.ts b/ui/src/api/heartbeats.tsindex 4d2863655b..cf913ef005 100644--- a/ui/src/api/heartbeats.ts+++ b/ui/src/api/heartbeats.ts@@ -1,3 +1,4 @@+import type { AgentAppearance } from "@paperclipai/shared";import type { IssueRecoveryAction } from "@paperclipai/shared";import type {HeartbeatRun,@@ -31,6 +32,8 @@ export interface ActiveRunForIssue {createdAt: string | Date;agentId: string;agentName: string;+ agentAppearance?: AgentAppearance | null;+ avatarUrl?: string;adapterType: string;logBytes?: number | null;lastOutputBytes?: number | null;@@ -62,6 +65,8 @@ export interface LiveRunForIssue {createdAt: string;agentId: string;agentName: string;+ agentAppearance?: AgentAppearance | null;+ avatarUrl?: string;adapterType: string;logBytes?: number | null;lastOutputBytes?: number | null;diff --git a/ui/src/components/ActiveAgentsPanel.tsx b/ui/src/components/ActiveAgentsPanel.tsxindex 25bbb97b18..ebef8e0084 100644--- a/ui/src/components/ActiveAgentsPanel.tsx+++ b/ui/src/components/ActiveAgentsPanel.tsx@@ -1,3 +1,4 @@+import { AgentIdentity } from "@/components/AgentIdentity";import { memo, useMemo } from "react";import { Link } from "@/lib/router";import { useQueries, useQuery } from "@tanstack/react-query";@@ -8,7 +9,6 @@ import { issuesApi } from "../api/issues";import { queryKeys } from "../lib/queryKeys";import { cn, relativeTime } from "../lib/utils";import { Clock3 } from "lucide-react";-import { Identity } from "./Identity";import { StatusGlyph } from "./StatusGlyph";import { RunChatSurface } from "./RunChatSurface";import { useLiveRunTranscripts } from "./transcript/useLiveRunTranscripts";@@ -190,7 +190,7 @@ export const AgentRunCard = memo(function AgentRunCard({aria-label={`${run.agentName} — ${statusLabel}. View run`}className="flex min-w-0 items-center gap-2 rounded-md text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">- <Identity name={run.agentName} className="gap-2 font-medium" />+ <AgentIdentity agent={{ id: run.agentId, name: run.agentName, appearance: run.agentAppearance }} size="sm" className="gap-2 font-medium" /></Link>{run.issueId ? (diff --git a/ui/src/components/ActivityFeed.tsx b/ui/src/components/ActivityFeed.tsxindex 90263a7c65..9c061f64c9 100644--- a/ui/src/components/ActivityFeed.tsx+++ b/ui/src/components/ActivityFeed.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { useMemo, useState, useRef, useCallback, useEffect } from "react";import { useQuery } from "@tanstack/react-query";import { useVisibilityRefetchInterval } from "@/lib/polling";@@ -26,7 +27,6 @@ import {TooltipTrigger,} from "@/components/ui/tooltip";import { ListFilter, Layers, ChevronDown, ChevronRight, User, Settings } from "lucide-react";-import { AgentIcon } from "./AgentIconPicker";import { timeAgo } from "../lib/timeAgo";/* ------------------------------------------------------------------ */@@ -280,7 +280,7 @@ function CollapsedFeedGroup({: <ChevronRight className="h-3 w-3 shrink-0 text-muted-foreground" />}{group.latestEvent.actorType === "agent"- ? <AgentIcon icon={actor?.icon ?? null} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ ? <AgentAvatar agent={actor} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/>: group.latestEvent.actorType === "user"? <User className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />: <Settings className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />diff --git a/ui/src/components/ActivityRow.tsx b/ui/src/components/ActivityRow.tsxindex f2ca58a21c..c6e1fa5831 100644--- a/ui/src/components/ActivityRow.tsx+++ b/ui/src/components/ActivityRow.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "./AgentAvatar";import { Link } from "@/lib/router";import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";import { deriveInitials } from "./Identity";@@ -54,10 +55,14 @@ export function ActivityRow({ event, agentMap, userProfileMap, entityNameMap, enconst inner = (<div className="space-y-2"><div className="flex items-start gap-2 @xl:grid @xl:grid-cols-(--dashboard-activity-list-columns) @xl:items-baseline">- <Avatar size="sm" aria-hidden="true" className="@xl:self-center">- {actorAvatarUrl && <AvatarImage src={actorAvatarUrl} alt="" />}- <AvatarFallback>{deriveInitials(actorName)}</AvatarFallback>- </Avatar>+ {event.actorType === "agent" ? (+ <AgentAvatar agent={actor} name={actorName} size={24} className="@xl:self-center" />+ ) : (+ <Avatar size="sm" aria-hidden="true" className="@xl:self-center">+ {actorAvatarUrl && <AvatarImage src={actorAvatarUrl} alt="" />}+ <AvatarFallback>{deriveInitials(actorName)}</AvatarFallback>+ </Avatar>+ )}<div className="flex min-w-0 flex-1 flex-col gap-1 @xl:contents"><div className="flex min-w-0 items-baseline gap-2 @xl:contents"><p className="flex h-6 min-w-0 flex-1 items-center gap-1.5">diff --git a/ui/src/components/AgentAvatar.tsx b/ui/src/components/AgentAvatar.tsxnew file mode 100644index 0000000000..8ab2d16624--- /dev/null+++ b/ui/src/components/AgentAvatar.tsx@@ -0,0 +1,34 @@+import { agentAvatarUrl } from "@/lib/agent-avatar-url";+import { useState } from "react";+import { resolveAgentAppearance, type AgentAppearance, type AgentAvatarSize, type CharacterState } from "@paperclipai/shared";+import { cn } from "@/lib/utils";+import { deriveInitials } from "./Identity";++export type AvatarAgent = { id?: string; name?: string; appearance?: AgentAppearance | null; avatarUrl?: string | null };+export const avatarSizeClasses: Record<AgentAvatarSize, string> = {+ 16: "size-4", 20: "size-5", 24: "size-6", 32: "size-8", 40: "size-10", 48: "size-12",+ 64: "size-16", 96: "size-24", 128: "size-32", 256: "size-64", 512: "size-128",+};+export interface AgentAvatarProps {+ agent?: AvatarAgent | null;+ appearance?: AgentAppearance | null;+ size?: AgentAvatarSize;+ name?: string;+ label?: string;+ pose?: CharacterState;+ muted?: boolean;+ className?: string;+}+export function AgentAvatar({ agent, appearance, size = 24, name, label, pose = "rest", muted = false, className }: AgentAvatarProps) {+ const identity = resolveAgentAppearance(appearance ?? agent?.appearance, agent?.id);+ const src = agentAvatarUrl(identity, size, 1, pose, muted);+ const [failedUrl, setFailedUrl] = useState<string | null>(null);+ return (+ <span data-slot="agent-avatar" className={cn("relative inline-flex shrink-0 items-center justify-center align-middle", avatarSizeClasses[size], className)}+ role={label ? "img" : undefined} aria-label={label} aria-hidden={label ? undefined : true}>+ {failedUrl === src ? <span className="text-xs text-muted-foreground">{deriveInitials(name ?? agent?.name ?? "Agent")}</span> :+ <img src={src} srcSet={`${agentAvatarUrl(identity, size, 2, pose, muted)} 2x`} alt="" width={size} height={size}+ decoding="async" loading="lazy" className="size-full object-contain" onError={() => setFailedUrl(src)} />}+ </span>+ );+}diff --git a/ui/src/components/AgentCharacter.tsx b/ui/src/components/AgentCharacter.tsxnew file mode 100644index 0000000000..d85bd2f650--- /dev/null+++ b/ui/src/components/AgentCharacter.tsx@@ -0,0 +1,63 @@+import { useEffect, useMemo, useRef, useState, useSyncExternalStore, type RefObject } from "react";+import { resolveAgentAppearance, type CharacterState } from "@paperclipai/shared";+import { cn } from "@/lib/utils";+import { characterSlot } from "@/lib/agent-character-slot";+import { AgentAvatar, avatarSizeClasses, type AgentAvatarProps } from "./AgentAvatar";+import type { createCharacter } from "@paperclipai/shared/cliplab/runtime";++type Player = ReturnType<typeof createCharacter>;+export interface AgentCharacterProps extends Omit<AgentAvatarProps, "pose"> {+ state?: CharacterState;+ motion?: "auto" | "still";+ trackingRegion?: RefObject<HTMLElement | null>;+ trackingScope?: "region" | "page";+ followCursor?: boolean;+ followRotation?: boolean;+}+export function AgentCharacter({ agent, appearance, size = 256, state = "idle", muted = false, motion = "auto", trackingRegion, trackingScope = "region", followCursor = true, followRotation = true, className, label, name }: AgentCharacterProps) {+ const identity = useMemo(() => resolveAgentAppearance(appearance ?? agent?.appearance, agent?.id), [appearance, agent?.appearance, agent?.id]);+ const root = useRef<HTMLSpanElement>(null), host = useRef<HTMLSpanElement>(null), player = useRef<Player | null>(null);+ const slotId = useRef(Symbol("agent-character"));+ const owner = useSyncExternalStore(characterSlot.subscribe, characterSlot.getSnapshot, () => null);+ const [visible, setVisible] = useState(false), [reduced, setReduced] = useState(true), [failed, setFailed] = useState(false), [ready, setReady] = useState(false);+ const active = visible && !reduced && !failed && motion === "auto" && state !== "rest";+ useEffect(() => {+ if (typeof matchMedia !== "function" || typeof IntersectionObserver !== "function") return;+ const media = matchMedia("(prefers-reduced-motion: reduce)");+ const change = () => setReduced(media.matches); change(); media.addEventListener("change", change);+ const observer = new IntersectionObserver(entries => setVisible(entries[0]?.isIntersecting ?? false));+ if (root.current) observer.observe(root.current);+ return () => { observer.disconnect(); media.removeEventListener("change", change); };+ }, []);+ useEffect(() => {+ if (active && owner === null) characterSlot.acquire(slotId.current);+ if (!active) characterSlot.release(slotId.current);+ }, [active, owner]);+ useEffect(() => () => characterSlot.release(slotId.current), []);+ useEffect(() => {+ if (!active || owner !== slotId.current) return;+ let disposed = false;+ setReady(false);+ void Promise.all([import("@paperclipai/shared/cliplab/runtime"), import("@paperclipai/shared/cliplab/definition")]).then(([runtime, library]) => {+ if (disposed || !host.current) return;+ player.current = runtime.createCharacter(host.current, library.characterDefinition(identity, muted), {+ animation: library.animationId(state), trackingRegion: trackingRegion?.current ?? root.current ?? undefined,+ followCursor, followRotation, trackingScope, displaySize: size, onError: () => setFailed(true),+ });+ setReady(true);+ }).catch(() => { if (!disposed) setFailed(true); });+ return () => { disposed = true; player.current?.destroy(); player.current = null; setReady(false); };+ }, [active, owner, trackingRegion, trackingScope, size, followCursor, followRotation]);+ useEffect(() => {+ if (!player.current) return;+ void import("@paperclipai/shared/cliplab/definition").then(library => {+ player.current?.setDefinition(library.characterDefinition(identity, muted));+ player.current?.setAnimation(library.animationId(state));+ });+ }, [identity, muted, state, ready]);+ return <span ref={root} role={label ? "img" : undefined} aria-label={label} aria-hidden={label ? undefined : true}+ className={cn("relative inline-block shrink-0", avatarSizeClasses[size], className)}>+ <AgentAvatar agent={agent} appearance={identity} size={size < 256 ? 256 : size} name={name} pose={state} muted={muted} className={cn("size-full", ready && "invisible")} />+ <span ref={host} className="absolute inset-0" />+ </span>;+}diff --git a/ui/src/components/AgentCharacterRuntime.test.ts b/ui/src/components/AgentCharacterRuntime.test.tsnew file mode 100644index 0000000000..f240df5cb1--- /dev/null+++ b/ui/src/components/AgentCharacterRuntime.test.ts@@ -0,0 +1,85 @@+// @vitest-environment jsdom+import { afterEach, beforeEach, expect, it, vi } from "vitest";+import { createCharacter } from "@paperclipai/shared/cliplab/runtime";+import { characterDefinition } from "@paperclipai/shared/cliplab/definition";+import { appearanceForPalette } from "@paperclipai/shared";+const renderer = vi.hoisted(() => ({ render: vi.fn(), resize: vi.fn(), dispose: vi.fn() }));+vi.mock("@paperclipai/shared/cliplab/renderer", () => ({ CharacterRenderer: class { render = renderer.render; resize = renderer.resize; dispose = renderer.dispose; } }));+let intersect: (entries: any[]) => void;+let hidden = false;+let frames: Map<number, FrameRequestCallback>;+let reduced: MediaQueryList;+let coarse: MediaQueryList;+let target: HTMLDivElement;+let region: HTMLDivElement;+const players: Array<ReturnType<typeof createCharacter>> = [];+function media() { return Object.assign(new EventTarget(), { matches: false }) as unknown as MediaQueryList; }+beforeEach(() => {+ vi.clearAllMocks(); renderer.render.mockReset(); hidden = false; frames = new Map(); reduced = media(); coarse = media();+ let id = 0;+ vi.stubGlobal("requestAnimationFrame", (callback: FrameRequestCallback) => { frames.set(++id, callback); return id; });+ vi.stubGlobal("cancelAnimationFrame", (key: number) => frames.delete(key));+ vi.stubGlobal("matchMedia", (query: string) => query.includes("reduced-motion") ? reduced : coarse);+ vi.spyOn(document, "hidden", "get").mockImplementation(() => hidden);+ vi.stubGlobal("IntersectionObserver", class { constructor(callback: typeof intersect) { intersect = callback; } observe() {} disconnect() {} });+ vi.stubGlobal("ResizeObserver", class { observe() {} disconnect() {} });+ target = document.createElement("div"); region = document.createElement("div"); region.appendChild(target); document.body.appendChild(region);+});+afterEach(() => { players.splice(0).forEach(player => player.destroy()); region.remove(); vi.restoreAllMocks(); vi.unstubAllGlobals(); });+function create() {+ const player = createCharacter(target, characterDefinition(appearanceForPalette("arctic-blue")), { trackingRegion: region });+ players.push(player); return player;+}+it("stops scheduling offscreen, when hidden, for reduced motion, and after disposal", () => {+ const player = create(); expect(frames.size).toBe(0);+ intersect([{ isIntersecting: true }]); expect(frames.size).toBe(1);+ hidden = true; document.dispatchEvent(new Event("visibilitychange")); expect(frames.size).toBe(0);+ hidden = false; document.dispatchEvent(new Event("visibilitychange")); expect(frames.size).toBe(1);+ Object.assign(reduced, { matches: true }); reduced.dispatchEvent(new Event("change")); expect(frames.size).toBe(0);+ Object.assign(reduced, { matches: false }); reduced.dispatchEvent(new Event("change")); expect(frames.size).toBe(1);+ intersect([{ isIntersecting: false }]); expect(frames.size).toBe(0);+ intersect([{ isIntersecting: true }]); player.destroy(); player.destroy();+ expect(frames.size).toBe(0); expect(renderer.dispose).toHaveBeenCalledTimes(1); expect(target.children).toHaveLength(0);+});+it("tracks only its region, ignores touch, and removes listeners for coarse pointers", () => {+ const add = vi.spyOn(region, "addEventListener"), remove = vi.spyOn(region, "removeEventListener");+ const documentAdd = vi.spyOn(document, "addEventListener");+ create(); intersect([{ isIntersecting: true }]);+ expect(add.mock.calls.some(([event]) => event === "pointermove")).toBe(true);+ expect(documentAdd.mock.calls.some(([event]) => event === "pointermove")).toBe(false);+ const before = renderer.render.mock.calls.at(-1)?.[3];+ region.dispatchEvent(Object.assign(new Event("pointermove"), { pointerType: "touch", clientX: 100, clientY: 100 }));+ const [id, frame] = [...frames][0]; frames.delete(id); frame(performance.now() + 16);+ expect(renderer.render.mock.calls.at(-1)?.[3]).toEqual(before);+ Object.assign(coarse, { matches: true }); coarse.dispatchEvent(new Event("change"));+ expect(remove.mock.calls.some(([event]) => event === "pointermove")).toBe(true);+});+it("disposes the canvas and subscriptions when the first render fails", () => {+ renderer.render.mockImplementationOnce(() => { throw new Error("lost context"); });+ expect(() => create()).toThrow("lost context");+ expect(renderer.dispose).toHaveBeenCalledTimes(1); expect(target.children).toHaveLength(0); expect(frames.size).toBe(0);+});++it("falls back when a later expression render fails", () => {+ const onError = vi.fn();+ const player = createCharacter(target, characterDefinition(appearanceForPalette("arctic-blue")), { onError });+ players.push(player); intersect([{ isIntersecting: true }]);+ renderer.render.mockImplementationOnce(() => { throw new Error("lost context"); });+ expect(() => player.setAnimation("success")).not.toThrow();+ expect(onError).toHaveBeenCalledOnce(); expect(frames.size).toBe(0);+});++it("can follow the whole page while measuring gaze from the character and cleaning up", () => {+ const page = document.documentElement;+ const remove = vi.spyOn(page, "removeEventListener");+ vi.spyOn(target, "getBoundingClientRect").mockReturnValue({ left: 100, top: 100, width: 100, height: 100 } as DOMRect);+ const player = createCharacter(target, characterDefinition(appearanceForPalette("arctic-blue")), { trackingScope: "page", displaySize: 256 });+ players.push(player); intersect([{ isIntersecting: true }]);+ // Outside the character and its parent region, but still on the page.+ page.dispatchEvent(Object.assign(new Event("pointermove"), { pointerType: "mouse", clientX: 900, clientY: 150 }));+ const [id, frame] = [...frames][0]; frames.delete(id); frame(performance.now() + 50);+ const gaze = renderer.render.mock.calls.at(-1)?.[3];+ expect(gaze.x).toBeGreaterThan(0); expect(gaze.y).toBe(0);+ player.destroy();+ expect(remove.mock.calls.some(([event]) => event === "pointermove")).toBe(true);+});diff --git a/ui/src/components/AgentIdentity.tsx b/ui/src/components/AgentIdentity.tsxnew file mode 100644index 0000000000..86f7e38d11--- /dev/null+++ b/ui/src/components/AgentIdentity.tsx@@ -0,0 +1,9 @@+import { AgentAvatar, type AvatarAgent } from "./AgentAvatar";+import { cn } from "@/lib/utils";+export function AgentIdentity({ agent, size = "default", className }: { agent: AvatarAgent; size?: "xs" | "sm" | "default" | "lg"; className?: string }) {+ const pixels = { xs: 20, sm: 24, default: 32, lg: 40 } as const;+ return <span title={agent.name} className={cn("inline-flex min-w-0 items-center gap-1.5", className)}>+ <AgentAvatar agent={agent} size={pixels[size]} />+ <span className={cn("truncate", size === "sm" ? "text-xs" : "text-sm")}>{agent.name ?? "Agent"}</span>+ </span>;+}diff --git a/ui/src/components/AgentMultiSelect.tsx b/ui/src/components/AgentMultiSelect.tsxindex ad0579895c..5c38fec2c3 100644--- a/ui/src/components/AgentMultiSelect.tsx+++ b/ui/src/components/AgentMultiSelect.tsx@@ -1,6 +1,6 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { useEffect, useMemo, useState, type ComponentProps, type ReactNode } from "react";import { ChevronRight } from "lucide-react";-import { AgentIcon } from "@/components/AgentIconPicker";import { Button } from "@/components/ui/button";import { Checkbox } from "@/components/ui/checkbox";import { Input } from "@/components/ui/input";@@ -94,7 +94,7 @@ export function AgentSelect({setOpen(false);}}>- <AgentIcon icon={agent.icon ?? null} className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" />+ <AgentAvatar agent={agent} size={16} className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"/><span className="flex min-w-0 flex-col"><span className="truncate text-sm font-medium text-foreground">{agent.name}</span>{agent.title ? <span className="truncate text-xs text-muted-foreground">{agent.title}</span> : null}@@ -261,7 +261,7 @@ export function AgentMultiSelect({setSelection(next);}}/>- <AgentIcon icon={agent.icon ?? null} className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" />+ <AgentAvatar agent={agent} size={16} className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"/><span className="flex min-w-0 flex-col"><span className="flex items-center gap-1.5 text-sm font-medium text-foreground"><span className="truncate">{agent.name}</span>@@ -306,7 +306,7 @@ export function AgentMultiSelect({<div className="space-y-0.5">{selectedAgents.slice(0, 3).map((agent) => (<div key={agent.id} className="flex items-center gap-2 px-1.5 py-1 text-sm">- <AgentIcon icon={agent.icon ?? null} className="h-4 w-4 shrink-0 text-muted-foreground" />+ <AgentAvatar agent={agent} size={16} className="h-4 w-4 shrink-0 text-muted-foreground"/><span className="min-w-0 flex-1 truncate text-foreground">{agent.name}</span></div>))}diff --git a/ui/src/components/AgentPersona.test.tsx b/ui/src/components/AgentPersona.test.tsxnew file mode 100644index 0000000000..340166f9a7--- /dev/null+++ b/ui/src/components/AgentPersona.test.tsx@@ -0,0 +1,89 @@+// @vitest-environment jsdom+import { act } from "react";+import { createRoot, type Root } from "react-dom/client";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { appearanceForPalette } from "@paperclipai/shared";+import { AgentAvatar } from "./AgentAvatar";+import { AgentCharacter } from "./AgentCharacter";+import { useAgentAppearanceDraft } from "../hooks/useAgentAppearanceDraft";++const renderer = vi.hoisted(() => ({ destroy: vi.fn(), setDefinition: vi.fn(), setAnimation: vi.fn() }));+const createCharacter = vi.hoisted(() => vi.fn(() => renderer));+vi.mock("@paperclipai/shared/cliplab/runtime", () => ({ createCharacter }));+vi.mock("@paperclipai/shared/cliplab/definition", () => ({ characterDefinition: vi.fn(value => value), animationId: vi.fn(value => value) }));+(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true;+let root: Root;+let host: HTMLDivElement;+let observers: Array<(entries: any[]) => void>;+let reduced = false;+const appearance = appearanceForPalette("bubblegum-sky");+beforeEach(() => {+ vi.clearAllMocks(); observers = []; reduced = false;+ sessionStorage.clear();+ host = document.createElement("div"); document.body.appendChild(host); root = createRoot(host);+ vi.stubGlobal("IntersectionObserver", class {+ constructor(callback: (entries: any[]) => void) { observers.push(callback); }+ observe() {} disconnect() {}+ });+ vi.stubGlobal("matchMedia", () => ({ matches: reduced, addEventListener() {}, removeEventListener() {} }));+});+afterEach(async () => { await act(async () => root.unmount()); host.remove(); vi.unstubAllGlobals(); });+async function show() { await act(async () => { for (const observer of observers) observer([{ isIntersecting: true }]); }); }+describe("agent persona presentation", () => {+ it("renders 500 static images without initializing a live renderer", async () => {+ await act(async () => root.render(<>{Array.from({ length: 500 }, (_, i) => <AgentAvatar key={i} appearance={appearance} size={24} />)}</>));+ expect(host.querySelectorAll("img")).toHaveLength(500);+ expect(host.querySelector("canvas")).toBeNull();+ expect(createCharacter).not.toHaveBeenCalled();+ expect(host.querySelector("img")?.getAttribute("srcset")).toContain("size=24&scale=2");+ expect(host.querySelector("img")?.getAttribute("width")).toBe("24");+ });+ it("keeps reserved image dimensions and falls back to initials after an image error", async () => {+ await act(async () => root.render(<AgentAvatar appearance={appearance} name="Chief of Staff" size={48} label="Chief of Staff" />));+ expect(host.querySelector("img")?.height).toBe(48);+ await act(async () => { host.querySelector("img")!.dispatchEvent(new Event("error")); });+ expect(host.textContent).toBe("CS");+ expect(host.querySelector('[role="img"]')?.getAttribute("aria-label")).toBe("Chief of Staff");+ });+ it("allows only one live character, releases it offscreen and disposes on unmount", async () => {+ await act(async () => root.render(<><AgentCharacter appearance={appearance} /><AgentCharacter appearance={appearance} /></>));+ expect(createCharacter).not.toHaveBeenCalled();+ await show();+ expect(createCharacter).toHaveBeenCalledTimes(1);+ await act(async () => { observers[0]([{ isIntersecting: false }]); });+ expect(renderer.destroy).toHaveBeenCalledTimes(1);+ expect(createCharacter).toHaveBeenCalledTimes(2);+ await act(async () => root.render(null));+ expect(renderer.destroy).toHaveBeenCalledTimes(2);+ });+ it("uses only static images for reduced motion and an explicit still policy", async () => {+ reduced = true;+ await act(async () => root.render(<><AgentCharacter appearance={appearance} /><AgentCharacter appearance={appearance} motion="still" /></>));+ await show();+ expect(createCharacter).not.toHaveBeenCalled();+ expect(host.querySelectorAll("img")).toHaveLength(2);+ });+ it("selects the correct saved draft when the company changes without remounting", async () => {+ let draft!: ReturnType<typeof useAgentAppearanceDraft>;+ function Draft({ company }: { company: string }) { draft = useAgentAppearanceDraft(`${company}:new-agent`); return null; }+ sessionStorage.setItem("paperclip.agent-appearance.two:new-agent", JSON.stringify(appearance));+ await act(async () => root.render(<Draft company="one" />));+ const first = draft.appearance;+ await act(async () => root.render(<Draft company="two" />));+ expect(draft.appearance).toEqual(appearance);+ await act(async () => root.render(<Draft company="one" />));+ expect(draft.appearance).toEqual(first);+ });+ it("retains the draft assignment across remounts and clears it only after creation", async () => {+ let draft!: ReturnType<typeof useAgentAppearanceDraft>;+ function Draft() { draft = useAgentAppearanceDraft("company:new-agent"); return null; }+ await act(async () => root.render(<Draft />));+ const first = draft.appearance;+ await act(async () => root.render(null));+ await act(async () => root.render(<Draft />));+ expect(draft.appearance).toEqual(first);+ expect(JSON.parse(sessionStorage.getItem("paperclip.agent-appearance.company:new-agent")!)).toEqual(first);+ draft.clear();+ expect(sessionStorage.getItem("paperclip.agent-appearance.company:new-agent")).toBeNull();+ });+});diff --git a/ui/src/components/AgentProperties.tsx b/ui/src/components/AgentProperties.tsxindex c0fdffd1d7..a2cbd4dd08 100644--- a/ui/src/components/AgentProperties.tsx+++ b/ui/src/components/AgentProperties.tsx@@ -1,3 +1,4 @@+import { AgentIdentity } from "@/components/AgentIdentity";import { useQuery } from "@tanstack/react-query";import { Link } from "@/lib/router";import { AGENT_ROLE_LABELS, type Agent, type AgentRuntimeState } from "@paperclipai/shared";@@ -96,7 +97,7 @@ export function AgentProperties({ agent, runtimeState }: AgentPropertiesProps) {<PropertyRow label="Reports To">{reportsToAgent ? (<Link to={agentUrl(reportsToAgent)} className="hover:underline">- <Identity name={reportsToAgent.name} size="sm" />+ <AgentIdentity agent={reportsToAgent} size="sm" /></Link>) : (<span className="text-sm font-mono">{agent.reportsTo.slice(0, 8)}</span>diff --git a/ui/src/components/ApprovalCard.tsx b/ui/src/components/ApprovalCard.tsxindex abfe67cae0..55c7a957cb 100644--- a/ui/src/components/ApprovalCard.tsx+++ b/ui/src/components/ApprovalCard.tsx@@ -1,3 +1,4 @@+import { AgentIdentity } from "@/components/AgentIdentity";import { CheckCircle2, XCircle, Clock } from "lucide-react";import { Link } from "@/lib/router";import { Badge } from "@/components/ui/badge";@@ -71,7 +72,7 @@ export function ApprovalCard({{requesterAgent && (<div className="inline-flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground"><span>Requested by</span>- <Identity name={requesterAgent.name} size="sm" className="inline-flex" />+ <AgentIdentity agent={requesterAgent} size="sm" className="inline-flex" /></div>)}</div>diff --git a/ui/src/components/BlockedInboxView.tsx b/ui/src/components/BlockedInboxView.tsxindex f8f18a6cbe..dee2ec3c7a 100644--- a/ui/src/components/BlockedInboxView.tsx+++ b/ui/src/components/BlockedInboxView.tsx@@ -1,3 +1,4 @@+import { AgentIdentity } from "@/components/AgentIdentity";import { useMemo, useState } from "react";import { useQuery } from "@tanstack/react-query";import { AlertTriangle, CheckCircle2 } from "lucide-react";@@ -29,6 +30,7 @@ interface BlockedInboxViewProps {companyId: string;searchQuery: string;agentNameById: ReadonlyMap<string, string>;+ agents?: import("./AgentAvatar").AvatarAgent[];userLabelById?: ReadonlyMap<string, string>;issueLinkState: unknown;groupBy: BlockedInboxGroupBy;@@ -50,6 +52,7 @@ export function BlockedInboxView({companyId,searchQuery,agentNameById,+ agents,userLabelById,issueLinkState,groupBy,@@ -217,7 +220,7 @@ export function BlockedInboxView({key={row.issue.id}row={row}issueLinkState={issueLinkState}- agentNameById={agentNameById}+ agentNameById={agentNameById} agents={agents}userLabelById={userLabelById}liveIssueIds={liveIssueIds}subtreeLiveCounts={subtreeLiveCounts}@@ -247,7 +250,7 @@ export function BlockedInboxView({key={row.issue.id}row={row}issueLinkState={issueLinkState}- agentNameById={agentNameById}+ agentNameById={agentNameById} agents={agents}userLabelById={userLabelById}liveIssueIds={liveIssueIds}subtreeLiveCounts={subtreeLiveCounts}@@ -272,6 +275,7 @@ interface BlockedInboxRowProps {row: BlockedInboxIssueRow;issueLinkState: unknown;agentNameById: ReadonlyMap<string, string>;+ agents?: import("./AgentAvatar").AvatarAgent[];userLabelById?: ReadonlyMap<string, string>;liveIssueIds: ReadonlySet<string>;subtreeLiveCounts: ReadonlyMap<string, number>;@@ -301,6 +305,7 @@ function BlockedInboxRow({row,issueLinkState,agentNameById,+ agents,userLabelById,liveIssueIds,subtreeLiveCounts,@@ -330,11 +335,7 @@ function BlockedInboxRow({</span>{ownerName ? (<span className="hidden w-(--sz-150px) min-w-0 items-center text-muted-foreground sm:inline-flex">- <Identity- name={ownerName}- size="xs"- className="max-w-full"- />+ {isAgent ? <AgentIdentity agent={agents?.find((agent) => agent.id === row.attention.owner.agentId) ?? { id: row.attention.owner.agentId ?? undefined, name: ownerName }} size="xs" className="max-w-full" /> : <Identity name={ownerName} size="xs" className="max-w-full" />}</span>) : (<span className="hidden w-(--sz-150px) shrink-0 sm:inline-flex" aria-hidden="true" />diff --git a/ui/src/components/CommandPalette.tsx b/ui/src/components/CommandPalette.tsxindex 320547f2ff..25f3d2ace6 100644--- a/ui/src/components/CommandPalette.tsx+++ b/ui/src/components/CommandPalette.tsx@@ -1,3 +1,4 @@+import { AgentIdentity } from "@/components/AgentIdentity";import { useState, useEffect, useMemo } from "react";import { useLocation, useNavigate } from "@/lib/router";import { useQuery } from "@tanstack/react-query";@@ -408,7 +409,7 @@ export function CommandPalette() {<span className="flex-1 truncate">{issue.title}</span>{issue.assigneeAgentId && (() => {const name = agentName(issue.assigneeAgentId);- return name ? <Identity name={name} size="sm" className="ml-2 hidden sm:inline-flex" /> : null;+ return name ? <AgentIdentity agent={agents?.find((agent) => agent.id === issue.assigneeAgentId) ?? { id: issue.assigneeAgentId, name }} size="sm" className="ml-2 hidden sm:inline-flex" /> : null;})()}</CommandItem>))}diff --git a/ui/src/components/CommentThread.tsx b/ui/src/components/CommentThread.tsxindex 6f26b23ae9..328bf906ca 100644--- a/ui/src/components/CommentThread.tsx+++ b/ui/src/components/CommentThread.tsx@@ -1,3 +1,5 @@+import { AgentIdentity } from "./AgentIdentity";+import { AgentAvatar } from "@/components/AgentAvatar";import { memo, useEffect, useMemo, useRef, useState, type ChangeEvent } from "react";import { Link, useLocation } from "react-router-dom";import type {@@ -18,7 +20,6 @@ import { MarkdownBody, type MarkdownExternalReferenceMap } from "./MarkdownBody"import { MarkdownEditor, type MarkdownEditorRef, type MentionOption } from "./MarkdownEditor";import { OutputFeedbackButtons } from "./OutputFeedbackButtons";import { ApprovalCard } from "./ApprovalCard";-import { AgentIcon } from "./AgentIconPicker";import { formatAssigneeUserLabel } from "../lib/assignees";import { formatTimelineWorkspaceLabel, type IssueTimelineAssignee, type IssueTimelineEvent } from "../lib/issue-timeline-events";import { timeAgo } from "../lib/timeAgo";@@ -344,8 +345,8 @@ function CommentCard({<div className="flex items-center justify-between mb-1">{comment.authorAgentId ? (<Link to={`/agents/${comment.authorAgentId}`} className="hover:underline">- <Identity- name={agentMap?.get(comment.authorAgentId)?.name ?? comment.authorAgentId.slice(0, 8)}+ <AgentIdentity+ agent={agentMap?.get(comment.authorAgentId) ?? { id: comment.authorAgentId, name: comment.authorAgentId.slice(0, 8) }}size="sm"/></Link>@@ -478,9 +479,9 @@ function TimelineEventCard({return (<div id={`activity-${event.id}`} className="flex items-start gap-2.5 py-1.5">- <Avatar size="sm" className="mt-0.5">- <AvatarFallback>{initialsForName(actorName)}</AvatarFallback>- </Avatar>+ {event.actorType === "agent" ? <AgentAvatar agent={agentMap?.get(event.actorId) ?? { id: event.actorId, name: actorName }} size={32} className="mt-0.5" /> : (+ <Avatar size="sm" className="mt-0.5"><AvatarFallback>{initialsForName(actorName)}</AvatarFallback></Avatar>+ )}<div className="min-w-0 flex-1 space-y-1.5"><div className="flex flex-wrap items-baseline gap-x-1.5 gap-y-1 text-sm">@@ -624,9 +625,7 @@ const TimelineList = memo(function TimelineList({const actorName = agentMap?.get(run.agentId)?.name ?? run.agentId.slice(0, 8);return (<div id={`run-${run.runId}`} key={`run:${run.runId}`} className="flex items-center gap-2.5 py-1.5">- <Avatar size="sm">- <AvatarFallback>{initialsForName(actorName)}</AvatarFallback>- </Avatar>+ <AgentAvatar agent={agentMap?.get(run.agentId) ?? { id: run.agentId, name: actorName }} size={32} /><div className="min-w-0 flex-1"><div className="flex flex-wrap items-center gap-x-1.5 gap-y-1 text-sm">@@ -829,6 +828,7 @@ export function CommentThread({kind: "agent",agentId: a.id,agentIcon: a.icon,+ agentAppearance: a.appearance,}));}, [agentMap, providedMentions]);@@ -1060,7 +1060,7 @@ export function CommentThread({return (<>{agent ? (- <AgentIcon icon={agent.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ <AgentAvatar agent={agent} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/>) : null}<span className="truncate">{option.label}</span></>@@ -1073,7 +1073,7 @@ export function CommentThread({return (<>{agent ? (- <AgentIcon icon={agent.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ <AgentAvatar agent={agent} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/>) : null}<span className="truncate">{option.label}</span></>diff --git a/ui/src/components/DocumentAnnotationPanel.tsx b/ui/src/components/DocumentAnnotationPanel.tsxindex 52de5c6ec0..9ba72ec627 100644--- a/ui/src/components/DocumentAnnotationPanel.tsx+++ b/ui/src/components/DocumentAnnotationPanel.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "./AgentAvatar";import { useCallback, useMemo, useRef, useState, useEffect } from "react";import type {DocumentAnnotationComment,@@ -23,7 +24,6 @@ import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";import { cn, relativeTime } from "@/lib/utils";import type { DocumentAnnotationTarget } from "@/api/document-annotations";import { useCopyToast } from "@/lib/use-copy-action";-import { AgentIcon } from "./AgentIconPicker";import { deriveInitials } from "./Identity";import { MarkdownBody } from "./MarkdownBody";import type { PendingAnchor } from "./DocumentAnnotationLayer";@@ -59,7 +59,7 @@ export interface AnnotationPanelProps {inline?: boolean;className?: string;/** Resolve `<authorAgentId>` to a display name. */- agentMap?: ReadonlyMap<string, Pick<Agent, "id" | "name"> & Partial<Pick<Agent, "icon">>>;+ agentMap?: ReadonlyMap<string, Pick<Agent, "id" | "name"> & Partial<Pick<Agent, "icon" | "appearance">>>;/** Resolve `<authorUserId>` to a display name. */userProfileMap?: ReadonlyMap<string, CompanyUserProfile>;}@@ -327,7 +327,7 @@ export function ThreadCard(props: {onCopyLink: () => void;pendingReply: boolean;pendingStatus: boolean;- agentMap?: ReadonlyMap<string, Pick<Agent, "id" | "name"> & Partial<Pick<Agent, "icon">>>;+ agentMap?: ReadonlyMap<string, Pick<Agent, "id" | "name"> & Partial<Pick<Agent, "icon" | "appearance">>>;userProfileMap?: ReadonlyMap<string, CompanyUserProfile>;}) {const { thread } = props;@@ -462,7 +462,7 @@ function CommentRow({}: {comment: DocumentAnnotationComment;focused: boolean;- agentMap?: ReadonlyMap<string, Pick<Agent, "id" | "name"> & Partial<Pick<Agent, "icon">>>;+ agentMap?: ReadonlyMap<string, Pick<Agent, "id" | "name"> & Partial<Pick<Agent, "icon" | "appearance">>>;userProfileMap?: ReadonlyMap<string, CompanyUserProfile>;}) {const author = resolveAuthor(comment, { agentMap, userProfileMap });@@ -477,18 +477,11 @@ function CommentRow({><div className="mb-0.5 flex items-center justify-between gap-2 text-(length:--text-micro)"><span className="flex min-w-0 items-center gap-1.5">+ {author.role === "agent" ? <AgentAvatar agent={author.agent} size={20} /> : (<Avatar size="xs" className="shrink-0">- {author.role === "agent" ? (- <AvatarFallback>- <AgentIcon icon={author.agentIcon} className="h-3 w-3" />- </AvatarFallback>- ) : (- <>- {author.imageUrl ? <AvatarImage src={author.imageUrl} alt={author.name} /> : null}- <AvatarFallback>{deriveInitials(author.name)}</AvatarFallback>- </>- )}- </Avatar>+ {author.imageUrl ? <AvatarImage src={author.imageUrl} alt={author.name} /> : null}+ <AvatarFallback>{deriveInitials(author.name)}</AvatarFallback>+ </Avatar>)}<span className="truncate font-medium text-foreground">{author.name}</span>{author.role === "agent" ? (<span className="text-muted-foreground">· agent</span>@@ -509,16 +502,17 @@ function isSubmitShortcut(event: React.KeyboardEvent<HTMLTextAreaElement>): boolfunction resolveAuthor(comment: DocumentAnnotationComment,maps: {- agentMap?: ReadonlyMap<string, Pick<Agent, "id" | "name"> & Partial<Pick<Agent, "icon">>>;+ agentMap?: ReadonlyMap<string, Pick<Agent, "id" | "name"> & Partial<Pick<Agent, "icon" | "appearance">>>;userProfileMap?: ReadonlyMap<string, CompanyUserProfile>;},-): { name: string; role: "board" | "agent"; agentIcon?: Agent["icon"]; imageUrl?: string | null } {+): { name: string; role: "board" | "agent"; agentIcon?: Agent["icon"]; agent?: import("./AgentAvatar").AvatarAgent; imageUrl?: string | null } {if (comment.authorAgentId) {const agent = maps.agentMap?.get(comment.authorAgentId);return {name: agent?.name ?? comment.authorAgentId.slice(0, 8),role: "agent",agentIcon: agent?.icon,+ agent: agent ?? { id: comment.authorAgentId },};}if (comment.authorUserId) {diff --git a/ui/src/components/DocumentFrameHeader.tsx b/ui/src/components/DocumentFrameHeader.tsxindex bb88c48e12..5ceb670964 100644--- a/ui/src/components/DocumentFrameHeader.tsx+++ b/ui/src/components/DocumentFrameHeader.tsx@@ -1,3 +1,4 @@+import { AgentAvatar, type AvatarAgent } from "./AgentAvatar";import type { ReactNode } from "react";import { ChevronDown, ChevronRight } from "lucide-react";import { cn, relativeTime } from "../lib/utils";@@ -13,13 +14,13 @@ import {DropdownMenuRadioItem,DropdownMenuTrigger,} from "@/components/ui/dropdown-menu";-import { AgentIcon } from "./AgentIconPicker";import { deriveInitials } from "./Identity";export type DocumentFrameHeaderRevisionActor = {kind: "agent" | "user" | "system";name: string;agentIcon?: string | null;+ agent?: AvatarAgent;imageUrl?: string | null;};@@ -57,18 +58,11 @@ export interface DocumentFrameHeaderProps {}function RevisionActorAvatar({ actor }: { actor: DocumentFrameHeaderRevisionActor }) {+ if (actor.kind === "agent") return <AgentAvatar agent={actor.agent} name={actor.name} size={20} />;return (- <Avatar size="xs" shape={actor.kind === "agent" ? "square" : "circle"} className="shrink-0">- {actor.kind === "agent" ? (- <AvatarFallback>- <AgentIcon icon={actor.agentIcon} className="h-3 w-3" />- </AvatarFallback>- ) : (- <>- {actor.imageUrl ? <AvatarImage src={actor.imageUrl} alt={actor.name} /> : null}- <AvatarFallback>{deriveInitials(actor.name)}</AvatarFallback>- </>- )}+ <Avatar size="xs" className="shrink-0">+ {actor.imageUrl ? <AvatarImage src={actor.imageUrl} alt={actor.name} /> : null}+ <AvatarFallback>{deriveInitials(actor.name)}</AvatarFallback></Avatar>);}diff --git a/ui/src/components/ExecutionParticipantPicker.tsx b/ui/src/components/ExecutionParticipantPicker.tsxindex 3acfdbd74d..b13d60748f 100644--- a/ui/src/components/ExecutionParticipantPicker.tsx+++ b/ui/src/components/ExecutionParticipantPicker.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { useMemo, useState } from "react";import type { Agent, Issue } from "@paperclipai/shared";import { useQuery } from "@tanstack/react-query";@@ -13,7 +14,6 @@ import {import { cn } from "../lib/utils";import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";import { User, Eye, ShieldCheck } from "lucide-react";-import { AgentIcon } from "./AgentIconPicker";type StageType = "review" | "approval";@@ -189,7 +189,7 @@ export function ExecutionParticipantPicker({)}onClick={() => toggle(encoded)}>- <AgentIcon icon={agent.icon} className="shrink-0 h-3 w-3 text-muted-foreground" />+ <AgentAvatar agent={agent} size={16} className="shrink-0 h-3 w-3 text-muted-foreground"/>{agent.name}</button>);diff --git a/ui/src/components/FeedCard.tsx b/ui/src/components/FeedCard.tsxindex e88c0bb9c7..91e703848c 100644--- a/ui/src/components/FeedCard.tsx+++ b/ui/src/components/FeedCard.tsx@@ -1,5 +1,5 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { Link } from "@/lib/router";-import { AgentIcon } from "./AgentIconPicker";import { timeAgo } from "../lib/timeAgo";import { cn } from "../lib/utils";import { deriveProjectUrlKey, type ActivityEvent, type Agent } from "@paperclipai/shared";@@ -380,10 +380,8 @@ function resolveContent(function ActorGlyph({ content }: { content: CardContent }) {if (content.actorType === "agent") {return (- <AgentIcon- icon={content.actor?.icon ?? null}- className="h-3.5 w-3.5 shrink-0 text-muted-foreground"- />+ <AgentAvatar agent={content.actor} size={16}+ className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/>);}if (content.actorType === "user") {diff --git a/ui/src/components/IssueChatThread.tsx b/ui/src/components/IssueChatThread.tsxindex c4cf424354..f5fb590527 100644--- a/ui/src/components/IssueChatThread.tsx+++ b/ui/src/components/IssueChatThread.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { TaskChatPausedTakeover, type TaskComposerPause } from "./task-chat/TaskChatPausedTakeover";import { useEmailComment } from "./EmailMessageCard";import { AssistantRuntimeProvider } from "@assistant-ui/react";@@ -148,7 +149,6 @@ import {type InlineEntityOption,} from "./InlineEntitySelector";import { IssueThreadInteractionCard } from "./IssueThreadInteractionCard";-import { AgentIcon } from "./AgentIconPicker";import {AssigneeChip,ComposerHandoffPreviewRow,@@ -1289,8 +1289,8 @@ function IssueChatChainOfThought({<div className="min-w-0 flex-1"><div className="flex min-w-0 items-center gap-2.5"><span className="inline-flex items-center gap-2 text-sm font-medium text-foreground/80">- {agentIcon ? (- <AgentIcon icon={agentIcon} className="h-4 w-4 shrink-0" />+ {agentId ? (+ <AgentAvatar agent={agentId ? agentMap?.get(agentId) ?? { id: agentId } : undefined} size={16} />) : isActive ? (<Loader2 className="h-4 w-4 shrink-0 animate-spin text-muted-foreground" />) : (@@ -2426,17 +2426,7 @@ function IssueChatAssistantMessage({!isRunning &&(hasCommentText || deleted);- const agentAvatar = (- <Avatar size="sm" className="shrink-0">- {agentIcon ? (- <AvatarFallback>- <AgentIcon icon={agentIcon} className="h-3.5 w-3.5" />- </AvatarFallback>- ) : (- <AvatarFallback>{initialsForName(authorName)}</AvatarFallback>- )}- </Avatar>- );+ const agentAvatar = <AgentAvatar agent={agentId ? agentMap?.get(agentId) ?? { id: agentId, name: authorName } : { name: authorName }} size={32} />;const messageActionBar = (<div className="mt-2 flex items-center gap-1">@@ -2562,8 +2552,8 @@ function IssueChatAssistantMessage({{/* Icon + name together in a header ABOVE the bubble (PAP-95 rev 7). */}<div className="mb-1 flex items-center gap-1.5 px-1"><span className="flex size-5 shrink-0 items-center justify-center text-muted-foreground">- {agentIcon ? (- <AgentIcon icon={agentIcon} className="h-4 w-4" />+ {agentId ? (+ <AgentAvatar agent={agentId ? agentMap?.get(agentId) ?? { id: agentId } : undefined} size={16} />) : (<Avatar size="sm" className="size-5"><AvatarFallback className="text-(length:--text-nano)">@@ -2715,11 +2705,8 @@ function IssueChatAssistantMessage({<div className="rounded-lg px-1 py-2"><div className="flex min-w-0 items-center gap-2.5"><span className="inline-flex items-center gap-2 text-sm font-medium text-foreground/80">- {agentIcon ? (- <AgentIcon- icon={agentIcon}- className="h-4 w-4 shrink-0"- />+ {agentId ? (+ <AgentAvatar agent={agentId ? agentMap?.get(agentId) ?? { id: agentId } : undefined} size={16} />) : (<Loader2 className="h-4 w-4 shrink-0 animate-spin text-muted-foreground" />)}@@ -3089,15 +3076,11 @@ function ExpiredRequestConfirmationActivity({</div>) : (<div className="flex items-start gap-2.5 py-1">- <Avatar size="sm" className="mt-0.5">- {actorIcon ? (- <AvatarFallback>- <AgentIcon icon={actorIcon} className="h-3.5 w-3.5" />- </AvatarFallback>- ) : (- <AvatarFallback>{initialsForName(actorName)}</AvatarFallback>- )}- </Avatar>+ {actorAgentId ? (+ <AgentAvatar agent={agentMap?.get(actorAgentId) ?? { id: actorAgentId, name: actorName }} size={32} />+ ) : (+ <Avatar size="sm" className="mt-0.5"><AvatarFallback>{initialsForName(actorName)}</AvatarFallback></Avatar>+ )}{rowContent}</div>)}@@ -3814,15 +3797,11 @@ function IssueChatSystemMessage({ message }: { message: ThreadMessage }) {if (custom.kind === "event" && actorName) {const isAgent = actorType === "agent";- const agentIcon =- isAgent && actorId ? agentMap?.get(actorId)?.icon : undefined;- const isCurrentUser =- actorType === "user" && !!currentUserId && actorId === currentUserId;- const rowIcon = agentIcon ? (- <AgentIcon icon={agentIcon} className="h-3 w-3" />- ) : (- <ClipboardList className="h-3 w-3" />- );+ const agentIcon = isAgent && actorId ? agentMap?.get(actorId)?.icon : undefined;+ const isCurrentUser = actorType === "user" && !!currentUserId && actorId === currentUserId;+ const rowIcon = isAgent+ ? <AgentAvatar agent={actorId ? agentMap?.get(actorId) ?? { id: actorId } : undefined} size={16} />+ : <ClipboardList className="h-3 w-3" />;const handoffResolvers: HandoffChipResolvers = {agentMap,currentUserId,@@ -3917,18 +3896,8 @@ function IssueChatSystemMessage({ message }: { message: ThreadMessage }) {? (agentMap?.get(runAgentId)?.name ?? runAgentId.slice(0, 8)): null);const runAgentIcon = runAgentId ? agentMap?.get(runAgentId)?.icon : undefined;- if (- custom.kind === "run" &&- runId &&- runAgentId &&- displayedRunAgentName &&- runStatus- ) {- const rowIcon = runAgentIcon ? (- <AgentIcon icon={runAgentIcon} className="h-3 w-3" />- ) : (- <span className="h-1.5 w-1.5 rounded-full bg-muted-foreground/50" />- );+ if (custom.kind === "run" && runId && runAgentId && displayedRunAgentName && runStatus) {+ const rowIcon = <AgentAvatar agent={agentMap?.get(runAgentId) ?? { id: runAgentId }} size={16} />;return (<IssueChatMetadataRow anchorId={anchorId} icon={rowIcon}>@@ -5662,10 +5631,7 @@ const IssueChatComposer = forwardRef<return (<>{agent ? (- <AgentIcon- icon={agent.icon}- className="h-3.5 w-3.5 shrink-0 text-muted-foreground"- />+ <AgentAvatar agent={agent} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/>) : null}<span className="truncate">{option.label}</span></>@@ -5681,10 +5647,7 @@ const IssueChatComposer = forwardRef<return (<>{agent ? (- <AgentIcon- icon={agent.icon}- className="h-3.5 w-3.5 shrink-0 text-muted-foreground"- />+ <AgentAvatar agent={agent} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/>) : null}<span className="truncate">{option.label}</span></>diff --git a/ui/src/components/IssueColumns.test.tsx b/ui/src/components/IssueColumns.test.tsxindex d63f1ad8a9..b969481cbd 100644--- a/ui/src/components/IssueColumns.test.tsx+++ b/ui/src/components/IssueColumns.test.tsx@@ -134,7 +134,7 @@ describe("InboxIssueMetaLeading live state", () => {});describe("InboxIssueTrailingColumns attribution", () => {- it("renders a kicked off by column for agent creators with square identity", () => {+ it("renders a kicked off by column for agent creators with a character identity", () => {const text = renderLeading(<InboxIssueTrailingColumnsissue={makeIssue({@@ -155,7 +155,7 @@ describe("InboxIssueTrailingColumns attribution", () => {);expect(text).toContain("CodexCoder");- expect(container?.querySelector('[data-shape="square"]')).not.toBeNull();+ expect(container?.querySelector('[data-slot="agent-avatar"]')).not.toBeNull();});it("renders a kicked off by column for user creators", () => {@@ -208,7 +208,7 @@ describe("InboxIssueTrailingColumns attribution", () => {// The responsible user wins over the creating agent.expect(text).toContain("Morgan Product");expect(container?.querySelector('[data-shape="circle"]')).not.toBeNull();- expect(container?.querySelector('[data-shape="square"]')).toBeNull();+ expect(container?.querySelector('[data-slot="agent-avatar"]')).toBeNull();});it("surfaces the responsible user for a routine execution with no creator", () => {diff --git a/ui/src/components/IssueColumns.tsx b/ui/src/components/IssueColumns.tsxindex 11d4b8fcf8..324a9d9597 100644--- a/ui/src/components/IssueColumns.tsx+++ b/ui/src/components/IssueColumns.tsx@@ -1,3 +1,5 @@+import { AgentIdentity } from "@/components/AgentIdentity";+import type { AvatarAgent } from "./AgentAvatar";import type { ReactNode } from "react";import { deriveOriginatingActor, type Issue } from "@paperclipai/shared";import { Columns3 } from "lucide-react";@@ -271,6 +273,8 @@ export function InboxIssueTrailingColumns({workspaceId,workspaceName,assigneeName,+ assigneeAgent,+ creatorAgent,assigneeUserName,assigneeUserAvatarUrl,creatorAgentName,@@ -290,6 +294,8 @@ export function InboxIssueTrailingColumns({workspaceId?: string | null;workspaceName: string | null;assigneeName: string | null;+ assigneeAgent?: AvatarAgent;+ creatorAgent?: AvatarAgent;assigneeUserName?: string | null;assigneeUserAvatarUrl?: string | null;creatorAgentName?: string | null;@@ -322,10 +328,9 @@ export function InboxIssueTrailingColumns({if (issue.assigneeAgentId) {return (<span key={column} className="min-w-0 text-xs text-foreground">- <Identity- name={assigneeName ?? issue.assigneeAgentId.slice(0, 8)}+ <AgentIdentity+ agent={assigneeAgent ?? { id: issue.assigneeAgentId, name: assigneeName ?? issue.assigneeAgentId.slice(0, 8) }}size="sm"- shape="square"className="min-w-0"/></span>@@ -359,10 +364,9 @@ export function InboxIssueTrailingColumns({<Tooltip key={column}><TooltipTrigger asChild><span className="min-w-0 text-xs text-foreground">- <Identity- name={name}+ <AgentIdentity+ agent={creatorAgent ?? { id: originatingActor.id, name }}size="sm"- shape="square"className="min-w-0"/></span>diff --git a/ui/src/components/IssueDocumentAnnotations.test.tsx b/ui/src/components/IssueDocumentAnnotations.test.tsxindex 7f573ab4e3..5636fe20c6 100644--- a/ui/src/components/IssueDocumentAnnotations.test.tsx+++ b/ui/src/components/IssueDocumentAnnotations.test.tsx@@ -648,7 +648,7 @@ describe("IssueDocumentAnnotations", () => {expect(expandedText).toContain("UXDesigner");expect(expandedText).toContain("· agent");// Each rendered comment shows an author avatar.- const avatars = expandedThread?.querySelectorAll('[data-slot="avatar"]') ?? [];+ const avatars = expandedThread?.querySelectorAll('[data-slot="avatar"], [data-slot="agent-avatar"]') ?? [];expect(avatars.length).toBe(2);});diff --git a/ui/src/components/IssueDocumentsSection.test.tsx b/ui/src/components/IssueDocumentsSection.test.tsxindex a2a008f014..e29fd54ff9 100644--- a/ui/src/components/IssueDocumentsSection.test.tsx+++ b/ui/src/components/IssueDocumentsSection.test.tsx@@ -589,7 +589,7 @@ describe("IssueDocumentsSection", () => {expect(document.body.textContent).toContain("CodexCoder");expect(document.body.textContent).toContain("Dotta");expect(document.body.textContent).not.toContain("• agent");- expect(document.body.querySelectorAll('[data-slot="avatar"]').length).toBeGreaterThanOrEqual(2);+ expect(document.body.querySelectorAll('[data-slot="avatar"], [data-slot="agent-avatar"]').length).toBeGreaterThanOrEqual(2);await act(async () => {root.unmount();diff --git a/ui/src/components/IssueDocumentsSection.tsx b/ui/src/components/IssueDocumentsSection.tsxindex eeadaf49b3..e4e0813a2c 100644--- a/ui/src/components/IssueDocumentsSection.tsx+++ b/ui/src/components/IssueDocumentsSection.tsx@@ -149,7 +149,7 @@ function downloadDocumentFile(key: string, body: string) {function getRevisionActor(revision: DocumentRevision,maps: {- agentMap?: ReadonlyMap<string, Pick<Agent, "id" | "name"> & Partial<Pick<Agent, "icon">>>;+ agentMap?: ReadonlyMap<string, Pick<Agent, "id" | "name"> & Partial<Pick<Agent, "icon" | "appearance">>>;userProfileMap?: ReadonlyMap<string, CompanyUserProfile>;},): DocumentFrameHeaderRevisionActor {@@ -159,6 +159,7 @@ function getRevisionActor(kind: "agent",name: agent?.name ?? revision.createdByAgentId.slice(0, 8),agentIcon: agent?.icon ?? null,+ agent: agent ?? { id: revision.createdByAgentId },};}if (revision.createdByUserId) {@@ -275,7 +276,7 @@ export function IssueDocumentsSection({options?: { allowSharing?: boolean; reason?: string },) => Promise<void>;extraActions?: ReactNode;- agentMap?: ReadonlyMap<string, Pick<Agent, "id" | "name"> & Partial<Pick<Agent, "icon">>>;+ agentMap?: ReadonlyMap<string, Pick<Agent, "id" | "name"> & Partial<Pick<Agent, "icon" | "appearance">>>;userProfileMap?: ReadonlyMap<string, CompanyUserProfile>;/*** Seed which document annotation panels are open on first render. Mostly usefuldiff --git a/ui/src/components/IssueProperties.test.tsx b/ui/src/components/IssueProperties.test.tsxindex 8f72726293..6b3492230e 100644--- a/ui/src/components/IssueProperties.test.tsx+++ b/ui/src/components/IssueProperties.test.tsx@@ -888,7 +888,7 @@ describe("IssueProperties", () => {expect(container.textContent).not.toContain("Responsible");expect(container.textContent).not.toContain("Kicked off by");expect(container.textContent).not.toContain("Created by");- expect(container.querySelector('[data-shape="square"]')?.textContent).toContain("CodexCoder");+ expect(container.querySelector('[title="CodexCoder"] [data-slot="agent-avatar"] img')?.getAttribute("src")).toContain("/api/agent-avatars/cap-v1/");});act(() => root.unmount());@@ -939,7 +939,7 @@ describe("IssueProperties", () => {expect(container.textContent).toContain("Unassigned");expect(container.textContent).not.toContain("Responsible");expect(container.textContent).not.toContain("Kicked off by");- expect(container.querySelector('[data-shape="square"]')?.textContent).toContain("CodexCoder");+ expect(container.querySelector('[title="CodexCoder"] [data-slot="agent-avatar"] img')?.getAttribute("src")).toContain("/api/agent-avatars/cap-v1/");});act(() => root.unmount());diff --git a/ui/src/components/IssuesList.tsx b/ui/src/components/IssuesList.tsxindex 5f1569d316..2a947c66db 100644--- a/ui/src/components/IssuesList.tsx+++ b/ui/src/components/IssuesList.tsx@@ -1,3 +1,4 @@+import { AgentIdentity } from "@/components/AgentIdentity";import { startTransition, useDeferredValue, useEffect, useMemo, useState, useCallback, useRef } from "react";import type { ReactNode } from "react";import { useQueries, useQuery, useQueryClient } from "@tanstack/react-query";@@ -2310,6 +2311,8 @@ function StreamlinedIssuesList({})}onFilterWorkspace={filterToWorkspace}assigneeName={agentName(issue.assigneeAgentId)}+ assigneeAgent={agents?.find((agent) => agent.id === issue.assigneeAgentId)}+ creatorAgent={agents?.find((agent) => agent.id === issue.createdByAgentId)}assigneeUserName={assigneeUserLabel}assigneeUserAvatarUrl={assigneeUserProfile?.image ?? null}creatorAgentName={agentName(issue.createdByAgentId)}@@ -2333,7 +2336,7 @@ function StreamlinedIssuesList({onClick={(e) => { e.preventDefault(); e.stopPropagation(); }}>{issue.assigneeAgentId && agentName(issue.assigneeAgentId) ? (- <Identity name={agentName(issue.assigneeAgentId)!} size="sm" shape="square" className="min-w-0" />+ <AgentIdentity agent={agents!.find((agent) => agent.id === issue.assigneeAgentId)!} size="sm" className="min-w-0" />) : issue.assigneeUserId ? (<Identityname={assigneeUserLabel ?? "User"}@@ -2412,7 +2415,7 @@ function StreamlinedIssuesList({assignIssue(issue.id, agent.id, null);}}>- <Identity name={agent.name} size="sm" className="min-w-0" />+ <AgentIdentity agent={agent} size="sm" className="min-w-0" /></button>))}</div>diff --git a/ui/src/components/KanbanBoard.tsx b/ui/src/components/KanbanBoard.tsxindex f251729e34..9b1c19f40e 100644--- a/ui/src/components/KanbanBoard.tsx+++ b/ui/src/components/KanbanBoard.tsx@@ -1,3 +1,4 @@+import { AgentIdentity } from "@/components/AgentIdentity";import { useMemo, useState } from "react";import { Link } from "@/lib/router";import {@@ -367,7 +368,7 @@ function KanbanCard({{issue.assigneeAgentId && (() => {const name = agentName(issue.assigneeAgentId);return name ? (- <Identity name={name} size="xs" />+ <AgentIdentity agent={agents?.find((agent) => agent.id === issue.assigneeAgentId) ?? { id: issue.assigneeAgentId, name }} size="xs" />) : (<span className="text-xs text-muted-foreground font-mono">{issue.assigneeAgentId.slice(0, 8)}diff --git a/ui/src/components/LegacyIssuesList.tsx b/ui/src/components/LegacyIssuesList.tsxindex 2e4e606701..964ae78482 100644--- a/ui/src/components/LegacyIssuesList.tsx+++ b/ui/src/components/LegacyIssuesList.tsx@@ -1,3 +1,4 @@+import { AgentIdentity } from "@/components/AgentIdentity";import { startTransition, useDeferredValue, useEffect, useMemo, useState, useCallback, useRef } from "react";import type { ReactNode } from "react";import { useQueries, useQuery, useQueryClient } from "@tanstack/react-query";@@ -2203,6 +2204,8 @@ export function IssuesList({})}onFilterWorkspace={filterToWorkspace}assigneeName={agentName(issue.assigneeAgentId)}+ assigneeAgent={agents?.find((agent) => agent.id === issue.assigneeAgentId)}+ creatorAgent={agents?.find((agent) => agent.id === issue.createdByAgentId)}assigneeUserName={assigneeUserLabel}assigneeUserAvatarUrl={assigneeUserProfile?.image ?? null}creatorAgentName={agentName(issue.createdByAgentId)}@@ -2226,7 +2229,7 @@ export function IssuesList({onClick={(e) => { e.preventDefault(); e.stopPropagation(); }}>{issue.assigneeAgentId && agentName(issue.assigneeAgentId) ? (- <Identity name={agentName(issue.assigneeAgentId)!} size="sm" shape="square" className="min-w-0" />+ <AgentIdentity agent={agents!.find((agent) => agent.id === issue.assigneeAgentId)!} size="sm" className="min-w-0" />) : issue.assigneeUserId ? (<Identityname={assigneeUserLabel ?? "User"}@@ -2305,7 +2308,7 @@ export function IssuesList({assignIssue(issue.id, agent.id, null);}}>- <Identity name={agent.name} size="sm" className="min-w-0" />+ <AgentIdentity agent={agent} size="sm" className="min-w-0" /></button>))}</div>diff --git a/ui/src/components/LiveRunWidget.tsx b/ui/src/components/LiveRunWidget.tsxindex 51bfcef469..62852ff3b6 100644--- a/ui/src/components/LiveRunWidget.tsx+++ b/ui/src/components/LiveRunWidget.tsx@@ -1,3 +1,4 @@+import { AgentIdentity } from "@/components/AgentIdentity";import { useMemo, useState } from "react";import { Link } from "@/lib/router";import { useQuery, useQueryClient } from "@tanstack/react-query";@@ -113,7 +114,7 @@ export function LiveRunWidget({ issueId, companyId }: LiveRunWidgetProps) {<div className="mb-3 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between"><div className="min-w-0"><Link to={`/agents/${run.agentId}`} className="inline-flex hover:underline">- <Identity name={run.agentName} size="sm" />+ <AgentIdentity agent={{ id: run.agentId, name: run.agentName, appearance: run.agentAppearance }} size="sm" /></Link><div className="mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground"><Linkdiff --git a/ui/src/components/ManagedRoutinesList.test.tsx b/ui/src/components/ManagedRoutinesList.test.tsxnew file mode 100644index 0000000000..8b54d204ea--- /dev/null+++ b/ui/src/components/ManagedRoutinesList.test.tsx@@ -0,0 +1,24 @@+// @vitest-environment jsdom+import type { ReactNode } from "react";+import { renderToStaticMarkup } from "react-dom/server";+import { describe, expect, it, vi } from "vitest";+import { appearanceForPalette, agentAvatarUrl, resolveAgentAppearance } from "@paperclipai/shared";+import { ManagedRoutinesList } from "./ManagedRoutinesList";++vi.mock("@/lib/router", () => ({ Link: ({ to, children, ...props }: { to: string; children: ReactNode }) => <a href={to} {...props}>{children}</a> }));+const routines = [{ key: "routine", title: "Daily summary", status: "active", assigneeAgentId: "agent-one" }];+function avatarSrc(markup: string) {+ const document = new DOMParser().parseFromString(markup, "text/html");+ return document.querySelector('[data-slot="agent-avatar"] img')?.getAttribute("src");+}+describe("routine agent identities", () => {+ it("keeps a saved palette for agents without legacy icons", () => {+ const appearance = appearanceForPalette("bubblegum-sky");+ const markup = renderToStaticMarkup(<ManagedRoutinesList routines={routines} agents={[{ id: "agent-one", name: "One", appearance, icon: null }]} />);+ expect(avatarSrc(markup)).toBe(agentAvatarUrl(appearance, 16));+ });+ it("uses the assignee ID for a stable fallback before the agent summary loads", () => {+ const markup = renderToStaticMarkup(<ManagedRoutinesList routines={routines} />);+ expect(avatarSrc(markup)).toBe(agentAvatarUrl(resolveAgentAppearance(null, "agent-one"), 16));+ });+});diff --git a/ui/src/components/ManagedRoutinesList.tsx b/ui/src/components/ManagedRoutinesList.tsxindex 0ac65812f8..5b85b6910d 100644--- a/ui/src/components/ManagedRoutinesList.tsx+++ b/ui/src/components/ManagedRoutinesList.tsx@@ -6,11 +6,7 @@ import {type RoutineListRowItem,} from "@/components/RoutineList";-export type ManagedRoutinesListAgent = {- id: string;- name: string;- icon?: string | null;-};+export type ManagedRoutinesListAgent = RoutineListAgentSummary & { id: string };export type ManagedRoutinesListProject = {id: string;@@ -94,7 +90,7 @@ export function ManagedRoutinesList({onReset,}: ManagedRoutinesListProps) {const agentById = new Map<string, RoutineListAgentSummary>(- agents.map((agent) => [agent.id, { name: agent.name, icon: agent.icon }]),+ agents.map((agent) => [agent.id, agent]),);const projectById = new Map<string, RoutineListProjectSummary>(projects.map((project) => [project.id, { name: project.name, color: project.color }]),diff --git a/ui/src/components/MarkdownEditor.tsx b/ui/src/components/MarkdownEditor.tsxindex d16c411ae0..1b1190939e 100644--- a/ui/src/components/MarkdownEditor.tsx+++ b/ui/src/components/MarkdownEditor.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "./AgentAvatar";import {Component,type ClipboardEvent,@@ -45,7 +46,6 @@ import {buildUserMentionHref,} from "@paperclipai/shared";import { Boxes, CalendarClock, Flag, Hash, User, X } from "lucide-react";-import { AgentIcon } from "./AgentIconPicker";import { applyMentionChipDecoration, clearMentionChipDecoration, parseMentionChipHref } from "../lib/mention-chips";import { MentionAwareLinkNode, mentionAwareLinkNodeReplacement } from "../lib/mention-aware-link-node";import { mentionDeletionPlugin } from "../lib/mention-deletion";@@ -68,6 +68,7 @@ export interface MentionOption {kind?: "agent" | "project" | "user" | "issue";agentId?: string;agentIcon?: string | null;+ agentAppearance?: import("@paperclipai/shared").AgentAppearance | null;projectId?: string;projectColor?: string | null;userId?: string;@@ -1596,10 +1597,7 @@ export const MarkdownEditor = forwardRef<MarkdownEditorRef, MarkdownEditorProps>) : option.kind === "user" ? (<User className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />) : (- <AgentIcon- icon={option.agentIcon}- className="h-3.5 w-3.5 shrink-0 text-muted-foreground"- />+ <AgentAvatar agent={{ id: option.agentId ?? option.id, name: option.name, appearance: option.agentAppearance }} size={16} />)}{option.kind === "issue" && option.issueIdentifier ? (<span className="flex min-w-0 items-baseline gap-1.5">diff --git a/ui/src/components/NewIssueDialog.tsx b/ui/src/components/NewIssueDialog.tsxindex a4e76cce05..bdd038a73a 100644--- a/ui/src/components/NewIssueDialog.tsx+++ b/ui/src/components/NewIssueDialog.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { normalizeLegacyRunnerProvider } from "@paperclipai/adapter-utils";import { memo, useState, useEffect, useRef, useCallback, useMemo, type ChangeEvent, type CSSProperties, type DragEvent, type RefObject } from "react";import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";@@ -77,7 +78,6 @@ import { extractProviderIdWithFallback } from "../lib/model-utils";import { issueStatusText, issueStatusTextDefault, priorityColor, priorityColorDefault } from "../lib/status-colors";import { SHOW_TASK_PRIORITY_UI } from "../lib/ui-flags";import { MarkdownEditor, type MarkdownEditorRef, type MentionOption } from "./MarkdownEditor";-import { AgentIcon } from "./AgentIconPicker";import { InlineBanner } from "./InlineBanner";import { InlineEntitySelector, type InlineEntityOption } from "./InlineEntitySelector";import { getTrustPreset } from "../lib/trust-policy-ui";@@ -1507,7 +1507,7 @@ export function NewIssueDialog() {option ? (currentAssignee ? (<>- <AgentIcon icon={currentAssignee.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ <AgentAvatar agent={currentAssignee} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/><span className="truncate">{option.label}</span></>) : (@@ -1524,7 +1524,7 @@ export function NewIssueDialog() {: null;return (<>- {assignee ? <AgentIcon icon={assignee.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" /> : null}+ {assignee ? <AgentAvatar agent={assignee} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/> : null}<span className="truncate">{option.label}</span>{assignee && getTrustPreset(assignee.permissions) === "low_trust_review" ? (<ShieldAlert className="ml-auto h-3.5 w-3.5 shrink-0 text-amber-600 dark:text-amber-300" aria-label="Low-trust review agent" />@@ -1665,7 +1665,7 @@ export function NewIssueDialog() {const reviewer = parseAssigneeValue(option.id).assigneeAgentId? (agents ?? []).find((a) => a.id === parseAssigneeValue(option.id).assigneeAgentId): null;- return reviewer ? <AgentIcon icon={reviewer.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" /> : null;+ return reviewer ? <AgentAvatar agent={reviewer} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/> : null;})()}<span className="truncate">{option.label}</span></>@@ -1680,7 +1680,7 @@ export function NewIssueDialog() {: null;return (<>- {reviewer ? <AgentIcon icon={reviewer.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" /> : null}+ {reviewer ? <AgentAvatar agent={reviewer} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/> : null}<span className="truncate">{option.label}</span></>);@@ -1710,7 +1710,7 @@ export function NewIssueDialog() {const approver = parseAssigneeValue(option.id).assigneeAgentId? (agents ?? []).find((a) => a.id === parseAssigneeValue(option.id).assigneeAgentId): null;- return approver ? <AgentIcon icon={approver.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" /> : null;+ return approver ? <AgentAvatar agent={approver} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/> : null;})()}<span className="truncate">{option.label}</span></>@@ -1725,7 +1725,7 @@ export function NewIssueDialog() {: null;return (<>- {approver ? <AgentIcon icon={approver.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" /> : null}+ {approver ? <AgentAvatar agent={approver} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/> : null}<span className="truncate">{option.label}</span></>);@@ -1747,7 +1747,7 @@ export function NewIssueDialog() {>{selectedWatchdogAgent ? (<>- <AgentIcon icon={selectedWatchdogAgent.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ <AgentAvatar agent={selectedWatchdogAgent} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/><span className="truncate text-foreground">{selectedWatchdogAgent.name}</span>{watchdogInstructions.trim() ? (<span className="truncate text-muted-foreground">· {watchdogInstructions.trim()}</span>@@ -1773,7 +1773,7 @@ export function NewIssueDialog() {option ? (<>{selectedWatchdogAgent ? (- <AgentIcon icon={selectedWatchdogAgent.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ <AgentAvatar agent={selectedWatchdogAgent} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/>) : null}<span className="truncate">{option.label}</span></>@@ -1785,7 +1785,7 @@ export function NewIssueDialog() {const agent = (agents ?? []).find((a) => a.id === option.id);return (<>- {agent ? <AgentIcon icon={agent.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" /> : null}+ {agent ? <AgentAvatar agent={agent} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/> : null}<span className="truncate">{option.label}</span></>);diff --git a/ui/src/components/OnboardingWizard.tsx b/ui/src/components/OnboardingWizard.tsxindex ee2005bda9..43915d134c 100644--- a/ui/src/components/OnboardingWizard.tsx+++ b/ui/src/components/OnboardingWizard.tsx@@ -6,6 +6,8 @@ import { aiProviderForAdapter } from "./ai-connections/AiConnectionField";import type { AiConnectionBinding } from "@paperclipai/shared";import { storeProviderApiKey } from "../lib/provider-credential";import { SavedProviderKeySelect, useSavedProviderKeys } from "./onboarding/SavedProviderKeySelect";+import { randomAgentAppearance, resolveAgentAppearance, agentAppearanceSchema } from "@paperclipai/shared";+import { AgentCharacter } from "./AgentCharacter";import { useEffect, useState, useMemo, useRef } from "react";import type { ComponentType, CSSProperties } from "react";import { useQuery, useQueryClient } from "@tanstack/react-query";@@ -556,6 +558,7 @@ function OnboardingWizardInner({// on the customer's behalf that they then have to notice and undo. It is the// step's only question, and its CTA gates on it.const [agentName, setAgentName] = useState((saved?.agentName as string) ?? "");+ const [agentAppearance, setAgentAppearance] = useState(() => agentAppearanceSchema.safeParse(saved?.agentAppearance).data ?? randomAgentAppearance());// Defaults to `general` rather than empty. The arc stopped asking for a role// — a customer naming their first agent is describing what it does, not// filing it — but the hire still needs one, and the guard below returns@@ -776,6 +779,7 @@ function OnboardingWizardInner({* hand rather than the one before it.*/function clearCompanyScopedState() {+ setAgentAppearance(randomAgentAppearance());setCreatedCompanyPrefix(null);setCompanyName("");setCreatedCompanyGoalId(null);@@ -879,7 +883,7 @@ function OnboardingWizardInner({if (!effectiveOnboardingOpen) return;const state = {step, companyName,- agentName, agentRole, adapterType, cwd, model, command, args, url,+ agentName, agentAppearance, agentRole, adapterType, cwd, model, command, args, url,// The mode, never the key: this blob is localStorage.credentialMode, credentialModeChoice,createdCompanyId, createdCompanyPrefix, createdAgentId,@@ -888,7 +892,7 @@ function OnboardingWizardInner({onboardingDraftStorage.write(JSON.stringify(state));}, [effectiveOnboardingOpen, step, companyName,- agentName, agentRole, adapterType, cwd, model, command, args, url,+ agentName, agentAppearance, agentRole, adapterType, cwd, model, command, args, url,credentialMode, credentialModeChoice,createdCompanyId, createdCompanyPrefix, createdAgentId,createdCompanyGoalId, createdProjectId, createdIssueRef,@@ -1600,6 +1604,7 @@ function OnboardingWizardInner({// Back to the mount defaults: an empty name (the step's only question, and// what its CTA gates on) and the neutral role every onboarding hire uses.setAgentName("");+ setAgentAppearance(randomAgentAppearance());setAgentRole(DEFAULT_AGENT_ROLE);setAdapterType("claude_local");setModel("");@@ -2157,6 +2162,7 @@ function OnboardingWizardInner({if (existing) {if (!isCurrent()) return;setCreatedAgentId(existing.id);+ setAgentAppearance(resolveAgentAppearance(existing.appearance, existing.id));queryClient.invalidateQueries({queryKey: queryKeys.agents.list(createdCompanyId)});@@ -2171,6 +2177,7 @@ function OnboardingWizardInner({// The name is optional; an agent that reaches here without one is// named for the job it was hired to do rather than left blank.name: hireName,+ appearance: agentAppearance,role: agentRole,adapterType,adapterConfig: hireAdapterConfig,@@ -2454,7 +2461,7 @@ function OnboardingWizardInner({/>)}- {/* The hero, above the heading: one PillGuy held in the same tree+ {/* The hero, above the heading: one character held in the same treeslot across steps 3–5, so React reuses the DOM node and movingbetween steps never replays the entrance. It is dormant whilethe agent is being specified and wakes on Review. */}@@ -2487,14 +2494,7 @@ function OnboardingWizardInner({to this box and travel out past its top-rightcorner. */}<div className="relative size-(--sz-72px)">- <PillGuy- state={step === 5 ? "alive" : "dormant"}- className="size-full"- />- {/* Only while it is actually asleep. A still grey- silhouette reads as a placeholder that failed to- load rather than as something waiting its turn. */}- {step < 5 && <SleepingZs />}+ <AgentCharacter appearance={agentAppearance} size={128} state={step === 5 ? "success" : adapterEnvLoading || loading || ["loading", "waiting", "connecting"].includes(connectPhase) ? "loading" : "sleepy"} muted={step < 5} className="size-full" /></div><AgentPreview agentName={agentName} agentRole="" /></motion.div>diff --git a/ui/src/components/PipelineItemBodyDocument.tsx b/ui/src/components/PipelineItemBodyDocument.tsxindex 7b784e6417..8347315078 100644--- a/ui/src/components/PipelineItemBodyDocument.tsx+++ b/ui/src/components/PipelineItemBodyDocument.tsx@@ -38,7 +38,7 @@ type CaseBodyDocument = PipelineCaseDocumentPayload["document"] & {function getPipelineRevisionActor(revision: { createdByAgentId?: string | null; createdByUserId?: string | null },maps: {- agentMap?: ReadonlyMap<string, Pick<Agent, "id" | "name"> & Partial<Pick<Agent, "icon">>>;+ agentMap?: ReadonlyMap<string, Pick<Agent, "id" | "name"> & Partial<Pick<Agent, "icon" | "appearance">>>;userProfileMap?: ReadonlyMap<string, CompanyUserProfile>;},): DocumentFrameHeaderRevisionActor {@@ -48,6 +48,7 @@ function getPipelineRevisionActor(kind: "agent",name: agent?.name ?? revision.createdByAgentId.slice(0, 8),agentIcon: agent?.icon ?? null,+ agent: agent ?? { id: revision.createdByAgentId },};}@@ -76,7 +77,7 @@ export interface PipelineItemBodyDocumentProps {/** Active conversation issue the body document is/should be anchored to. */conversationIssueId: string | null;conversationIssue: Issue | null;- agentMap?: ReadonlyMap<string, Pick<Agent, "id" | "name"> & Partial<Pick<Agent, "icon">>>;+ agentMap?: ReadonlyMap<string, Pick<Agent, "id" | "name"> & Partial<Pick<Agent, "icon" | "appearance">>>;userProfileMap?: ReadonlyMap<string, CompanyUserProfile>;mentions?: MentionOption[];imageUploadHandler?: (file: File) => Promise<string>;diff --git a/ui/src/components/ReportsToPicker.tsx b/ui/src/components/ReportsToPicker.tsxindex d3a4bf0d0b..706375c6bd 100644--- a/ui/src/components/ReportsToPicker.tsx+++ b/ui/src/components/ReportsToPicker.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { useState } from "react";import type { Agent } from "@paperclipai/shared";import {@@ -8,7 +9,6 @@ import {import { User } from "lucide-react";import { cn } from "../lib/utils";import { roleLabels } from "./agent-config-primitives";-import { AgentIcon } from "./AgentIconPicker";export function ReportsToPicker({agents,@@ -55,7 +55,7 @@ export function ReportsToPicker({</>) : current ? (<>- <AgentIcon icon={current.icon} className="h-3 w-3 shrink-0 text-muted-foreground" />+ <AgentAvatar agent={current} size={16} className="h-3 w-3 shrink-0 text-muted-foreground"/><spanclassName={cn("min-w-0 truncate",@@ -91,7 +91,7 @@ export function ReportsToPicker({</button>{terminatedManager && (<div className="flex min-w-0 items-center gap-2 overflow-hidden px-2 py-1.5 text-xs text-muted-foreground border-b border-border mb-0.5">- <AgentIcon icon={current.icon} className="shrink-0 h-3 w-3" />+ <AgentAvatar agent={current} size={16} className="shrink-0 h-3 w-3"/><span className="min-w-0 truncate">Current: {current.name} (terminated)</span>@@ -115,7 +115,7 @@ export function ReportsToPicker({setOpen(false);}}>- <AgentIcon icon={a.icon} className="shrink-0 h-3 w-3 text-muted-foreground" />+ <AgentAvatar agent={a} size={16} className="shrink-0 h-3 w-3 text-muted-foreground"/><span className="min-w-0 truncate">{a.name}</span><span className="text-muted-foreground ml-auto shrink-0">{roleLabels[a.role] ?? a.role}</span></button>diff --git a/ui/src/components/RoutineList.tsx b/ui/src/components/RoutineList.tsxindex 29604651c1..332422307f 100644--- a/ui/src/components/RoutineList.tsx+++ b/ui/src/components/RoutineList.tsx@@ -1,7 +1,8 @@+import type { AgentAppearance } from "@paperclipai/shared";+import { AgentAvatar } from "@/components/AgentAvatar";import type { ReactNode } from "react";import { MoreHorizontal, Play } from "lucide-react";import { Link } from "@/lib/router";-import { AgentIcon } from "@/components/AgentIconPicker";import { Button } from "@/components/ui/button";import {DropdownMenu,@@ -18,6 +19,8 @@ export type RoutineListProjectSummary = {};export type RoutineListAgentSummary = {+ id?: string;+ appearance?: AgentAppearance | null;name: string;icon?: string | null;};@@ -148,7 +151,7 @@ export function RoutineListRow<TRoutine extends RoutineListRowItem>({<span>{routine.projectId ? (project?.name ?? "Unknown project") : "No project"}</span></span><span className="flex items-center gap-2">- {agent?.icon ? <AgentIcon icon={agent.icon} className="h-3.5 w-3.5 shrink-0" /> : null}+ {routine.assigneeAgentId ? <AgentAvatar agent={{ ...agent, id: routine.assigneeAgentId }} size={16} className="h-3.5 w-3.5 shrink-0"/> : null}<span>{routine.assigneeAgentId ? (agent?.name ?? "Unknown agent") : "No default agent"}</span></span><span>diff --git a/ui/src/components/RoutineRunVariablesDialog.tsx b/ui/src/components/RoutineRunVariablesDialog.tsxindex ed5c2b1fe9..65052867c6 100644--- a/ui/src/components/RoutineRunVariablesDialog.tsx+++ b/ui/src/components/RoutineRunVariablesDialog.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { useCallback, useEffect, useMemo, useState } from "react";import {WORKSPACE_BRANCH_ROUTINE_VARIABLE,@@ -12,7 +13,6 @@ import { useQuery } from "@tanstack/react-query";import { instanceSettingsApi } from "../api/instanceSettings";import { queryKeys } from "../lib/queryKeys";import { IssueWorkspaceCard } from "./IssueWorkspaceCard";-import { AgentIcon } from "./AgentIconPicker";import { InlineEntitySelector, type InlineEntityOption } from "./InlineEntitySelector";import { getRecentAssigneeIds, sortAgentsByRecency, trackRecentAssignee } from "../lib/recent-assignees";import { getRecentProjectIds, trackRecentProject } from "../lib/recent-projects";@@ -374,7 +374,7 @@ export function RoutineRunVariablesDialog({option ? (currentAssignee ? (<>- <AgentIcon icon={currentAssignee.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ <AgentAvatar agent={currentAssignee} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/><span className="truncate">{option.label}</span></>) : (@@ -389,7 +389,7 @@ export function RoutineRunVariablesDialog({const assignee = agents.find((agent) => agent.id === option.id);return (<>- {assignee ? <AgentIcon icon={assignee.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" /> : null}+ {assignee ? <AgentAvatar agent={assignee} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/> : null}<span className="truncate">{option.label}</span></>);diff --git a/ui/src/components/SidebarAgents.production.tsx b/ui/src/components/SidebarAgents.production.tsxindex 028c8de32a..c2d0bcfe4d 100644--- a/ui/src/components/SidebarAgents.production.tsx+++ b/ui/src/components/SidebarAgents.production.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { Link, useLocation } from "@/lib/router";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";@@ -43,7 +44,6 @@ import {type AgentSidebarSortMode,writeAgentSortMode,} from "../lib/agent-order";-import { AgentIcon } from "./AgentIconPicker";import { BudgetSidebarMarker } from "./BudgetSidebarMarker";import { SidebarNavItem } from "./SidebarNavItem.production";import { SidebarSection, type SidebarSectionRadioChoice } from "./SidebarSection";@@ -166,7 +166,7 @@ function SidebarAgentItem({<SidebarNavItemto={href}label={agent.name}- iconNode={<AgentIcon icon={agent.icon} className="shrink-0 h-4 w-4" />}+ iconNode={<AgentAvatar agent={agent} size={16} className="shrink-0 h-4 w-4"/>}active={isActive}liveCount={runCount}labelClassName={showBuiltInLifecycle ? "min-w-(--sz-4_5rem) flex-initial" : undefined}diff --git a/ui/src/components/SidebarAgents.tsx b/ui/src/components/SidebarAgents.tsxindex 806e1fd294..0ae054f9ea 100644--- a/ui/src/components/SidebarAgents.tsx+++ b/ui/src/components/SidebarAgents.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { Link, useLocation } from "@/lib/router";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";@@ -43,7 +44,6 @@ import {type AgentSidebarSortMode,writeAgentSortMode,} from "../lib/agent-order";-import { AgentIcon } from "./AgentIconPicker";import { BudgetSidebarMarker } from "./BudgetSidebarMarker";import { SidebarNavItem } from "./SidebarNavItem";import { SidebarSection, type SidebarSectionRadioChoice } from "./SidebarSection";@@ -166,7 +166,7 @@ function SidebarAgentItem({<SidebarNavItemto={href}label={agent.name}- iconNode={<AgentIcon icon={agent.icon} className="shrink-0 h-4 w-4" />}+ iconNode={<AgentAvatar agent={agent} size={16} className="shrink-0 h-4 w-4"/>}active={isActive}liveCount={runCount}labelClassName={showBuiltInLifecycle ? "min-w-(--sz-4_5rem) flex-initial" : undefined}diff --git a/ui/src/components/StageSecretsPanel.tsx b/ui/src/components/StageSecretsPanel.tsxindex 5ba0846395..76cc8e777d 100644--- a/ui/src/components/StageSecretsPanel.tsx+++ b/ui/src/components/StageSecretsPanel.tsx@@ -3,7 +3,7 @@ import type { CompanySecret, RoutineEnvConfig } from "@paperclipai/shared";import { Button } from "@/components/ui/button";import { EmptyState } from "./EmptyState";import { EnvironmentVariablesEditor } from "./environment-variables-editor";-import { AgentIcon } from "./AgentIconPicker";+import { AgentAvatar, type AvatarAgent } from "./AgentAvatar";export interface StageSecretsPanelProps {/** Whether the stage has a backing automation routine with an assignee. */@@ -11,6 +11,7 @@ export interface StageSecretsPanelProps {/** Display name + icon of the agent that runs this step (when automation exists). */agentName?: string | null;agentIcon?: string | null;+ agent?: AvatarAgent;/** Company secret inventory (shared, not stage-scoped). */secrets: CompanySecret[];secretsLoading: boolean;@@ -35,6 +36,7 @@ export function StageSecretsPanel({hasAutomation,agentName,agentIcon,+ agent,secrets,secretsLoading,value,@@ -65,7 +67,7 @@ export function StageSecretsPanel({<div className="space-y-5"><div className="flex items-start gap-2 rounded-md border border-border bg-muted/20 px-4 py-3 text-xs text-muted-foreground">{agentName ? (- <AgentIcon icon={agentIcon} className="h-3.5 w-3.5 mt-0.5 shrink-0" />+ <AgentAvatar agent={agent} name={displayName} size={16} />) : (<KeyRound className="h-3.5 w-3.5 mt-0.5 shrink-0" />)}diff --git a/ui/src/components/TaskChatThread.tsx b/ui/src/components/TaskChatThread.tsxindex 721d7f2e32..6687365efa 100644--- a/ui/src/components/TaskChatThread.tsx+++ b/ui/src/components/TaskChatThread.tsx@@ -1656,6 +1656,7 @@ export function TaskChatThread(props: TaskChatThreadProps) {agentName:meta?.agentName ??(meta?.agentId ? agentMap?.get(meta.agentId)?.name : undefined),+ agent: meta?.agentId ? agentMap?.get(meta.agentId) ?? { id: meta.agentId } : undefined,agentIcon: meta?.agentId? agentMap?.get(meta.agentId)?.icon: undefined,@@ -1873,7 +1874,8 @@ export function TaskChatThread(props: TaskChatThreadProps) {agentName:meta?.agentName ??(meta?.agentId ? agentMap?.get(meta.agentId)?.name : undefined),- agentIcon: meta?.agentId+ agent: meta?.agentId ? agentMap?.get(meta.agentId) ?? { id: meta.agentId } : undefined,+ agentIcon: meta?.agentId? agentMap?.get(meta.agentId)?.icon: undefined,standaloneHeader: sourceIsPaperclipRunner,@@ -1963,6 +1965,7 @@ export function TaskChatThread(props: TaskChatThreadProps) {(liveRun.agentId? agentMap?.get(liveRun.agentId)?.name: undefined),+ agent: liveRun.agentId ? agentMap?.get(liveRun.agentId) ?? { id: liveRun.agentId } : undefined,agentIcon: liveRun.agentId? agentMap?.get(liveRun.agentId)?.icon: undefined,@@ -2888,6 +2891,7 @@ export function TaskChatThread(props: TaskChatThreadProps) {}agentName={visibleTailAgentName}agentIcon={visibleTailAgentIcon}+ agent={tailAgent ?? (tailAgentId ? { id: tailAgentId } : undefined)}items={tailItems}status={optimisticRunnerStartupdiff --git a/ui/src/components/interrupt-handoff/InterruptHandoffViews.tsx b/ui/src/components/interrupt-handoff/InterruptHandoffViews.tsxindex bd66a32000..1c9049dc76 100644--- a/ui/src/components/interrupt-handoff/InterruptHandoffViews.tsx+++ b/ui/src/components/interrupt-handoff/InterruptHandoffViews.tsx@@ -1,6 +1,6 @@import { AlertTriangle, Info, PauseCircle, User, X } from "lucide-react";import { cn } from "../../lib/utils";-import { AgentIcon } from "../AgentIconPicker";+import { AgentAvatar, type AvatarAgent } from "../AgentAvatar";import {classifyAssigneeHandoff,resolveRunStatusPresentation,@@ -17,7 +17,7 @@ import {* so they can be exercised in isolation by component tests and Storybook.*/-export interface HandoffAgentLike {+export interface HandoffAgentLike extends AvatarAgent {name: string;icon?: string | null;}@@ -60,7 +60,7 @@ export function AssigneeChip({return (<span className={cn(CHIP_CLASS, className)} data-testid="handoff-assignee-chip" data-kind="agent"><span className="sr-only">Agent </span>- <AgentIcon icon={agentIcon(assignee.agentId, resolvers)} className="h-3 w-3 shrink-0 text-muted-foreground" />+ <AgentAvatar agent={{ ...resolvers.agentMap?.get(assignee.agentId), id: assignee.agentId }} size={16} /><span className="max-w-(--sz-12rem) truncate">{agentName(assignee.agentId, resolvers)}</span></span>);diff --git a/ui/src/components/issue-properties/IssueProperties.tsx b/ui/src/components/issue-properties/IssueProperties.tsxindex 1ffb39d231..00bbb7f54a 100644--- a/ui/src/components/issue-properties/IssueProperties.tsx+++ b/ui/src/components/issue-properties/IssueProperties.tsx@@ -1,3 +1,5 @@+import { AgentIdentity } from "@/components/AgentIdentity";+import { AgentAvatar } from "@/components/AgentAvatar";import { normalizeLegacyRunnerProvider } from "@paperclipai/adapter-utils";import { useCallback, useEffect, useMemo, useRef, useState, type ComponentType } from "react";import { createPortal } from "react-dom";@@ -78,7 +80,6 @@ import {import { IssuePropertiesPlansTab } from "./IssuePropertiesPlansTab";import { IssuePropertiesArtifactsTab } from "./IssuePropertiesArtifactsTab";import { User, ArrowUpRight, Plus, X, GitBranch, FolderOpen, HardDrive, Check, Clock, RotateCcw, Loader2, CheckCircle2, ArchiveRestore, ChevronLeft } from "lucide-react";-import { AgentIcon } from "../AgentIconPicker";import { InlineEntitySelector, type InlineEntityOption } from "../InlineEntitySelector";import {AssigneeRunningBanner,@@ -949,7 +950,7 @@ export function IssueProperties({// --- Interrupt-handoff clarity for the assignee picker (design surface 2) ---const handoffResolvers: HandoffChipResolvers = useMemo(() => ({- agentMap: new Map((agents ?? []).map((agent) => [agent.id, { name: agent.name, icon: agent.icon }])),+ agentMap: new Map((agents ?? []).map((agent) => [agent.id, agent])),resolveUserLabel: (id) => userLabel(id),}),// userLabel closes over userLabelMap + currentUserId, both reflected here.@@ -1141,7 +1142,7 @@ export function IssueProperties({<span className="inline-flex min-w-0 max-w-full items-center gap-1.5 text-sm" title={issue.watchdog.instructions?.trim() || undefined}>{(() => {const agent = (agents ?? []).find((candidate) => candidate.id === issue.watchdog?.watchdogAgentId);- return agent ? <AgentIcon icon={agent.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" /> : null;+ return agent ? <AgentAvatar agent={agent} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/> : null;})()}<span className="shrink-0 max-w-40 truncate">{agentName(issue.watchdog.watchdogAgentId)}</span>{issue.watchdog.instructions?.trim() ? (@@ -1185,7 +1186,7 @@ export function IssueProperties({const agent = (agents ?? []).find((candidate) => candidate.id === option.id);return (<>- {agent ? <AgentIcon icon={agent.icon} className="h-3 w-3 shrink-0 text-muted-foreground" /> : null}+ {agent ? <AgentAvatar agent={agent} size={16} className="h-3 w-3 shrink-0 text-muted-foreground"/> : null}<span className="truncate">{option.label}</span></>);@@ -1194,7 +1195,7 @@ export function IssueProperties({const agent = (agents ?? []).find((candidate) => candidate.id === option.id);return (<>- {agent ? <AgentIcon icon={agent.icon} className="h-3 w-3 shrink-0 text-muted-foreground" /> : null}+ {agent ? <AgentAvatar agent={agent} size={16} className="h-3 w-3 shrink-0 text-muted-foreground"/> : null}<span className="truncate">{option.label}</span></>);@@ -1691,7 +1692,7 @@ export function IssueProperties({);const assigneeTrigger = assignee ? (- <Identity name={assignee.name} size="sm" shape="square" />+ <AgentIdentity agent={assignee} size="sm" />) : assigneeUserLabel ? (<><User className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />@@ -1771,7 +1772,7 @@ export function IssueProperties({}}>{option.kind === "agent" ? (- <AgentIcon icon={option.agent.icon} className="shrink-0 h-3 w-3 text-muted-foreground" />+ <AgentAvatar agent={option.agent} size={16} className="shrink-0 h-3 w-3 text-muted-foreground"/>) : option.kind === "user" ? (<User className="h-3 w-3 shrink-0 text-muted-foreground" />) : null}@@ -1930,7 +1931,7 @@ export function IssueProperties({)}onClick={() => toggleExecutionParticipant(stageType, encoded)}>- <AgentIcon icon={agent.icon} className="shrink-0 h-3 w-3 text-muted-foreground" />+ <AgentAvatar agent={agent} size={16} className="shrink-0 h-3 w-3 text-muted-foreground"/>{agent.name}</button>);@@ -2877,11 +2878,7 @@ export function IssueProperties({to={`/agents/${originatingActor.id}`}className="hover:underline">- <Identity- name={agentName(originatingActor.id) ?? originatingActor.id.slice(0, 8)}- size="sm"- shape="square"- />+ <AgentIdentity agent={agents?.find((agent) => agent.id === originatingActor.id) ?? { id: originatingActor.id, name: agentName(originatingActor.id) ?? "Agent" }} size="sm" /></Link>) : (<span className="flex min-w-0 items-center gap-1.5">@@ -2945,7 +2942,7 @@ export function IssueProperties({title={`Archived by ${archivedByName} · ${formatDateTime(issue.archivedAt)}`}>{archivedByAgent- ? <AgentIcon icon={archivedByAgent.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ ? <AgentAvatar agent={archivedByAgent} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/>: null}<span className="min-w-0 truncate">{archivedByName}diff --git a/ui/src/components/new-agent/AgentBasicsDialog.tsx b/ui/src/components/new-agent/AgentBasicsDialog.tsxindex 1b7ee5b27e..de8a3f7a84 100644--- a/ui/src/components/new-agent/AgentBasicsDialog.tsx+++ b/ui/src/components/new-agent/AgentBasicsDialog.tsx@@ -1,3 +1,6 @@+import { useCompany } from "@/context/CompanyContext";+import { useAgentAppearanceDraft } from "@/hooks/useAgentAppearanceDraft";+import { AgentCharacter } from "../AgentCharacter";import { useId, useState } from "react";import { useQuery } from "@tanstack/react-query";import { ArrowLeft, ArrowRight, Check, ChevronRight } from "lucide-react";@@ -16,7 +19,6 @@ import {DialogDescription,DialogTitle,} from "../ui/dialog";-import { PillGuy } from "../onboarding/PillGuy";export type AgentBasics = {name: string;@@ -79,6 +81,12 @@ export function AdapterMark({</>);}+function AgentBasicsCharacter() {+ const { selectedCompanyId } = useCompany();+ const { appearance } = useAgentAppearanceDraft(`${selectedCompanyId}:new-agent`);+ return <AgentCharacter appearance={appearance} state="sleepy" muted size={256} className="size-48" trackingScope="page" />;+}+export function AgentBasicsDialog({open,onClose,@@ -166,7 +174,7 @@ export function AgentBasicsDialog({><div className="flex min-h-0 flex-col gap-7 overflow-y-auto px-6 pb-8 sm:px-10"><div className="flex flex-col items-center gap-4 text-center">- <PillGuy state="dormant" className="size-16" />+ {open && <AgentBasicsCharacter />}<div className="space-y-2"><DialogTitle className="text-3xl font-semibold tracking-tight">{step === "name"diff --git a/ui/src/components/new-agent/NewAgentSetup.tsx b/ui/src/components/new-agent/NewAgentSetup.tsxindex 80a65dfdae..5ebb4e318b 100644--- a/ui/src/components/new-agent/NewAgentSetup.tsx+++ b/ui/src/components/new-agent/NewAgentSetup.tsx@@ -1,3 +1,5 @@+import { AgentCharacter } from "../AgentCharacter";+import { useAgentAppearanceDraft } from "../../hooks/useAgentAppearanceDraft";import { AiConnectionField, aiProviderForAdapter } from "../ai-connections/AiConnectionField";import type { AiConnectionBinding } from "@paperclipai/shared";import { DEFAULT_CODEX_LOCAL_MODEL } from "@paperclipai/adapter-codex-local";@@ -51,7 +53,6 @@ import { Field } from "../agent-config-primitives";import { SecretPicker } from "../environment-variables-editor/SecretPicker";import { Button } from "../ui/button";import { Input } from "../ui/input";-import { PillGuy } from "../onboarding/PillGuy";import {OnboardingCard,OnboardingHeading,@@ -107,6 +108,7 @@ function Setup({const navigate = useNavigate();const cache = useQueryClient();const { openNewIssue } = useDialogActions();+ const appearanceDraft = useAgentAppearanceDraft(`${companyId}:new-agent`);const isRunner = adapterType === "paperclip_runner";const brandType = isRunner? runnerProvider === "claude"@@ -497,6 +499,7 @@ function Setup({);const response = await agentsApi.hire(companyId, {name: name.trim(),+ appearance: appearanceDraft.appearance,role: existing.length ? "general" : "ceo",...(leader ? { reportsTo: leader.id } : {}),adapterType,@@ -517,6 +520,7 @@ function Setup({setApiKey("");setConnection(null);setCreated(response.agent);+ appearanceDraft.clear();setScreen("saved");navigate(`/agents/new?${new URLSearchParams({ name: response.agent.name, adapterType, runnerProvider, createdAgentId: response.agent.id })}`,@@ -624,10 +628,9 @@ function Setup({<MotionConfig reducedMotion="user"><div className="mx-auto flex max-w-5xl flex-col gap-8 py-6"><header className="flex items-center gap-4">- <PillGuy- state={created ? "alive" : "dormant"}- className="size-14 shrink-0"- />+ <AgentCharacter appearance={created?.appearance ?? appearanceDraft.appearance} size={256} className="size-48" trackingScope="page"+ state={created || testState === "pass" ? "success" : testState === "running" ? "loading" : "sleepy"}+ muted={!created && testState !== "pass"} /><div className="space-y-2"><h1 className="text-2xl font-semibold tracking-tight">{name}</h1><div className="flex items-center gap-2 text-sm text-muted-foreground">diff --git a/ui/src/components/onboarding/ConnectModelPreview.tsx b/ui/src/components/onboarding/ConnectModelPreview.tsxindex fdd6f2acb2..56f6aaf0de 100644--- a/ui/src/components/onboarding/ConnectModelPreview.tsx+++ b/ui/src/components/onboarding/ConnectModelPreview.tsx@@ -1,3 +1,4 @@+import { AgentCharacter } from "../AgentCharacter";import { useState } from "react";import { MotionConfig } from "motion/react";@@ -96,7 +97,7 @@ export function ConnectModelPreview({{/* `relative` is load-bearing: the sleep marks anchor to this box andtravel out past its top-right corner. */}<div className="relative size-(--sz-72px)">- <PillGuy state="dormant" className="size-full" />+ <AgentCharacter state="sleepy" muted size={128} className="size-full" /><SleepingZs /></div><AgentPreview agentName="Darnold" agentRole="" />diff --git a/ui/src/components/routine-sections/editable-sections.production.tsx b/ui/src/components/routine-sections/editable-sections.production.tsxindex 49e79c2522..a7adf99d0f 100644--- a/ui/src/components/routine-sections/editable-sections.production.tsx+++ b/ui/src/components/routine-sections/editable-sections.production.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { useEffect, useMemo, useState } from "react";import {ArrowRight,@@ -28,7 +29,6 @@ import { timeAgo } from "../../lib/timeAgo";import { EmptyState } from "../EmptyState";import { InlineEntitySelector } from "../InlineEntitySelector";import { DocumentAnnotationsCountChip, IssueDocumentAnnotations } from "../IssueDocumentAnnotations";-import { AgentIcon } from "../AgentIconPicker";import { MarkdownEditor } from "../MarkdownEditor";import { ScheduleEditor, getScheduleCronValidation } from "../ScheduleEditor";import { RoutineVariablesEditor, RoutineVariablesHint } from "../RoutineVariablesEditor";@@ -177,7 +177,7 @@ export function OverviewSection({option ? (currentAssignee ? (<>- <AgentIcon icon={currentAssignee.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ <AgentAvatar agent={currentAssignee} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/><span className="truncate">{option.label}</span></>) : (@@ -193,7 +193,7 @@ export function OverviewSection({return (<>{assignee ? (- <AgentIcon icon={assignee.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ <AgentAvatar agent={assignee} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/>) : null}<span className="truncate">{option.label}</span></>diff --git a/ui/src/components/routine-sections/editable-sections.tsx b/ui/src/components/routine-sections/editable-sections.tsxindex 4321a3ec44..3be34a09c1 100644--- a/ui/src/components/routine-sections/editable-sections.tsx+++ b/ui/src/components/routine-sections/editable-sections.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { useEffect, useMemo, useState } from "react";import {ArrowRight,@@ -27,7 +28,6 @@ import { timeAgo } from "../../lib/timeAgo";import { EmptyState } from "../EmptyState";import { InlineEntitySelector } from "../InlineEntitySelector";import { DocumentAnnotationsCountChip, IssueDocumentAnnotations } from "../IssueDocumentAnnotations";-import { AgentIcon } from "../AgentIconPicker";import { MarkdownEditor } from "../MarkdownEditor";import { ScheduleEditor, getScheduleCronValidation } from "../ScheduleEditor";import { RoutineVariablesEditor, RoutineVariablesHint } from "../RoutineVariablesEditor";@@ -175,7 +175,7 @@ export function OverviewSection({option ? (currentAssignee ? (<>- <AgentIcon icon={currentAssignee.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ <AgentAvatar agent={currentAssignee} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/><span className="truncate">{option.label}</span></>) : (@@ -191,7 +191,7 @@ export function OverviewSection({return (<>{assignee ? (- <AgentIcon icon={assignee.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ <AgentAvatar agent={assignee} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/>) : null}<span className="truncate">{option.label}</span></>diff --git a/ui/src/components/search/SearchResultRow.tsx b/ui/src/components/search/SearchResultRow.tsxindex d159fdfd19..ea118b63e9 100644--- a/ui/src/components/search/SearchResultRow.tsx+++ b/ui/src/components/search/SearchResultRow.tsx@@ -1,3 +1,5 @@+import { AgentAvatar } from "../AgentAvatar";+import { AgentIdentity } from "../AgentIdentity";import { memo, type ComponentType, type SVGProps } from "react";import { Bot, FileText, Hexagon, MessageSquare, Paperclip, Quote } from "lucide-react";import type { Agent, CompanySearchResult } from "@paperclipai/shared";@@ -46,7 +48,7 @@ function formatRelativeTime(input: string | null): string {export interface SearchResultRowProps {result: CompanySearchResult;- agentsById?: ReadonlyMap<string, Pick<Agent, "id" | "name">>;+ agentsById?: ReadonlyMap<string, Pick<Agent, "id" | "name" | "appearance">>;isActive?: boolean;className?: string;}@@ -67,9 +69,7 @@ function SearchResultRowImpl({className={cn(ROW_BASE, "py-3", isActive && "bg-muted/40", className)}data-result-type="agent">- <span className="mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground">- <Bot className="h-3 w-3" />- </span>+ <AgentAvatar agent={agentsById?.get(result.id) ?? { id: result.id, name: result.title }} size={24} /><div className="min-w-0 flex-1"><div className="flex min-w-0 items-center gap-2"><span className="truncate text-sm font-medium">{result.title}</span>@@ -214,7 +214,7 @@ function SearchResultRowImpl({<div className="ml-2 hidden shrink-0 flex-col items-end gap-2 sm:flex">{assigneeName || updated ? (<div className="flex items-center gap-2 text-xs text-muted-foreground">- {assigneeName ? <Identity name={assigneeName} size="sm" /> : null}+ {assigneeName ? <AgentIdentity agent={agentsById?.get(result.issue?.assigneeAgentId ?? "") ?? { id: result.issue?.assigneeAgentId ?? undefined, name: assigneeName }} size="sm" /> : null}{updated ? <span className="tabular-nums">{updated}</span> : null}</div>) : null}diff --git a/ui/src/components/task-chat/TaskChatBubble.tsx b/ui/src/components/task-chat/TaskChatBubble.tsxindex bc51a51133..2562c31d09 100644--- a/ui/src/components/task-chat/TaskChatBubble.tsx+++ b/ui/src/components/task-chat/TaskChatBubble.tsx@@ -1,3 +1,4 @@+import { AgentAvatar, type AvatarAgent } from "../AgentAvatar";import { useCallback, useContext, useState, type ReactNode } from "react";import { useEmailComment } from "@/components/EmailMessageCard";import type { IssueAttachment } from "@paperclipai/shared";@@ -9,8 +10,6 @@ import {ImageGalleryModal,type GalleryMediaItem,} from "@/components/ImageGalleryModal";-import { Avatar, AvatarFallback } from "@/components/ui/avatar";-import { AgentIcon } from "@/components/AgentIconPicker";import {Attachment,AttachmentContent,@@ -74,28 +73,18 @@ function initialsForName(name: string) {export function TaskChatAgentIdentity({agentName,agentIcon,+ agent,}: {agentName: string;agentIcon?: string | null;+ agent?: AvatarAgent;}) {return (<spanclassName="flex items-center gap-2 px-1"data-testid="task-chat-agent-identity">- <Avatar- size="sm"- className="shrink-0"- data-testid="task-chat-agent-avatar"- >- {agentIcon ? (- <AvatarFallback>- <AgentIcon icon={agentIcon} className="h-3.5 w-3.5" />- </AvatarFallback>- ) : (- <AvatarFallback>{initialsForName(agentName)}</AvatarFallback>- )}- </Avatar>+ <span data-testid="task-chat-agent-avatar"><AgentAvatar agent={agent} name={agentName} size={24} /></span><span className="text-sm font-semibold text-foreground">{agentName}</span></span>);@@ -232,6 +221,7 @@ function TaskChatBubbleContent({<TaskChatAgentIdentityagentName={item.authorName}agentIcon={item.agentIcon}+ agent={item.agent}/>) : null}{bodyText.length > 0 ? (diff --git a/ui/src/components/task-chat/TaskChatComposer.tsx b/ui/src/components/task-chat/TaskChatComposer.tsxindex e59dcfd42f..cbe5740466 100644--- a/ui/src/components/task-chat/TaskChatComposer.tsx+++ b/ui/src/components/task-chat/TaskChatComposer.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "../AgentAvatar";import {useEffect,useRef,@@ -65,7 +66,6 @@ import {InlineEntitySelector,type InlineEntityOption,} from "@/components/InlineEntitySelector";-import { AgentIcon } from "@/components/AgentIconPicker";import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";import type { MentionOption } from "@/components/MarkdownEditor";import type { IssueAttachment, IssueWorkMode } from "@paperclipai/shared";@@ -123,7 +123,7 @@ interface TaskChatComposerProps {enableReassign?: boolean;conversationMode?: boolean;reassignOptions?: InlineEntityOption[];- agentMap?: ReadonlyMap<string, { icon?: string | null }>;+ agentMap?: ReadonlyMap<string, import("../AgentAvatar").AvatarAgent & { icon?: string | null }>;userProfileMap?: ReadonlyMap<string,{ label: string; image: string | null }@@ -246,7 +246,7 @@ function AssigneeIdentityAvatar({}: {assigneeValue: string;label: string;- agentMap: ReadonlyMap<string, { icon?: string | null }> | undefined;+ agentMap: ReadonlyMap<string, import("../AgentAvatar").AvatarAgent & { icon?: string | null }> | undefined;userProfileMap:| ReadonlyMap<string, { label: string; image: string | null }>| null@@ -257,8 +257,7 @@ function AssigneeIdentityAvatar({const agentId = assigneeValue.slice("agent:".length);const icon = agentMap?.get(agentId)?.icon ?? "bot";return (- <Avatar- size="xs"+ <spanclassName="shrink-0"data-assignee-identity={assigneeValue}data-assignee-trigger-icon={placement === "trigger" ? icon : undefined}@@ -266,10 +265,8 @@ function AssigneeIdentityAvatar({placement === "option" ? assigneeValue : undefined}>- <AvatarFallback>- <AgentIcon icon={icon} className="h-3 w-3" />- </AvatarFallback>- </Avatar>+ <AgentAvatar agent={agentMap?.get(agentId) ?? { id: agentId }} size={16} />+ </span>);}diff --git a/ui/src/components/task-chat/TaskChatDescriptionBubble.test.tsx b/ui/src/components/task-chat/TaskChatDescriptionBubble.test.tsxindex b2f4c23dc5..111459fb50 100644--- a/ui/src/components/task-chat/TaskChatDescriptionBubble.test.tsx+++ b/ui/src/components/task-chat/TaskChatDescriptionBubble.test.tsx@@ -80,7 +80,7 @@ describe("TaskChatDescriptionBubble (PAP-375)", () => {expect(bubble).not.toBeNull();expect(bubble?.getAttribute("data-author")).toBe("human");expect(bubble?.className).toContain("items-end");- expect(bubble?.querySelector('[data-testid="task-chat-agent-avatar"]')).toBeNull();+ expect(bubble?.querySelector('[data-slot="agent-avatar"]')).toBeNull();const body = bubble?.querySelector(".bg-\\(--liveness-blue\\)");expect(body).not.toBeNull();expect(body?.textContent).toContain("Ship the widget by");@@ -94,7 +94,7 @@ describe("TaskChatDescriptionBubble (PAP-375)", () => {const bubble = container.querySelector('[data-testid="task-chat-description-bubble"]');expect(bubble?.getAttribute("data-author")).toBe("agent");expect(bubble?.className).toContain("items-start");- expect(bubble?.querySelector('[data-testid="task-chat-agent-avatar"]')).not.toBeNull();+ expect(bubble?.querySelector('[data-slot="agent-avatar"]')).not.toBeNull();expect(bubble?.textContent).toContain("CEO");expect(bubble?.querySelector(".bg-\\(--bubble-agent\\)")).not.toBeNull();expect(bubble?.querySelector(".bg-\\(--liveness-blue\\)")).toBeNull();diff --git a/ui/src/components/task-chat/TaskChatDescriptionBubble.tsx b/ui/src/components/task-chat/TaskChatDescriptionBubble.tsxindex ed4b6b133b..0cb2630b98 100644--- a/ui/src/components/task-chat/TaskChatDescriptionBubble.tsx+++ b/ui/src/components/task-chat/TaskChatDescriptionBubble.tsx@@ -1,3 +1,4 @@+import { AgentAvatar, type AvatarAgent } from "../AgentAvatar";import { useState } from "react";import { Pencil } from "lucide-react";import { cn } from "@/lib/utils";@@ -5,7 +6,6 @@ import { FoldCurtain } from "@/components/FoldCurtain";import { InlineEditor } from "@/components/InlineEditor";import { MarkdownBody, type MarkdownExternalReferenceMap } from "@/components/MarkdownBody";import { Avatar, AvatarFallback } from "@/components/ui/avatar";-import { AgentIcon } from "@/components/AgentIconPicker";import type { MentionOption } from "@/components/MarkdownEditor";import { formatTaskChatTimestamp } from "./task-chat-adapter";@@ -23,6 +23,7 @@ export interface TaskChatIssueBrief {authorName?: string;/** Creating agent's assigned icon (AgentIconName) for the avatar header. */agentIcon?: string | null;+ agent?: AvatarAgent;/** issue.createdAt — rendered like the other bubbles' footer timestamps. */createdAt?: string | Date;onSave: (description: string) => void | Promise<unknown>;@@ -115,15 +116,7 @@ export function TaskChatDescriptionBubble({ brief }: TaskChatDescriptionBubblePr>{!isHuman && brief.authorName ? (<span className="flex items-center gap-2 px-1">- <Avatar size="sm" className="shrink-0" data-testid="task-chat-agent-avatar">- {brief.agentIcon ? (- <AvatarFallback>- <AgentIcon icon={brief.agentIcon} className="h-3.5 w-3.5" />- </AvatarFallback>- ) : (- <AvatarFallback>{initialsForName(brief.authorName)}</AvatarFallback>- )}- </Avatar>+ <AgentAvatar agent={brief.agent} name={brief.authorName} size={24} /><span className="text-sm font-semibold text-foreground">{brief.authorName}</span></span>) : null}diff --git a/ui/src/components/task-chat/TaskChatRunnerTurn.tsx b/ui/src/components/task-chat/TaskChatRunnerTurn.tsxindex c65890e7a9..00df5ee5f1 100644--- a/ui/src/components/task-chat/TaskChatRunnerTurn.tsx+++ b/ui/src/components/task-chat/TaskChatRunnerTurn.tsx@@ -118,6 +118,7 @@ export function TaskChatRunnerTurn({runId,agentName,agentIcon,+ agent,items,status,startedAtMs,@@ -131,6 +132,7 @@ export function TaskChatRunnerTurn({runId?: string | null;agentName?: string | null;agentIcon?: string | null;+ agent?: import("../AgentAvatar").AvatarAgent;items: readonly TaskChatItem[];status: string;execution?: ExecutionProjection | null;@@ -213,7 +215,7 @@ export function TaskChatRunnerTurn({data-testid="task-chat-runner-identity-row">{agentName ? (- <TaskChatAgentIdentity agentName={agentName} agentIcon={agentIcon} />+ <TaskChatAgentIdentity agentName={agentName} agentIcon={agentIcon} agent={agent} />) : null}<RunnerTurnStatusstatus={status}@@ -271,7 +273,7 @@ export function TaskChatRunnerTurn({data-testid="task-chat-final-response"><TaskChatBubble- item={{ ...final, authorName: agentName ?? undefined, agentIcon, timestamp: final.timestamp ?? formatTaskChatTimestamp(final.atMs) }}+ item={{ ...final, authorName: agentName ?? undefined, agentIcon, agent, timestamp: final.timestamp ?? formatTaskChatTimestamp(final.atMs) }}animateEntry={false}hideAgentIdentity={!continuedAfterSteering}actions={<TaskChatBubbleActions copyText={final.text} />}diff --git a/ui/src/components/task-chat/TaskChatThreadView.tsx b/ui/src/components/task-chat/TaskChatThreadView.tsxindex 1ac28528fd..52d900ecbf 100644--- a/ui/src/components/task-chat/TaskChatThreadView.tsx+++ b/ui/src/components/task-chat/TaskChatThreadView.tsx@@ -111,6 +111,7 @@ function renderItem(...item.attachedTurn,agentName: item.attachedTurn.agentName ?? item.authorName,agentIcon: item.attachedTurn.agentIcon ?? item.agentIcon,+ agent: item.attachedTurn.agent ?? item.agent,}: item.attachedTurn;const turn = attachedTurnItem ? (diff --git a/ui/src/components/task-chat/TaskChatTurn.tsx b/ui/src/components/task-chat/TaskChatTurn.tsxindex 8545e892f0..3377ef40ed 100644--- a/ui/src/components/task-chat/TaskChatTurn.tsx+++ b/ui/src/components/task-chat/TaskChatTurn.tsx@@ -96,7 +96,7 @@ export function TaskChatTurn({{item.agentName ? (<TaskChatAgentIdentityagentName={item.agentName}- agentIcon={item.agentIcon}+ agentIcon={item.agentIcon} agent={item.agent}/>) : null}<span className="min-w-0 truncate">diff --git a/ui/src/components/task-chat/task-chat-adapter.ts b/ui/src/components/task-chat/task-chat-adapter.tsindex ce8fef7263..d8434c4ad3 100644--- a/ui/src/components/task-chat/task-chat-adapter.ts+++ b/ui/src/components/task-chat/task-chat-adapter.ts@@ -120,6 +120,7 @@ export function commentsToTaskChatItems(kind: "message",author: kind,authorName,+ agent: effectiveAgentId(comment) ? ctx.agentMap?.get(effectiveAgentId(comment)!) ?? { id: effectiveAgentId(comment)! } : undefined,text: comment.body,sourceChannel: kind === "human" ? comment.metadata?.sourceChannel : undefined,timestamp: formatTaskChatCommentTimestamp(comment, kind),diff --git a/ui/src/components/task-chat/task-chat-model.ts b/ui/src/components/task-chat/task-chat-model.tsindex 057fa7799f..9dbab8ada1 100644--- a/ui/src/components/task-chat/task-chat-model.ts+++ b/ui/src/components/task-chat/task-chat-model.ts@@ -126,6 +126,7 @@ export interface TaskChatMessageItem {}>;/** Assigned agent icon name (AgentIconName) for the avatar header. */agentIcon?: string | null;+ agent?: import("../AgentAvatar").AvatarAgent;/*** Responsible user's display name, set only when this agent comment is a* cross-issue write (the author is not the assignee). Renders as a@@ -506,6 +507,7 @@ export interface TaskChatTurnItem {/** Agent identity retained when a live runner turn becomes durable history. */agentName?: string;agentIcon?: string | null;+ agent?: import("../AgentAvatar").AvatarAgent;/*** The in-flight run's status line, hoisted to be THE turn's single visible* row while collapsed (PAP-354 parent-row model). Absent once settled.diff --git a/ui/src/components/timeline/WorkTimelineChart.test.tsx b/ui/src/components/timeline/WorkTimelineChart.test.tsxindex 8862a1196f..31470558b9 100644--- a/ui/src/components/timeline/WorkTimelineChart.test.tsx+++ b/ui/src/components/timeline/WorkTimelineChart.test.tsx@@ -178,13 +178,15 @@ describe("WorkTimelineChart", () => {expect(lastCall?.toMs).toBeCloseTo(new Date("2026-07-02T01:00:00.000Z").getTime(), -3);});- it("renders configured agent icons in the actor gutter instead of generated initials", () => {+ it("renders cached persona images in the actor gutter", () => {renderChart(timelineSample());const gutter = container.querySelector<SVGSVGElement>("[data-testid='work-timeline-actor-gutter']");- expect(gutter?.querySelector(".lucide-code")).not.toBeNull();- expect(gutter?.querySelector(".lucide-shield")).not.toBeNull();+ const portraits = gutter?.querySelectorAll('image[data-testid="timeline-agent-icon"]');+ expect(portraits?.length).toBe(2);+ expect(portraits?.[0].getAttribute("href")).toContain("/api/agent-avatars/cap-v1/");+ expect(portraits?.[1].getAttribute("href")).toContain("/api/agent-avatars/cap-v1/");expect(gutter?.textContent).not.toContain("CC");});diff --git a/ui/src/components/timeline/WorkTimelineChart.tsx b/ui/src/components/timeline/WorkTimelineChart.tsxindex 17c9804b21..b982a51da9 100644--- a/ui/src/components/timeline/WorkTimelineChart.tsx+++ b/ui/src/components/timeline/WorkTimelineChart.tsx@@ -1,3 +1,5 @@+import { agentAvatarUrl } from "@/lib/agent-avatar-url";+import { resolveAgentAppearance } from "@paperclipai/shared";/*** Work Timeline — custom-SVG Gantt (board-locked Direction C, PAP-12422).*@@ -12,7 +14,6 @@ import { useEffect, useMemo, useRef, useState } from "react";import { useLocation } from "@/lib/router";import type { WorkTimelineActor, WorkTimelineResult } from "@paperclipai/shared";import { applyCompanyPrefix, extractCompanyPrefixFromPath } from "@/lib/company-routes";-import { getAgentIcon } from "@/lib/agent-icons";import {AXIS_H,actorType,@@ -182,19 +183,10 @@ function ActorGlyph({clipId: string;}) {if (actor.type === "agent") {- const Icon = getAgentIcon(actor.avatar);- const size = r > 10 ? 16 : 13;- return (- <Icon- data-testid="timeline-agent-icon"- x={cx - size / 2}- y={cy - size / 2}- width={size}- height={size}- strokeWidth={2.2}- color="var(--color-muted-foreground)"- />- );+ const size = r > 10 ? 24 : 16;+ const appearance = resolveAgentAppearance(actor.appearance, actor.id.replace(/^agent:/, ""));+ return <image data-testid="timeline-agent-icon" href={agentAvatarUrl(appearance, size, 2)}+ x={cx - size / 2} y={cy - size / 2} width={size} height={size} preserveAspectRatio="xMidYMid meet" />;}const stroke = "var(--color-foreground)";diff --git a/ui/src/connect-flow-preview-main.tsx b/ui/src/connect-flow-preview-main.tsxindex 9b6aa7510d..221b0ce3c1 100644--- a/ui/src/connect-flow-preview-main.tsx+++ b/ui/src/connect-flow-preview-main.tsx@@ -27,7 +27,7 @@ import {type ModelSource,} from "./components/onboarding/ModelSourceTiles";import { OnboardingHeading } from "./components/onboarding/OnboardingPrimitives";-import { PillGuy } from "./components/onboarding/PillGuy";+import { AgentCharacter } from "./components/AgentCharacter";import { SleepingZs } from "./components/onboarding/SleepingZs";import { Stepper } from "./components/onboarding/Stepper";import "./index.css";@@ -299,7 +299,7 @@ function ConnectFlowPreview({<div className="flex flex-col items-center"><div className="relative size-(--sz-72px)">- <PillGuy state={done ? "alive" : "dormant"} className="size-full" />+ <AgentCharacter muted={!done} state={done ? "success" : "sleepy"} size={128} className="size-full" />{!done && <SleepingZs />}</div><AgentPreview agentName="Ron" agentRole="" />diff --git a/ui/src/features/connections/ConnectionSetupFlow.tsx b/ui/src/features/connections/ConnectionSetupFlow.tsxindex e5e998dd5d..8ab534b0f1 100644--- a/ui/src/features/connections/ConnectionSetupFlow.tsx+++ b/ui/src/features/connections/ConnectionSetupFlow.tsx@@ -56,7 +56,6 @@ import { ApiError } from "@/api/client";import { toolsApi } from "@/api/tools";import { agentsApi } from "@/api/agents";import { appCopyFor, credentialFieldLabel } from "@/lib/app-gallery-copy";-import { AgentIcon } from "@/components/AgentIconPicker";import { AgentMultiSelect } from "@/components/AgentMultiSelect";import { InlineBanner } from "@/components/InlineBanner";import { Button } from "@/components/ui/button";diff --git a/ui/src/hooks/useAgentAppearanceDraft.ts b/ui/src/hooks/useAgentAppearanceDraft.tsnew file mode 100644index 0000000000..8cbd6bc85a--- /dev/null+++ b/ui/src/hooks/useAgentAppearanceDraft.ts@@ -0,0 +1,19 @@+import { useState } from "react";+import { agentAppearanceSchema, randomAgentAppearance } from "@paperclipai/shared";++/** Non-secret visual identity, retained across navigation and company changes. */+export function useAgentAppearanceDraft(draftKey: string) {+ const key = `paperclip.agent-appearance.${draftKey}`;+ function readDraft() {+ try {+ const stored = agentAppearanceSchema.safeParse(JSON.parse(sessionStorage.getItem(key) ?? "null"));+ if (stored.success) return stored.data;+ } catch { /* Storage can be unavailable; retain the in-memory assignment. */ }+ const value = randomAgentAppearance();+ try { sessionStorage.setItem(key, JSON.stringify(value)); } catch { /* In-memory draft still works. */ }+ return value;+ }+ const [draft, setDraft] = useState(() => ({ key, appearance: readDraft() }));+ if (draft.key !== key) setDraft({ key, appearance: readDraft() });+ return { appearance: draft.appearance, clear() { try { sessionStorage.removeItem(key); } catch { /* Best effort. */ } } };+}diff --git a/ui/src/index.css b/ui/src/index.cssindex 545c0c0ba5..7dbf1df614 100644--- a/ui/src/index.css+++ b/ui/src/index.css@@ -3047,3 +3047,43 @@ span.paperclip-mention-chip[data-mention-kind="external-object"] {.chat-connection-health-summary::-webkit-details-marker {display: none;}++/* Immutable ClipLab cap-v1 artwork tokens. New artwork gets a new version. */+:root {+ --agent-cap-v1-bubblegum-sky-a: #8bd4ff;+ --agent-cap-v1-bubblegum-sky-b: #ff51bf;+ --agent-cap-v1-pink-lemonade-a: #ff26a8;+ --agent-cap-v1-pink-lemonade-b: #fff78a;+ --agent-cap-v1-orchid-peach-a: #e771ff;+ --agent-cap-v1-orchid-peach-b: #ffd87c;+ --agent-cap-v1-coral-mint-a: #beffe8;+ --agent-cap-v1-coral-mint-b: #ff797b;+ --agent-cap-v1-lime-lagoon-a: #b4ffa4;+ --agent-cap-v1-lime-lagoon-b: #26dfff;+ --agent-cap-v1-arctic-blue-a: #97fff3;+ --agent-cap-v1-arctic-blue-b: #0084ff;+ --agent-cap-v1-solar-flare-a: #ecca5c;+ --agent-cap-v1-solar-flare-b: #fe3c3f;+ --agent-cap-v1-violet-ember-a: #ff5c43;+ --agent-cap-v1-violet-ember-b: #6262ff;+ --agent-cap-v1-deep-tide-a: #003d60;+ --agent-cap-v1-deep-tide-b: #32fffc;+ --agent-cap-v1-coral-current-a: #26e2ff;+ --agent-cap-v1-coral-current-b: #ff6666;+ --agent-cap-v1-golden-hour-a: #ffcd4f;+ --agent-cap-v1-golden-hour-b: #fde5ba;+ --agent-cap-v1-tangerine-cobalt-a: #ffad32;+ --agent-cap-v1-tangerine-cobalt-b: #4169ff;+ --agent-cap-v1-electric-grove-a: #b4ff32;+ --agent-cap-v1-electric-grove-b: #008d58;+ --agent-cap-v1-flamingo-jade-a: #ff4f9a;+ --agent-cap-v1-flamingo-jade-b: #36edaa;+ --agent-cap-v1-cherry-pop-a: #ff69db;+ --agent-cap-v1-cherry-pop-b: #d51c46;+ --agent-cap-v1-turquoise-cherry-a: #37f0db;+ --agent-cap-v1-turquoise-cherry-b: #ff4f64;+ --agent-cap-v1-ultraviolet-tide-a: #7516cf;+ --agent-cap-v1-ultraviolet-tide-b: #00e8d1;+ --agent-cap-v1-muted-dream-a: #a6aaad;+ --agent-cap-v1-muted-dream-b: #44464a;+}diff --git a/ui/src/lib/agent-avatar-url.ts b/ui/src/lib/agent-avatar-url.tsnew file mode 100644index 0000000000..1df5b27e73--- /dev/null+++ b/ui/src/lib/agent-avatar-url.ts@@ -0,0 +1,2 @@+// Storybook replaces this module at build time with its packaged-image resolver.+export { agentAvatarUrl } from "@paperclipai/shared";diff --git a/ui/src/lib/agent-character-slot.ts b/ui/src/lib/agent-character-slot.tsnew file mode 100644index 0000000000..ee8201e3f9--- /dev/null+++ b/ui/src/lib/agent-character-slot.ts@@ -0,0 +1,9 @@+// The app gets one live hero. Other placements retain their static image.+let owner: symbol | null = null;+const listeners = new Set<() => void>();+export const characterSlot = {+ subscribe(listener: () => void) { listeners.add(listener); return () => { listeners.delete(listener); }; },+ getSnapshot() { return owner; },+ acquire(id: symbol) { if (owner) return false; owner = id; for (const listener of listeners) listener(); return true; },+ release(id: symbol) { if (owner !== id) return; owner = null; for (const listener of listeners) listener(); },+};diff --git a/ui/src/lib/company-members.ts b/ui/src/lib/company-members.tsindex 90d5e907fe..484b0a4b31 100644--- a/ui/src/lib/company-members.ts+++ b/ui/src/lib/company-members.ts@@ -85,7 +85,7 @@ export function buildCompanyUserMentionOptions(}export function isAgentTaskTarget(- agent: Pick<Agent, "status"> & Partial<Pick<Agent, "orgChainHealth">>,+ agent: Pick<Agent, "status"> & Partial<Pick<Agent, "orgChainHealth" | "appearance">>,): boolean {return (agent.status !== "terminated" &&@@ -116,7 +116,7 @@ export function buildIssueMentionOptions(}export function buildMarkdownMentionOptions(args: {- agents?: Array<Pick<Agent, "id" | "name" | "status" | "icon"> & Partial<Pick<Agent, "orgChainHealth">>> | null | undefined;+ agents?: Array<Pick<Agent, "id" | "name" | "status" | "icon"> & Partial<Pick<Agent, "orgChainHealth" | "appearance">>> | null | undefined;projects?: Array<Pick<Project, "id" | "name" | "color">> | null | undefined;members?: CompanyUserRecord[] | null | undefined;issues?: Array<Pick<Issue, "id" | "identifier" | "title">> | null | undefined;@@ -132,6 +132,7 @@ export function buildMarkdownMentionOptions(args: {kind: "agent" as const,agentId: agent.id,agentIcon: agent.icon,+ agentAppearance: agent.appearance,})),...[...(args.projects ?? [])].sort((left, right) => left.name.localeCompare(right.name))diff --git a/ui/src/lib/duplicate-agent-payload.test.ts b/ui/src/lib/duplicate-agent-payload.test.tsindex dd86af7a50..4af744a916 100644--- a/ui/src/lib/duplicate-agent-payload.test.ts+++ b/ui/src/lib/duplicate-agent-payload.test.ts@@ -47,6 +47,11 @@ const baseAgent: AgentDetail = {};describe("duplicate agent payload", () => {+ it("omits the source persona so central creation makes a fresh assignment", () => {+ const source = { ...baseAgent, appearance: { schemaVersion: 1, characterVersion: "cap-v1", paletteId: "arctic-blue" } } as AgentDetail;+ expect(buildDuplicateAgentPayload(source)).not.toHaveProperty("appearance");+ });+it("suffixes duplicate names", () => {expect(duplicateAgentName("Senior Product Engineer")).toBe("Senior Product Engineer Copy");expect(duplicateAgentName(" ")).toBe("Agent Copy");diff --git a/ui/src/pages/AgentDetail.production.tsx b/ui/src/pages/AgentDetail.production.tsxindex 519e6c5254..a64210b408 100644--- a/ui/src/pages/AgentDetail.production.tsx+++ b/ui/src/pages/AgentDetail.production.tsx@@ -1,3 +1,5 @@+import { AgentCharacter } from "../components/AgentCharacter";+import { characterStateForAgent } from "@paperclipai/shared";import { mergeRunLogChunks, readChunkSeq } from "../lib/run-log-chunks";import { getPageVisibility, usePageVisibility } from "../lib/page-visibility";import { useCallback, useEffect, useMemo, useState, useRef } from "react";@@ -91,7 +93,6 @@ import {import { Collapsible, CollapsibleTrigger, CollapsibleContent } from "@/components/ui/collapsible";import { TooltipProvider } from "@/components/ui/tooltip";import { Input } from "@/components/ui/input";-import { AgentIcon, AgentIconPicker } from "../components/AgentIconPicker";import { RunTranscriptView, type TranscriptMode } from "../components/transcript/RunTranscriptView";import { AgentToolsTab } from "./AgentToolsTab";import { AgentChannelsPanel } from "../components/chat/AgentChannelsPanel";@@ -1283,14 +1284,7 @@ export function AgentDetail() {{/* Header */}<div className="flex items-center justify-between gap-2"><div className="flex items-center gap-3 min-w-0">- <AgentIconPicker- value={agent.icon}- onChange={(icon) => updateIcon.mutate(icon)}- >- <button className="shrink-0 flex items-center justify-center h-12 w-12 rounded-lg bg-accent hover:bg-accent/80 transition-colors">- <AgentIcon icon={agent.icon} className="h-6 w-6" />- </button>- </AgentIconPicker>+ <AgentCharacter agent={agent} state={characterStateForAgent(agent.status)} size={96} trackingScope="page" /><div className="min-w-0"><div className="flex items-center gap-2"><h2 className="text-2xl font-bold truncate">{agent.name}</h2>diff --git a/ui/src/pages/AgentDetail.tsx b/ui/src/pages/AgentDetail.tsxindex 1ae0704863..fc833c2aa0 100644--- a/ui/src/pages/AgentDetail.tsx+++ b/ui/src/pages/AgentDetail.tsx@@ -1,3 +1,5 @@+import { AgentCharacter } from "../components/AgentCharacter";+import { characterStateForAgent } from "@paperclipai/shared";import { mergeRunLogChunks, readChunkSeq } from "../lib/run-log-chunks";import { getPageVisibility, usePageVisibility } from "../lib/page-visibility";import { useCallback, useEffect, useMemo, useState, useRef } from "react";@@ -27,7 +29,6 @@ import { queryKeys } from "../lib/queryKeys";import { copyTextToClipboard } from "../lib/clipboard";import { AgentSkillsTab } from "./agent-skills/AgentSkillsTab";import { AgentConfigForm } from "../components/AgentConfigForm";-import { PillGuy } from "../components/onboarding/PillGuy";import { getAdapterDisplay } from "../adapters/adapter-display-registry";import { adapterLabels, roleLabels, help } from "../components/agent-config-primitives";import { ToggleSwitch } from "@/components/ui/toggle-switch";@@ -89,7 +90,6 @@ import {import { Collapsible, CollapsibleTrigger, CollapsibleContent } from "@/components/ui/collapsible";import { TooltipProvider } from "@/components/ui/tooltip";import { Input } from "@/components/ui/input";-import { AgentIcon, AgentIconPicker } from "../components/AgentIconPicker";import { RunTranscriptView, type TranscriptMode } from "../components/transcript/RunTranscriptView";import { AgentToolsTab } from "./AgentToolsTab";import { AgentChannelsPanel } from "../components/chat/AgentChannelsPanel";@@ -1248,7 +1248,7 @@ export function AgentDetail() {<header className="flex flex-wrap items-center justify-between gap-5 border-b border-border pb-6"><div className="flex min-w-0 items-center gap-4"><div role="img" aria-label={`${agent.name} avatar`} className="shrink-0">- <PillGuy state="alive" className="size-12" />+ <AgentCharacter agent={agent} state={characterStateForAgent(agent.status)} size={96} trackingScope="page" /></div><div className="min-w-0 space-y-1"><h1 className="truncate text-2xl font-semibold tracking-tight">{agent.name}</h1>diff --git a/ui/src/pages/Agents.production.tsx b/ui/src/pages/Agents.production.tsxindex 7ba12ed9e4..a5eee50fc8 100644--- a/ui/src/pages/Agents.production.tsx+++ b/ui/src/pages/Agents.production.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { useState, useEffect, useMemo, lazy, Suspense } from "react";import { Link, useNavigate, useLocation } from "@/lib/router";import { useQuery } from "@tanstack/react-query";@@ -402,7 +403,7 @@ export function Agents() {leading={hasInvalidOrgChain ? (<AlertTriangle className="h-3.5 w-3.5 text-amber-500" aria-label="Invalid reporting chain" />) : (- <AgentStatusCapsule status={agent.status} />+ <AgentAvatar agent={agent} size={32} />)}secondaryRow={builtInCluster ? (@@ -655,7 +656,7 @@ function OrgTreeNode({{hasInvalidOrgChain ? (<AlertTriangle className="h-3.5 w-3.5 shrink-0 text-amber-500" aria-label="Invalid reporting chain" />) : (- <AgentStatusCapsule status={node.status} />+ <AgentAvatar agent={agent ?? node} size={24} />)}<div className="flex-1 min-w-0 flex flex-wrap items-center gap-2">{/* Name floor + `truncate` keeps the primary identifier readable; thediff --git a/ui/src/pages/Agents.tsx b/ui/src/pages/Agents.tsxindex 04473b93c5..e347a4250b 100644--- a/ui/src/pages/Agents.tsx+++ b/ui/src/pages/Agents.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { useAgentChatEnabled } from "../hooks/useAgentChatEnabled";import { useState, useEffect, useMemo, lazy, Suspense } from "react";import { Link, useNavigate, useLocation } from "@/lib/router";@@ -400,7 +401,7 @@ export function Agents({ initialView = "list" }: { initialView?: AgentsView } =leading={hasInvalidOrgChain ? (<AlertTriangle className="h-3.5 w-3.5 text-amber-500" aria-label="Invalid reporting chain" />) : (- <AgentStatusCapsule status={agent.status} />+ <AgentAvatar agent={agent} size={32} />)}secondaryRow={builtInCluster && (<div className="@5xl:hidden flex flex-wrap items-center gap-1.5">@@ -636,7 +637,7 @@ function OrgTreeNode({{hasInvalidOrgChain ? (<AlertTriangle className="h-3.5 w-3.5 shrink-0 text-amber-500" aria-label="Invalid reporting chain" />) : (- <AgentStatusCapsule status={node.status} />+ <AgentAvatar agent={agent ?? node} size={24} />)}<div className="flex-1 min-w-0 flex flex-wrap items-center gap-2">{/* Name floor + `truncate` keeps the primary identifier readable; thediff --git a/ui/src/pages/ApprovalDetail.tsx b/ui/src/pages/ApprovalDetail.tsxindex 972b920f5e..9491f5b4db 100644--- a/ui/src/pages/ApprovalDetail.tsx+++ b/ui/src/pages/ApprovalDetail.tsx@@ -1,3 +1,4 @@+import { AgentIdentity } from "@/components/AgentIdentity";import { useEffect, useMemo, useState } from "react";import { Link, useNavigate, useParams, useSearchParams } from "@/lib/router";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";@@ -213,8 +214,8 @@ export function ApprovalDetail() {{approval.requestedByAgentId && (<div className="flex items-center gap-2"><span className="text-muted-foreground text-xs">Requested by</span>- <Identity- name={agentNameById.get(approval.requestedByAgentId) ?? approval.requestedByAgentId.slice(0, 8)}+ <AgentIdentity+ agent={agents?.find((agent) => agent.id === approval.requestedByAgentId) ?? { id: approval.requestedByAgentId, name: "Agent" }}size="sm"/></div>@@ -331,8 +332,8 @@ export function ApprovalDetail() {<div className="flex items-center justify-between mb-1">{comment.authorAgentId ? (<Link to={`/agents/${comment.authorAgentId}`} className="hover:underline">- <Identity- name={agentNameById.get(comment.authorAgentId) ?? comment.authorAgentId.slice(0, 8)}+ <AgentIdentity+ agent={agents?.find((agent) => agent.id === comment.authorAgentId) ?? { id: comment.authorAgentId, name: "Agent" }}size="sm"/></Link>diff --git a/ui/src/pages/BoardChat.tsx b/ui/src/pages/BoardChat.tsxindex caf067fbe2..3901c926e9 100644--- a/ui/src/pages/BoardChat.tsx+++ b/ui/src/pages/BoardChat.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "@/components/AgentAvatar";import {useEffect,useLayoutEffect,@@ -29,7 +30,6 @@ import {AgentBubbleActionRow,agentBubbleDateLabel,} from "../components/AgentBubbleActionRow";-import { AgentIcon } from "../components/AgentIconPicker";import { cn, formatDateTime } from "../lib/utils";import type { FeedbackVoteValue } from "@paperclipai/shared";import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet";@@ -63,21 +63,8 @@ function agentInitials(name: string): string {* Icon-adjacent-to-name header rendered directly above an agent bubble —* the shared `[agent icon][agent name]` convention (PAP-105 / PAP-97).*/-function AgentBubbleHeader({ name, icon }: { name: string; icon: string | null }) {- return (- <div className="mb-1 flex items-center gap-1.5 pl-1">- <Avatar size="sm" className="shrink-0">- <AvatarFallback>- {icon ? (- <AgentIcon icon={icon} className="h-3.5 w-3.5" />- ) : (- agentInitials(name)- )}- </AvatarFallback>- </Avatar>- <span className="text-sm font-medium text-foreground">{name}</span>- </div>- );+function AgentBubbleHeader({ agent }: { agent: import("../components/AgentAvatar").AvatarAgent }) {+ return <div className="mb-1 flex items-center gap-1.5 pl-1"><AgentAvatar agent={agent} size={24} /><span className="text-sm font-medium text-foreground">{agent.name}</span></div>;}/** Agent-styled chat bubble containing the three-dot typing indicator. */@@ -776,7 +763,7 @@ export function BoardChat() {return (<><div className="flex flex-col items-start">- <AgentBubbleHeader name={ceoName} icon={ceoAgent.icon} />+ <AgentBubbleHeader agent={{ ...ceoAgent, name: ceoName }} /><divclassName={cn(boardChatBubbleShell,@@ -833,7 +820,7 @@ export function BoardChat() {const agentIconValue = agent?.icon ?? null;return (<div key={comment.id} className="flex flex-col items-start">- <AgentBubbleHeader name={agentName} icon={agentIconValue} />+ <AgentBubbleHeader agent={agent ?? { id: comment.authorAgentId ?? undefined, name: agentName }} /><divclassName={cn(boardChatBubbleShell,@@ -883,7 +870,7 @@ export function BoardChat() {{streamingText && (<div className="flex flex-col items-start">{ceoAgent && (- <AgentBubbleHeader name={ceoAgent.name} icon={ceoAgent.icon} />+ <AgentBubbleHeader agent={ceoAgent} />)}<divclassName={cn(diff --git a/ui/src/pages/CompanySkills.production.tsx b/ui/src/pages/CompanySkills.production.tsxindex 4413cd017a..cff79aaebd 100644--- a/ui/src/pages/CompanySkills.production.tsx+++ b/ui/src/pages/CompanySkills.production.tsx@@ -1,3 +1,5 @@+import { AgentIdentity } from "@/components/AgentIdentity";+import { AgentAvatar } from "@/components/AgentAvatar";import { useEffect, useMemo, useRef, useState, type SVGProps } from "react";import { Link, useNavigate, useParams, useSearchParams } from "@/lib/router";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";@@ -36,7 +38,6 @@ import { MarkdownEditor } from "../components/MarkdownEditor";import { PageSkeleton } from "../components/PageSkeleton";import { CopyText } from "../components/CopyText";import { Identity } from "../components/Identity";-import { AgentIcon } from "../components/AgentIconPicker";import { AgentMultiSelect } from "../components/AgentMultiSelect";import { useAdapterCapabilities } from "../adapters/use-adapter-capabilities";import {@@ -3238,7 +3239,7 @@ export function SkillDetailPage({const meta = attachAgentMetaById.get(agent.id);return (<div key={agent.id} className="flex items-center gap-3 border-b border-border py-3 text-sm last:border-b-0">- <AgentIcon icon={meta?.icon ?? null} className="h-4 w-4 shrink-0 text-muted-foreground" />+ <AgentAvatar agent={meta} size={16} className="h-4 w-4 shrink-0 text-muted-foreground"/><div className="min-w-0 flex-1"><div className="flex items-center gap-1.5"><span className="truncate font-medium">{agent.name}</span>@@ -3446,7 +3447,7 @@ export function SkillDetailPage({to={`/agents/${agent.urlKey}/skills`}className="flex items-center gap-2 rounded-md px-1.5 py-1 text-sm no-underline hover:bg-accent/40">- <AgentIcon icon={meta?.icon ?? null} className="h-4 w-4 shrink-0 text-muted-foreground" />+ <AgentAvatar agent={meta} size={16} className="h-4 w-4 shrink-0 text-muted-foreground"/><span className="min-w-0 flex-1 truncate text-foreground">{agent.name}</span>{meta?.paused ? (<Pause className="h-3 w-3 shrink-0 text-amber-500" aria-label="Paused" />@@ -3906,7 +3907,7 @@ function SkillPane({to={`/agents/${agent.urlKey}/skills`}className="group rounded-md border border-transparent p-2 no-underline hover:border-border hover:bg-accent/40">- <Identity name={agent.name} size="sm" />+ <AgentIdentity agent={agent} size="sm" /></Link>))}</div>diff --git a/ui/src/pages/CompanySkills.tsx b/ui/src/pages/CompanySkills.tsxindex 7e713884e7..58405951c6 100644--- a/ui/src/pages/CompanySkills.tsx+++ b/ui/src/pages/CompanySkills.tsx@@ -1,3 +1,5 @@+import { AgentIdentity } from "@/components/AgentIdentity";+import { AgentAvatar } from "@/components/AgentAvatar";import { useEffect, useMemo, useRef, useState, type SVGProps } from "react";import { Link, useNavigate, useParams, useSearchParams } from "@/lib/router";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";@@ -36,7 +38,6 @@ import { MarkdownEditor } from "../components/MarkdownEditor";import { PageSkeleton } from "../components/PageSkeleton";import { CopyText } from "../components/CopyText";import { Identity } from "../components/Identity";-import { AgentIcon } from "../components/AgentIconPicker";import { AgentMultiSelect } from "../components/AgentMultiSelect";import { useAdapterCapabilities } from "../adapters/use-adapter-capabilities";import { useStreamlinedUiEnabled } from "../hooks/useStreamlinedUiEnabled";@@ -3255,7 +3256,7 @@ export function SkillDetailPage({const meta = attachAgentMetaById.get(agent.id);return (<div key={agent.id} className="flex items-center gap-3 border-b border-border py-3 text-sm last:border-b-0">- <AgentIcon icon={meta?.icon ?? null} className="h-4 w-4 shrink-0 text-muted-foreground" />+ <AgentAvatar agent={meta} size={16} className="h-4 w-4 shrink-0 text-muted-foreground"/><div className="min-w-0 flex-1"><div className="flex items-center gap-1.5"><span className="truncate font-medium">{agent.name}</span>@@ -3463,7 +3464,7 @@ export function SkillDetailPage({to={`/agents/${agent.urlKey}/skills`}className="flex items-center gap-2 rounded-md px-1.5 py-1 text-sm no-underline hover:bg-accent/40">- <AgentIcon icon={meta?.icon ?? null} className="h-4 w-4 shrink-0 text-muted-foreground" />+ <AgentAvatar agent={meta} size={16} className="h-4 w-4 shrink-0 text-muted-foreground"/><span className="min-w-0 flex-1 truncate text-foreground">{agent.name}</span>{meta?.paused ? (<Pause className="h-3 w-3 shrink-0 text-amber-500" aria-label="Paused" />@@ -3924,7 +3925,7 @@ function SkillPane({to={`/agents/${agent.urlKey}/skills`}className="group rounded-md border border-transparent p-2 no-underline hover:border-border hover:bg-accent/40">- <Identity name={agent.name} size="sm" />+ <AgentIdentity agent={agent} size="sm" /></Link>))}</div>diff --git a/ui/src/pages/Costs.production.tsx b/ui/src/pages/Costs.production.tsxindex a314c5ffb6..bbb8b9a804 100644--- a/ui/src/pages/Costs.production.tsx+++ b/ui/src/pages/Costs.production.tsx@@ -1,3 +1,4 @@+import { AgentIdentity } from "@/components/AgentIdentity";import { useEffect, useMemo, useRef, useState, type ComponentType } from "react";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";import type {@@ -742,7 +743,7 @@ export function Costs() {) : (<span className="h-3 w-3 shrink-0" />)}- <Identity name={row.agentName ?? row.agentId} size="sm" />+ <AgentIdentity agent={{ id: row.agentId, name: row.agentName ?? row.agentId, appearance: row.agentAppearance }} size="sm" />{row.agentStatus === "terminated" ? <StatusBadge status="terminated" /> : null}</div><div className="text-right text-sm tabular-nums">diff --git a/ui/src/pages/Costs.tsx b/ui/src/pages/Costs.tsxindex c639fd6aef..e28cf08dd9 100644--- a/ui/src/pages/Costs.tsx+++ b/ui/src/pages/Costs.tsx@@ -1,3 +1,4 @@+import { AgentIdentity } from "@/components/AgentIdentity";import { useEffect, useMemo, useRef, useState, type ComponentType } from "react";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";import type {@@ -770,7 +771,7 @@ export function Costs({) : (<span className="h-3 w-3 shrink-0" />)}- <Identity name={row.agentName ?? row.agentId} size="sm" />+ <AgentIdentity agent={{ id: row.agentId, name: row.agentName ?? row.agentId, appearance: row.agentAppearance }} size="sm" />{row.agentStatus === "terminated" ? <StatusBadge status="terminated" /> : null}</div><div className="text-right text-sm tabular-nums">diff --git a/ui/src/pages/Dashboard.tsx b/ui/src/pages/Dashboard.tsxindex 1033c34b98..009f74c836 100644--- a/ui/src/pages/Dashboard.tsx+++ b/ui/src/pages/Dashboard.tsx@@ -1,3 +1,4 @@+import { AgentIdentity } from "../components/AgentIdentity";import { useEffect, useMemo, useRef, useState } from "react";import { useLocation } from "@/lib/router";import {@@ -24,7 +25,6 @@ import { StatusIcon } from "../components/StatusIcon";import { usePublishSharedQueryData, useSharedPollingQuery } from "../hooks/useSharedPolling";import { ActivityRow } from "../components/ActivityRow";-import { Identity } from "../components/Identity";import { timeAgo } from "../lib/timeAgo";import { cn, formatCents } from "../lib/utils";import { SHOW_TASK_PRIORITY_UI } from "../lib/ui-flags";@@ -537,7 +537,7 @@ export function Dashboard() {{issue.assigneeAgentId && (() => {const name = agentName(issue.assigneeAgentId);return name- ? <Identity name={name} size="sm" className="max-w-32" />+ ? <AgentIdentity agent={agents?.find(agent => agent.id === issue.assigneeAgentId) ?? { id: issue.assigneeAgentId ?? undefined, name }} size="sm" className="max-w-32" />: null;})()}</span>diff --git a/ui/src/pages/DesignGuide.tsx b/ui/src/pages/DesignGuide.tsxindex f4afbdb786..1c3f90942a 100644--- a/ui/src/pages/DesignGuide.tsx+++ b/ui/src/pages/DesignGuide.tsx@@ -5,6 +5,9 @@ import { announcementPreview, announcementAnimationPreview, announcementAnimatioimport { TaskDetailTasksPanel } from "@/components/task-detail/TaskDetailTasksPanel";import { AiConnectionDesignExamples } from "@/components/ai-connections/AiConnectionDesignExamples";import { SavedProviderKeySelect } from "../components/onboarding/SavedProviderKeySelect";+import { AgentAvatar } from "@/components/AgentAvatar";+import { AgentCharacter } from "@/components/AgentCharacter";+import { AGENT_PALETTE_IDS, appearanceForPalette } from "@paperclipai/shared";import { RepositoryEditor } from "@/components/RepositoryEditor";import { TaskChatRunnerActivityGroup } from "@/components/task-chat/TaskChatRunnerActivityGroup";import { TaskChatMarker } from "@/components/task-chat/TaskChatMarker";@@ -1507,20 +1510,29 @@ export function DesignGuide() {{/* ============================================================ */}{/* IDENTITY */}{/* ============================================================ */}- <Section title="Identity">+ <Section title="Agent personas">+ <SubSection title="Stable palette identities">+ <div className="flex flex-wrap gap-3">{AGENT_PALETTE_IDS.map(palette => <AgentAvatar key={palette} appearance={appearanceForPalette(palette)} size={48} label={palette} />)}</div>+ </SubSection>+ <SubSection title="Onboarding and live character">+ <p className="text-sm text-muted-foreground">Place one live character beside the agent name. Onboarding uses a larger padded frame. Onboarding and agent headers follow the pointer across the page; other placements track within their region. Full-page examples are in Storybook under Agents / Personas / Full pages.</p>+ <div className="flex gap-4"><AgentCharacter muted state="sleepy" motion="still" size={128} /><AgentCharacter size={128} /></div>+ </SubSection>+ </Section>+ <Section title="Human identity"><SubSection title="Sizes"><div className="flex items-center gap-6">- <Identity name="Agent Alpha" size="sm" />- <Identity name="Agent Alpha" />- <Identity name="Agent Alpha" size="lg" />+ <Identity name="Alex Morgan" size="sm" />+ <Identity name="Alex Morgan" />+ <Identity name="Alex Morgan" size="lg" /></div></SubSection><SubSection title="Initials derivation"><div className="flex flex-col gap-2">- <Identity name="CEO Agent" size="sm" />+ <Identity name="Casey Jordan" size="sm" /><Identity name="Alpha" size="sm" />- <Identity name="Quality Assurance Lead" size="sm" />+ <Identity name="Quinn Lee" size="sm" /></div></SubSection>diff --git a/ui/src/pages/Inbox.tsx b/ui/src/pages/Inbox.tsxindex c602c5c58a..59415263cb 100644--- a/ui/src/pages/Inbox.tsx+++ b/ui/src/pages/Inbox.tsx@@ -2693,7 +2693,7 @@ function StreamlinedInbox() {<BlockedInboxViewcompanyId={selectedCompanyId!}searchQuery={searchQuery}- agentNameById={agentById}+ agentNameById={agentById} agents={agents}userLabelById={companyUserLabelMap}issueLinkState={issueLinkState}groupBy={blockedGroupBy}@@ -2906,6 +2906,8 @@ function StreamlinedInbox() {defaultProjectWorkspaceIdByProjectId,})}assigneeName={agentName(issue.assigneeAgentId)}+ assigneeAgent={agents?.find((agent) => agent.id === issue.assigneeAgentId)}+ creatorAgent={agents?.find((agent) => agent.id === issue.createdByAgentId)}assigneeUserName={formatAssigneeUserLabel(issue.assigneeUserId, currentUserId, companyUserLabelMap)?? assigneeUserProfile?.labeldiff --git a/ui/src/pages/IssueDetail.tsx b/ui/src/pages/IssueDetail.tsxindex 15d14bef1f..5576069196 100644--- a/ui/src/pages/IssueDetail.tsx+++ b/ui/src/pages/IssueDetail.tsx@@ -1,3 +1,5 @@+import { AgentAvatar } from "@/components/AgentAvatar";+import { AgentIdentity } from "@/components/AgentIdentity";import { clearLegacyChatMessageRequests } from "@/lib/chat-message-request";import { agentChatDraft } from "@/lib/agent-chat-draft";import { Settings as ChatSettings } from "lucide-react";@@ -196,7 +198,6 @@ import {import { IssueSiblingNavigation } from "../components/IssueSiblingNavigation";import type { MarkdownExternalReferenceMap } from "../components/MarkdownBody";import { IssuesList } from "../components/IssuesList";-import { AgentIcon } from "../components/AgentIconPicker";import { IssueReferenceActivitySummary } from "../components/IssueReferenceActivitySummary";import { IssueFieldChangeReceipt } from "../components/IssueFieldChangeReceipt";import { IssueWriteDenialNotice } from "../components/IssueWriteDenialNotice";@@ -663,7 +664,7 @@ function ActorIdentity({const id = evt.actorId;if (evt.actorType === "agent") {const agent = agentMap.get(id);- return <Identity name={agent?.name ?? id.slice(0, 8)} size="sm" />;+ return <AgentIdentity agent={agent ?? { id, name: id.slice(0, 8) }} size="sm" />;}if (evt.actorType === "system") return <Identity name="System" size="sm" />;if (evt.actorType === "user") {@@ -680,6 +681,7 @@ function ActorIdentity({}export type AttributionActor = {+ appearance?: Agent["appearance"];kind: "agent" | "user";id: string;name: string;@@ -710,36 +712,26 @@ function AttributionAvatar({return (<Tooltip><TooltipTrigger asChild>- <Avatar- size="xs"- shape={actor.kind === "agent" ? "square" : "circle"}- aria-label={accessibleLabel}- data-testid={`issue-${testIdLabel}-avatar`}- className="ring-2 ring-background"- >- {actor.avatarUrl ? (- <AvatarImage src={actor.avatarUrl} alt="" />- ) : null}- <AvatarFallback>{attributionInitials(actor.name)}</AvatarFallback>- </Avatar>+ <span aria-label={accessibleLabel} data-testid={`issue-${testIdLabel}-avatar`}>+ {actor.kind === "agent" ? <AgentAvatar agent={actor} size={20} /> : (+ <Avatar size="xs" className="ring-2 ring-background">+ {actor.avatarUrl ? <AvatarImage src={actor.avatarUrl} alt="" /> : null}+ <AvatarFallback>{attributionInitials(actor.name)}</AvatarFallback>+ </Avatar>+ )}+ </span></TooltipTrigger><TooltipContent side="top" sideOffset={6} className="px-2 py-1.5"><divclassName="flex items-center gap-2"data-testid={`issue-${testIdLabel}-tooltip`}>- <Avatar- size="sm"- shape={actor.kind === "agent" ? "square" : "circle"}- className="ring-1 ring-background/30"- >- {actor.avatarUrl ? (- <AvatarImage src={actor.avatarUrl} alt="" />- ) : null}- <AvatarFallback className="bg-background/20 text-background">- {attributionInitials(actor.name)}- </AvatarFallback>- </Avatar>+ {actor.kind === "agent" ? <AgentAvatar agent={actor} size={32} /> : (+ <Avatar size="sm" className="ring-1 ring-background/30">+ {actor.avatarUrl ? <AvatarImage src={actor.avatarUrl} alt="" /> : null}+ <AvatarFallback>{attributionInitials(actor.name)}</AvatarFallback>+ </Avatar>+ )}<div className="min-w-0"><div className="text-(length:--text-nano) font-medium uppercase leading-none text-background/70">{label}@@ -777,6 +769,7 @@ function IssueAttributionByline({? {kind: "agent",id: issue.assigneeAgentId,+ appearance: agentMap.get(issue.assigneeAgentId)?.appearance,name:agentMap.get(issue.assigneeAgentId)?.name ??issue.assigneeAgentId.slice(0, 8),@@ -798,6 +791,7 @@ function IssueAttributionByline({? {kind: "agent",id: originatingActor.id,+ appearance: agentMap.get(originatingActor.id)?.appearance,name:agentMap.get(originatingActor.id)?.name ??originatingActor.id.slice(0, 8),@@ -7704,7 +7698,8 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS? (agentMap.get(issue.createdByAgentId)?.name ??"Agent"): undefined,- agentIcon: issue.createdByAgentId+ agent: issue.createdByAgentId ? agentMap.get(issue.createdByAgentId) ?? { id: issue.createdByAgentId } : undefined,+ agentIcon: issue.createdByAgentId? agentMap.get(issue.createdByAgentId)?.icon: undefined,createdAt: issue.createdAt,diff --git a/ui/src/pages/LegacyInbox.tsx b/ui/src/pages/LegacyInbox.tsxindex 4f82668426..0c94ab9907 100644--- a/ui/src/pages/LegacyInbox.tsx+++ b/ui/src/pages/LegacyInbox.tsx@@ -2772,6 +2772,8 @@ export function Inbox() {defaultProjectWorkspaceIdByProjectId,})}assigneeName={agentName(issue.assigneeAgentId)}+ assigneeAgent={agents?.find((agent) => agent.id === issue.assigneeAgentId)}+ creatorAgent={agents?.find((agent) => agent.id === issue.createdByAgentId)}assigneeUserName={formatAssigneeUserLabel(issue.assigneeUserId, currentUserId, companyUserLabelMap)?? assigneeUserProfile?.labeldiff --git a/ui/src/pages/OrgChart.production.tsx b/ui/src/pages/OrgChart.production.tsxindex d394489b43..87df93b4e5 100644--- a/ui/src/pages/OrgChart.production.tsx+++ b/ui/src/pages/OrgChart.production.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { useEffect, useRef, useState, useMemo, useCallback } from "react";import { Link, useNavigate } from "@/lib/router";import { useQuery } from "@tanstack/react-query";@@ -10,7 +11,6 @@ import { Card } from "@/components/ui/card";import { Button } from "@/components/ui/button";import { EmptyState } from "../components/EmptyState";import { PageSkeleton } from "../components/PageSkeleton";-import { AgentIcon } from "../components/AgentIconPicker";import { Download, Maximize2, Minus, Network, Plus, Upload } from "lucide-react";import { AGENT_ROLE_LABELS, type Agent } from "@paperclipai/shared";import { useCloudInstance } from "@/hooks/useCloudInstance";@@ -598,7 +598,7 @@ export function OrgChart() {{/* Agent icon + status dot */}<div className="relative shrink-0"><div className="w-9 h-9 rounded-full bg-muted flex items-center justify-center">- <AgentIcon icon={agent?.icon} className="h-4.5 w-4.5 text-foreground/70" />+ <AgentAvatar agent={agent} size={16} className="h-4.5 w-4.5 text-foreground/70"/></div><spanclassName="absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-card"diff --git a/ui/src/pages/OrgChart.tsx b/ui/src/pages/OrgChart.tsxindex 1eb8e35ce6..a9fe1193e4 100644--- a/ui/src/pages/OrgChart.tsx+++ b/ui/src/pages/OrgChart.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { useEffect, useRef, useState, useMemo, useCallback } from "react";import { Link, useNavigate } from "@/lib/router";import { useQuery } from "@tanstack/react-query";@@ -10,7 +11,6 @@ import { Card } from "@/components/ui/card";import { Button } from "@/components/ui/button";import { EmptyState } from "../components/EmptyState";import { PageSkeleton } from "../components/PageSkeleton";-import { AgentIcon } from "../components/AgentIconPicker";import { Download, Maximize2, Minus, Network, Plus, Upload } from "lucide-react";import { AGENT_ROLE_LABELS, type Agent } from "@paperclipai/shared";import { useCloudInstance } from "@/hooks/useCloudInstance";@@ -630,7 +630,7 @@ export function OrgChart({ orgTree: providedOrgTree, agents: providedAgents, emb{/* Agent icon + status dot */}<div className="relative shrink-0"><div className="w-9 h-9 rounded-full bg-muted flex items-center justify-center">- <AgentIcon icon={agent?.icon} className="h-4.5 w-4.5 text-foreground/70" />+ <AgentAvatar agent={agent} size={16} className="h-4.5 w-4.5 text-foreground/70"/></div><spanclassName="absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-card"diff --git a/ui/src/pages/PipelineSettings.tsx b/ui/src/pages/PipelineSettings.tsxindex 5e53515a63..edf5a75588 100644--- a/ui/src/pages/PipelineSettings.tsx+++ b/ui/src/pages/PipelineSettings.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type FormEvent, type ReactNode } from "react";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";import {@@ -61,7 +62,6 @@ import { PageSkeleton } from "../components/PageSkeleton";import { MarkdownEditor, type MarkdownEditorRef } from "../components/MarkdownEditor";import { RoutineVariablesEditor, RoutineVariablesHint } from "../components/RoutineVariablesEditor";import { PipelineStageHistoryPanel } from "../components/PipelineStageHistoryPanel";-import { AgentIcon } from "../components/AgentIconPicker";import { InlineEntitySelector, type InlineEntityOption } from "../components/InlineEntitySelector";import { Button } from "@/components/ui/button";import {@@ -2825,7 +2825,7 @@ export function PipelineSettings() {const agent = option.id.startsWith("agent:") ? agentById.get(option.id.slice("agent:".length)) : null;return (<>- {agent ? <AgentIcon icon={agent.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" /> : null}+ {agent ? <AgentAvatar agent={agent} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/> : null}<span className="truncate">{option.label}</span></>);@@ -2835,7 +2835,7 @@ export function PipelineSettings() {const agent = option.id.startsWith("agent:") ? agentById.get(option.id.slice("agent:".length)) : null;return (<>- {agent ? <AgentIcon icon={agent.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" /> : null}+ {agent ? <AgentAvatar agent={agent} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/> : null}<span className="truncate">{option.label}</span></>);@@ -2916,7 +2916,7 @@ export function PipelineSettings() {: null;return (<>- {agent ? <AgentIcon icon={agent.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" /> : null}+ {agent ? <AgentAvatar agent={agent} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/> : null}<span className="truncate">{option.label}</span></>);@@ -2927,7 +2927,7 @@ export function PipelineSettings() {const agent = agentId ? agentById.get(agentId) : null;return (<>- {agent ? <AgentIcon icon={agent.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" /> : null}+ {agent ? <AgentAvatar agent={agent} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/> : null}<span className="truncate">{option.label}</span></>);@@ -3056,7 +3056,7 @@ export function PipelineSettings() {) : null}</div><div className="flex items-center gap-2 text-sm text-muted-foreground">- <AgentIcon icon={selectedAutomationAgent.icon} className="h-4 w-4 shrink-0" />+ <AgentAvatar agent={selectedAutomationAgent} size={16} className="h-4 w-4 shrink-0"/><span>{selectedAutomationAgent.name} runs this step automatically.</span></div><FieldRow label="Issue title">@@ -3143,6 +3143,7 @@ export function PipelineSettings() {hasAutomation={Boolean(detail.routineId && detail.assigneeAgentId)}agentName={automationAgent?.name ?? null}agentIcon={automationAgent?.icon ?? null}+ agent={automationAgent ?? undefined}secrets={secretsQuery.data ?? []}secretsLoading={secretsQuery.isLoading}value={stageEnv}diff --git a/ui/src/pages/Pipelines.tsx b/ui/src/pages/Pipelines.tsxindex 926ea7f386..8c1a4ef4e4 100644--- a/ui/src/pages/Pipelines.tsx+++ b/ui/src/pages/Pipelines.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { useCallback, useEffect, useMemo, useState, type FormEvent, type ReactNode } from "react";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";import { groupWarningsByStage, LOW_TRUST_REVIEW_PRESET } from "@paperclipai/shared";@@ -84,7 +85,6 @@ import { instanceSettingsApi } from "../api/instanceSettings";import { issuesApi } from "../api/issues";import { projectsApi } from "../api/projects";import { EmptyState } from "../components/EmptyState";-import { AgentIcon } from "../components/AgentIconPicker";import { IssueChatThread } from "../components/IssueChatThread";import { MarkdownBody } from "../components/MarkdownBody";import { PageSkeleton } from "../components/PageSkeleton";@@ -1363,7 +1363,7 @@ function PipelineBoardColumn({className="inline-flex max-w-full items-center gap-1 rounded-full border border-border px-2 py-0.5 text-xs font-medium text-muted-foreground hover:text-foreground"title={`Edit ${stage.name} automation`}>- <AgentIcon icon={automationAgent.icon} className="h-3.5 w-3.5 shrink-0" />+ <AgentAvatar agent={automationAgent} size={16} className="h-3.5 w-3.5 shrink-0"/><span className="truncate">{automationAgent.name}</span></Link>) : null}diff --git a/ui/src/pages/Routines.production.tsx b/ui/src/pages/Routines.production.tsxindex 4ec6f10503..691ec369d2 100644--- a/ui/src/pages/Routines.production.tsx+++ b/ui/src/pages/Routines.production.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { startTransition, useEffect, useMemo, useRef, useState } from "react";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";import { Link, useNavigate, useSearchParams } from "@/lib/router";@@ -25,7 +26,6 @@ import { EmptyState } from "../components/EmptyState";import { IssuesList } from "../components/IssuesList";import { PageSkeleton } from "../components/PageSkeleton";import { PageTabBar } from "../components/PageTabBar";-import { AgentIcon } from "../components/AgentIconPicker";import { InlineEntitySelector, type InlineEntityOption } from "../components/InlineEntitySelector";import { MarkdownEditor, type MarkdownEditorRef, type MentionOption } from "../components/MarkdownEditor";import { RoutineListRow, nextRoutineStatus } from "../components/RoutineList";@@ -1042,7 +1042,7 @@ export function Routines() {option ? (currentAssignee ? (<>- <AgentIcon icon={currentAssignee.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ <AgentAvatar agent={currentAssignee} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/><span className="truncate">{option.label}</span></>) : (@@ -1057,7 +1057,7 @@ export function Routines() {const assignee = agentById.get(option.id);return (<>- {assignee ? <AgentIcon icon={assignee.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" /> : null}+ {assignee ? <AgentAvatar agent={assignee} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/> : null}<span className="truncate">{option.label}</span></>);diff --git a/ui/src/pages/Routines.tsx b/ui/src/pages/Routines.tsxindex e7c03b1542..978a7e78ea 100644--- a/ui/src/pages/Routines.tsx+++ b/ui/src/pages/Routines.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { startTransition, useEffect, useMemo, useRef, useState } from "react";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";import { Link, Navigate, useNavigate, useSearchParams } from "@/lib/router";@@ -24,7 +25,6 @@ import { EmptyState } from "../components/EmptyState";import { IssuesList } from "../components/IssuesList";import { PageSkeleton } from "../components/PageSkeleton";import { PageTabBar } from "../components/PageTabBar";-import { AgentIcon } from "../components/AgentIconPicker";import { InlineEntitySelector, type InlineEntityOption } from "../components/InlineEntitySelector";import { MarkdownEditor, type MarkdownEditorRef, type MentionOption } from "../components/MarkdownEditor";import { RoutineListRow, nextRoutineStatus } from "../components/RoutineList";@@ -1075,7 +1075,7 @@ export function Routines() {option ? (currentAssignee ? (<>- <AgentIcon icon={currentAssignee.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ <AgentAvatar agent={currentAssignee} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/><span className="truncate">{option.label}</span></>) : (@@ -1090,7 +1090,7 @@ export function Routines() {const assignee = agentById.get(option.id);return (<>- {assignee ? <AgentIcon icon={assignee.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" /> : null}+ {assignee ? <AgentAvatar agent={assignee} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/> : null}<span className="truncate">{option.label}</span></>);diff --git a/ui/src/pages/Search.tsx b/ui/src/pages/Search.tsxindex b4cc5a4c59..d1e42436df 100644--- a/ui/src/pages/Search.tsx+++ b/ui/src/pages/Search.tsx@@ -328,8 +328,8 @@ export function Search() {placeholderData: (previousData) => previousData,});- const agentsById = useMemo<ReadonlyMap<string, Pick<Agent, "id" | "name">>>(() => {- const map = new Map<string, Pick<Agent, "id" | "name">>();+ const agentsById = useMemo<ReadonlyMap<string, Pick<Agent, "id" | "name" | "appearance">>>(() => {+ const map = new Map<string, Pick<Agent, "id" | "name" | "appearance">>();for (const agent of agents) map.set(agent.id, agent);return map;}, [agents]);@@ -732,7 +732,7 @@ interface SearchTabContentProps {sortLabel: string;zeroResultsSlot: ReactNode;isFetching: boolean;- agentsById: ReadonlyMap<string, Pick<Agent, "id" | "name">>;+ agentsById: ReadonlyMap<string, Pick<Agent, "id" | "name" | "appearance">>;}function SearchTabContent({diff --git a/ui/src/pages/SkillStudio.tsx b/ui/src/pages/SkillStudio.tsxindex 112bd5539f..f5a07cf30f 100644--- a/ui/src/pages/SkillStudio.tsx+++ b/ui/src/pages/SkillStudio.tsx@@ -1,3 +1,4 @@+import { AgentIdentity } from "@/components/AgentIdentity";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";import {@@ -2958,7 +2959,7 @@ function AgentPicker({<PopoverTrigger asChild><Button variant="outline" size="sm">{selectedAgent ? (- <Identity name={selectedAgent.name} size="xs" />+ <AgentIdentity agent={selectedAgent} size="xs" />) : (<span className="text-muted-foreground">Pick an agent</span>)}@@ -2991,7 +2992,7 @@ function AgentPicker({)}aria-hidden/>- <Identity name={agent.name} size="xs" />+ <AgentIdentity agent={agent} size="xs" />{!selectable && (<Badge variant="secondary" className="ml-auto">Paused@@ -3118,7 +3119,7 @@ function RunDetailView({<div className="min-h-0 flex-1 space-y-3 overflow-auto p-3"><div className="flex flex-wrap items-center gap-2"><StatusBadge status={runBadgeStatus(detail.status)} />- <Identity name={agentName} size="xs" />+ <AgentIdentity agent={agent ?? { id: detail.agentId, name: agentName }} size="xs" />{removed && <Badge variant="secondary">removed</Badge>}<span className="font-mono text-xs text-muted-foreground">v{detail.skillVersion.revisionNumber}diff --git a/ui/src/pages/StatusCards/SummarizerAgentSelect.tsx b/ui/src/pages/StatusCards/SummarizerAgentSelect.tsxindex c738a22c8e..1c97b1fe52 100644--- a/ui/src/pages/StatusCards/SummarizerAgentSelect.tsx+++ b/ui/src/pages/StatusCards/SummarizerAgentSelect.tsx@@ -1,8 +1,8 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { useMemo } from "react";import { useQuery } from "@tanstack/react-query";import { agentsApi } from "@/api/agents";-import { AgentIcon } from "@/components/AgentIconPicker";import { InlineEntitySelector, type InlineEntityOption } from "@/components/InlineEntitySelector";import { isAgentTaskTarget } from "@/lib/company-members";import { queryKeys } from "@/lib/queryKeys";@@ -48,7 +48,7 @@ export function SummarizerAgentSelect({const agent = option.id.startsWith("agent:") ? agentById.get(option.id.slice("agent:".length)) : null;return (<>- {agent ? <AgentIcon icon={agent.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" /> : null}+ {agent ? <AgentAvatar agent={agent} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/> : null}<span className="truncate">{option.label}</span></>);diff --git a/ui/src/pages/apps/app-detail/PermissionsPanel.tsx b/ui/src/pages/apps/app-detail/PermissionsPanel.tsxindex b0d64ad447..24c1454120 100644--- a/ui/src/pages/apps/app-detail/PermissionsPanel.tsx+++ b/ui/src/pages/apps/app-detail/PermissionsPanel.tsx@@ -1,8 +1,8 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { useEffect, useMemo, useRef, useState, type ReactNode } from "react";import { Ban, Check, FlaskConical, Loader2, RefreshCw, Search, ShieldQuestion } from "lucide-react";import type { Agent, ToolCatalogEntry, ToolConnectionCapabilities } from "@paperclipai/shared";import { useSearchParams } from "@/lib/router";-import { AgentIcon } from "@/components/AgentIconPicker";import { AgentMultiSelect } from "@/components/AgentMultiSelect";import { InlineBanner } from "@/components/InlineBanner";import { Button } from "@/components/ui/button";@@ -183,7 +183,7 @@ function AgentAccessSection({<div className="space-y-0.5">{selectedAgents.map((agent) => (<div key={agent.id} className="flex items-center gap-2 px-1.5 py-1 text-sm">- <AgentIcon icon={agent.icon ?? null} className="h-4 w-4 shrink-0 text-muted-foreground" />+ <AgentAvatar agent={agent} size={16} className="h-4 w-4 shrink-0 text-muted-foreground"/><span className="min-w-0 flex-1 truncate text-foreground">{agent.name}</span></div>))}diff --git a/ui/src/pages/audit/AuditFeed.production.tsx b/ui/src/pages/audit/AuditFeed.production.tsxindex 94426bfcda..375f112824 100644--- a/ui/src/pages/audit/AuditFeed.production.tsx+++ b/ui/src/pages/audit/AuditFeed.production.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { useEffect, useMemo, useState } from "react";import { useInfiniteQuery, useQuery } from "@tanstack/react-query";import { Download, ScrollText, ShieldAlert } from "lucide-react";@@ -15,7 +16,6 @@ import {} from "@/components/ui/select";import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";import { Identity } from "@/components/Identity";-import { AgentIcon } from "@/components/AgentIconPicker";import { cn, relativeTime } from "@/lib/utils";import { queryKeys } from "@/lib/queryKeys";import { formatActivityVerb } from "@/lib/activity-format";@@ -112,7 +112,7 @@ function AuditActor({return (<span className="inline-flex min-w-0 items-center gap-1.5" title={agent.name}><span className="flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground">- <AgentIcon icon={agent.icon} className="h-3 w-3" />+ <AgentAvatar agent={agent} size={16} className="h-3 w-3"/></span><span className="truncate font-medium text-foreground">{agent.name}</span></span>diff --git a/ui/src/pages/audit/AuditFeed.tsx b/ui/src/pages/audit/AuditFeed.tsxindex 2637f161d4..525ddc90a8 100644--- a/ui/src/pages/audit/AuditFeed.tsx+++ b/ui/src/pages/audit/AuditFeed.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { useEffect, useMemo, useState } from "react";import { useInfiniteQuery, useQuery } from "@tanstack/react-query";import { Download, ScrollText, ShieldAlert } from "lucide-react";@@ -15,7 +16,6 @@ import {} from "@/components/ui/select";import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";import { Identity } from "@/components/Identity";-import { AgentIcon } from "@/components/AgentIconPicker";import { cn, relativeTime } from "@/lib/utils";import { queryKeys } from "@/lib/queryKeys";import { formatActivityVerb } from "@/lib/activity-format";@@ -122,7 +122,7 @@ function AuditActor({return (<span className="inline-flex min-w-0 items-center gap-1.5" title={agent.name}><span className="flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground">- <AgentIcon icon={agent.icon} className="h-3 w-3" />+ <AgentAvatar agent={agent} size={16} className="h-3 w-3"/></span><span className="truncate font-medium text-foreground">{agent.name}</span></span>diff --git a/ui/src/pages/secrets/proposal-review.tsx b/ui/src/pages/secrets/proposal-review.tsxindex a5af79499c..7b79a07012 100644--- a/ui/src/pages/secrets/proposal-review.tsx+++ b/ui/src/pages/secrets/proposal-review.tsx@@ -1,3 +1,4 @@+import { AgentAvatar } from "@/components/AgentAvatar";import { useCallback, useMemo, useState } from "react";import { useMutation, useQueryClient } from "@tanstack/react-query";import { Copy, Fingerprint, KeyRound, Link2, ShieldAlert, Variable, ServerCog } from "lucide-react";@@ -6,7 +7,6 @@ import type {SecretProposalAgentRef,SecretProposalView,} from "@paperclipai/shared";-import { AgentIcon } from "@/components/AgentIconPicker";import { Badge } from "@/components/ui/badge";import { Button } from "@/components/ui/button";import { Input } from "@/components/ui/input";@@ -126,7 +126,7 @@ export function AgentRefChip({}) {return (<span className={cn("inline-flex min-w-0 items-center gap-1", className)}>- <AgentIcon icon={agent.icon ?? null} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ <AgentAvatar agent={agent} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/><span className="min-w-0 truncate">{agent.name}</span></span>);diff --git a/ui/storybook/.storybook/main.ts b/ui/storybook/.storybook/main.tsindex 0192e08658..0357165753 100644--- a/ui/storybook/.storybook/main.ts+++ b/ui/storybook/.storybook/main.ts@@ -3,6 +3,7 @@ import { fileURLToPath } from "node:url";import type { StorybookConfig } from "@storybook/react-vite";import tailwindcss from "@tailwindcss/vite";import { mergeConfig } from "vite";+import { storybookAgentAvatarAssets } from "../../../scripts/storybook-agent-avatar-assets.mjs";const storybookConfigDir = path.dirname(fileURLToPath(import.meta.url));@@ -17,9 +18,10 @@ const config: StorybookConfig = {docs: {autodocs: true,},- viteFinal: async (baseConfig) =>+ viteFinal: async (baseConfig, { configType }) =>mergeConfig(baseConfig, {- plugins: [tailwindcss()],+ plugins: [tailwindcss(), storybookAgentAvatarAssets()],+ server: { proxy: { "/api/agent-avatars": { target: process.env.PAPERCLIP_STORYBOOK_API_URL ?? "http://localhost:3100", changeOrigin: true } } },optimizeDeps: { include: ["motion/react", "react", "react-dom"] },resolve: {// Storybook's core and the react-vite builder each resolve their own@@ -29,6 +31,9 @@ const config: StorybookConfig = {// The app's own dev server hoists one React and never hit this.dedupe: ["react", "react-dom"],alias: {+ ...(configType === "PRODUCTION" ? {+ "@/lib/agent-avatar-url": path.resolve(storybookConfigDir, "../fixtures/agent-avatar-url.ts"),+ } : {}),"@": path.resolve(storybookConfigDir, "../../src"),lexical: path.resolve(storybookConfigDir, "../../node_modules/lexical/dist/Lexical.mjs"),// Vite's bundled `node:crypto` polyfill omits `createHash`, whichdiff --git a/ui/storybook/fixtures/agent-avatar-url.test.ts b/ui/storybook/fixtures/agent-avatar-url.test.tsnew file mode 100644index 0000000000..f1aaebf8d0--- /dev/null+++ b/ui/storybook/fixtures/agent-avatar-url.test.ts@@ -0,0 +1,27 @@+import { describe, expect, it } from "vitest";+import { AGENT_AVATAR_SIZES, AGENT_PALETTE_IDS, CHARACTER_STATES, appearanceForPalette } from "@paperclipai/shared";+import { agentAvatarUrl as productionUrl } from "../../src/lib/agent-avatar-url";+import { agentAvatarUrl } from "./agent-avatar-url";++describe("packaged Storybook avatar URLs", () => {+ it("keeps production on the public API and resolves preview assets under a branch prefix", () => {+ const appearance = appearanceForPalette("bubblegum-sky");+ expect(productionUrl(appearance, 24, 2)).toBe("/api/agent-avatars/cap-v1/bubblegum-sky/rest.png?size=24&scale=2");+ expect(new URL(agentAvatarUrl(appearance, 24, 2), "https://example.com/branches/personas/builds/123/iframe.html").href)+ .toBe("https://example.com/branches/personas/builds/123/agent-avatar-images/cap-v1/bubblegum-sky/rest-24-2.png");+ expect(agentAvatarUrl(appearance)).toBe("./agent-avatar-images/cap-v1/bubblegum-sky/rest-512-1.png");+ });++ it("gives every finite preset a distinct filename, retaining logical size separately from density", () => {+ const paths = new Set<string>();+ for (const palette of AGENT_PALETTE_IDS) for (const pose of CHARACTER_STATES)+ for (const size of AGENT_AVATAR_SIZES) for (const scale of [1, 2] as const) {+ paths.add(agentAvatarUrl(appearanceForPalette(palette), size, scale, pose));+ paths.add(agentAvatarUrl(appearanceForPalette(palette), size, scale, pose, true));+ }+ expect(paths.size).toBe((AGENT_PALETTE_IDS.length + 1) * CHARACTER_STATES.length * AGENT_AVATAR_SIZES.length * 2);+ expect(agentAvatarUrl(appearanceForPalette("arctic-blue"), 24, 2))+ .not.toBe(agentAvatarUrl(appearanceForPalette("arctic-blue"), 48, 1));+ expect([...paths].every(path => !path.includes("?") && path.startsWith("./agent-avatar-images/cap-v1/"))).toBe(true);+ });+});diff --git a/ui/storybook/fixtures/agent-avatar-url.ts b/ui/storybook/fixtures/agent-avatar-url.tsnew file mode 100644index 0000000000..efbe5c3ce5--- /dev/null+++ b/ui/storybook/fixtures/agent-avatar-url.ts@@ -0,0 +1,8 @@+import { agentAvatarUrl as apiAvatarUrl } from "@paperclipai/shared";++/** Relative to iframe.html, including when a preview is hosted under a branch prefix. */+export const agentAvatarUrl: typeof apiAvatarUrl = (...args) => {+ const url = new URL(apiAvatarUrl(...args), "https://storybook.invalid");+ const preset = url.pathname.slice("/api/agent-avatars/".length).replace(/\.png$/, "");+ return `./agent-avatar-images/${preset}-${url.searchParams.get("size")}-${url.searchParams.get("scale")}.png`;+};diff --git a/ui/storybook/stories/agent-persona-pages.stories.tsx b/ui/storybook/stories/agent-persona-pages.stories.tsxnew file mode 100644index 0000000000..0ae8a72759--- /dev/null+++ b/ui/storybook/stories/agent-persona-pages.stories.tsx@@ -0,0 +1,120 @@+import { agentAvatarUrl } from "@/lib/agent-avatar-url";+import { useEffect, useState, useRef } from "react";+import type { Meta, StoryObj } from "@storybook/react-vite";+import { useQueryClient } from "@tanstack/react-query";+import { Route, Routes, useLocation, useNavigate } from "@/lib/router";+import { useCompany } from "@/context/CompanyContext";+import { PluginLauncherProvider } from "@/plugins/launchers";+import { Layout } from "@/components/Layout";+import { Agents } from "@/pages/Agents";+import { AgentDetail } from "@/pages/AgentDetail";+import { IssueDetail } from "@/pages/IssueDetail";+import { Dashboard } from "@/pages/Dashboard";+import { NewAgent } from "@/pages/NewAgent";+import { AgentBasicsDialog } from "@/components/new-agent/AgentBasicsDialog";+import { queryKeys } from "@/lib/queryKeys";+import { resolveAgentAppearance } from "@paperclipai/shared";+import { storybookAgents, storybookIssues, storybookActivityEvents, storybookLiveRuns, storybookDashboardSummary } from "../fixtures/paperclipData";++const companyId = "company-storybook";+const agents = storybookAgents.map(agent => {+ const appearance = resolveAgentAppearance(agent.appearance, agent.id);+ return { ...agent, appearance, avatarUrl: agentAvatarUrl(appearance), chainOfCommand: [], access: { canAssignTasks: true, taskAssignSource: "explicit_grant", membership: null, grants: [] } };+});+const liveRuns = storybookLiveRuns.map(run => ({ ...run, agentAppearance: agents.find(agent => agent.id === run.agentId)?.appearance }));+const issue = { ...storybookIssues[0], assigneeAgentId: agents[0].id, status: "in_progress" };++/** Real route components and navigation; all domain data stays in Storybook. */+function installPageFixtures() {+ const previous = window.fetch;+ window.fetch = async (input, init) => {+ const url = new URL(typeof input === "string" ? input : input instanceof URL ? input.href : input.url, location.origin);+ const path = url.pathname;+ if (!path.startsWith("/api/") || path.startsWith("/api/agent-avatars/")) return previous(input, init);+ const json = (data: unknown) => Response.json(data);+ if (path === "/api/cli-auth/me") return json({ source: "local_implicit", isInstanceAdmin: true, companyIds: [companyId], memberships: [] });+ if (path === "/api/health") return json({ status: "ok", deploymentMode: "local_trusted", authReady: true, bootstrapStatus: "ready" });+ if (path === "/api/instance/settings") return json({ experimental: {} });+ if (path === "/api/instance/settings/experimental") return previous(input, init);+ if (path.endsWith("/resource-memberships/me")) return json({ projectMemberships: {}, agentMemberships: {}, starredProjectIds: [], starredAgentIds: [], starredDocumentIds: [], projectStarredAt: {}, agentStarredAt: {}, documentStarredAt: {}, updatedAt: null });+ if (path === `/api/companies/${companyId}/agents`) return json(agents);+ if (path.endsWith("/dashboard")) return json(storybookDashboardSummary);+ if (path === `/api/companies/${companyId}/activity`) return json(storybookActivityEvents);+ if (path === `/api/companies/${companyId}/live-runs`) return json(liveRuns);+ const agentMatch = path.match(/^\/api\/agents\/([^/]+)(?:\/(.*))?$/);+ if (agentMatch) {+ const agent = agents.find(item => item.id === agentMatch[1] || item.urlKey === agentMatch[1]) ?? agents[0];+ if (!agentMatch[2]) return json(agent);+ if (agentMatch[2] === "runtime-state") return json({ agentId: agent.id, companyId, adapterType: agent.adapterType, stateJson: {}, sessionId: null, sessionDisplayId: null, totalInputTokens: 42000, totalOutputTokens: 8200, totalCostCents: 340, lastRunStatus: "succeeded" });+ if (agentMatch[2] === "skills") return json({ desiredSkills: [], actualSkills: [], errors: [] });+ if (agentMatch[2] === "instructions-bundle") return previous(input, init);+ return json([]);+ }+ const issueMatch = path.match(/^\/api\/issues\/([^/]+)(?:\/(.*))?$/);+ if (issueMatch) {+ const item = storybookIssues.find(row => row.id === issueMatch[1] || row.identifier === issueMatch[1]) ?? issue;+ if (!issueMatch[2]) return json({ ...item, assigneeAgentId: agents[0].id });+ if (issueMatch[2] === "comments") return json([{ id: "persona-comment", issueId: item.id, companyId, authorAgentId: agents[0].id, authorUserId: null, body: "The implementation is ready for review. I’ve checked the edge cases and added coverage for the new behavior.", createdAt: item.updatedAt, updatedAt: item.updatedAt }]);+ if (issueMatch[2] === "active-run") return json(null);+ if (issueMatch[2] === "queued-comments") return json({ queues: [], revision: "storybook", items: [] });+ if (issueMatch[2] === "cost-summary") return json({ costCents: 340, inputTokens: 42000, outputTokens: 8200, runCount: 1 });+ if (issueMatch[2].startsWith("documents/")) return new Response(null, { status: 404 });+ return json([]);+ }+ if (path.endsWith("/budgets/overview")) return json({ companyId, policies: [], activeIncidents: [], pausedAgentCount: 0, pausedProjectCount: 0, pendingApprovalCount: 0 });+ if (path.includes("/heartbeat-runs/") && path.endsWith("/events")) return json([]);+ // Reuse the preview's auth, company, adapter, issue-list and environment fixtures.+ if (path === "/api/companies" || path.startsWith("/api/auth/") || path.includes("/adapters") || path.includes("/environments") || path.endsWith("/issues") || path.endsWith("/projects") || path.endsWith("/approvals") || path.endsWith("/sidebar-badges") || path.endsWith("/user-directory")) return previous(input, init);+ if (path.includes("/settings")) return json({});+ return json([]);+ };+ return () => { window.fetch = previous; };+}++function PersonaPage({ path, meet = false }: { path: string; meet?: boolean }) {+ const navigate = useNavigate();+ const location = useLocation();+ const queryClient = useQueryClient();+ const { selectedCompanyId, setSelectedCompanyId } = useCompany();+ const [ready, setReady] = useState(false);+ const [dialogOpen, setDialogOpen] = useState(meet);+ const initialPath = useRef<string | null>(null);+ useEffect(() => installPageFixtures(), []);+ useEffect(() => {+ if (initialPath.current === path) return;+ initialPath.current = path;+ queryClient.setQueryData(queryKeys.agents.list(companyId), agents);+ // Shared polling elects a leader asynchronously; seed the visible panel so+ // its initial render is independent of that election and the avatar cache.+ queryClient.setQueryData([...queryKeys.liveRuns(companyId), "dashboard", { minRunCount: 4, fetchLimit: undefined }], liveRuns);+ for (const agent of agents) {+ for (const ref of [agent.id, agent.urlKey]) queryClient.setQueryData([...queryKeys.agents.detail(ref!), companyId], agent);+ }+ setSelectedCompanyId(companyId);+ navigate(path, { replace: true });+ setReady(true);+ }, [path, navigate, queryClient, setSelectedCompanyId]);+ if (!ready || selectedCompanyId !== companyId || location.pathname === "/PAP/storybook") return null;+ return <PluginLauncherProvider>+ <Routes>+ <Route path="/:companyPrefix" element={<Layout />}>+ <Route path="agents" element={<Agents />} />+ <Route path="agents/all" element={<Agents />} />+ <Route path="agents/new" element={<NewAgent />} />+ <Route path="agents/:agentId/:tab?" element={<AgentDetail />} />+ <Route path="issues/:issueId" element={<IssueDetail />} />+ <Route path="dashboard" element={<Dashboard />} />+ </Route>+ </Routes>+ {meet && <AgentBasicsDialog open={dialogOpen} onClose={() => setDialogOpen(false)} onContinue={basics => { setDialogOpen(false); navigate(`/PAP/agents/new?name=${encodeURIComponent(basics.name)}&adapterType=${basics.adapterType}`); }} />}+ </PluginLauncherProvider>;+}+const meta = { title: "Agents/Personas/Full pages", parameters: { layout: "fullscreen", a11y: { test: "off" } } } satisfies Meta;+export default meta;+type Story = StoryObj;+export const AllAgents: Story = { render: () => <PersonaPage path="/PAP/agents/all" /> };+export const AgentOverview: Story = { render: () => <PersonaPage path="/PAP/agents/codexcoder/overview" /> };+export const Task: Story = { render: () => <PersonaPage path={`/PAP/issues/${issue.identifier}`} /> };+export const CompanyDashboard: Story = { name: "Dashboard", render: () => <PersonaPage path="/PAP/dashboard" /> };+export const MeetYourNextAgent: Story = { render: () => <PersonaPage path="/PAP/agents/all" meet /> };+export const NewAgentConnection: Story = { render: () => <PersonaPage path="/PAP/agents/new?name=Carl&adapterType=codex_local" /> };diff --git a/ui/storybook/stories/agent-personas.stories.tsx b/ui/storybook/stories/agent-personas.stories.tsxnew file mode 100644index 0000000000..007972cf98--- /dev/null+++ b/ui/storybook/stories/agent-personas.stories.tsx@@ -0,0 +1,130 @@+import { agentAvatarUrl } from "@/lib/agent-avatar-url";+import { expect, waitFor } from "storybook/test";+import { useEffect, useRef, useState } from "react";+import type { Meta, StoryObj } from "@storybook/react-vite";+import { AGENT_PALETTE_IDS, AGENT_AVATAR_SIZES, CHARACTER_STATES, appearanceForPalette, type CharacterState } from "@paperclipai/shared";+import { AgentAvatar, avatarSizeClasses } from "../../src/components/AgentAvatar";+import { AgentCharacter } from "../../src/components/AgentCharacter";+import { AgentIdentity } from "../../src/components/AgentIdentity";+import { Button } from "../../src/components/ui/button";++const appearance = appearanceForPalette("bubblegum-sky");+const agent = { id: "storybook-agent", name: "Chief of Staff", appearance };+const meta = {+ title: "Agents/Personas",+ component: AgentCharacter,+ args: { appearance, size: 256, state: "listening", label: "Chief of Staff" },+ parameters: { docs: { description: { component: "Persistent cap-v1 identities. Avatars request on-demand PNGs from Paperclip; the hero alone loads ClipLab. Development Storybook uses PAPERCLIP_STORYBOOK_API_URL. Published Storybook packages PNGs from the same API renderer automatically during its build, including every preset and both densities; no running API is required." } } },+ argTypes: {+ state: { control: "select", options: CHARACTER_STATES },+ size: { control: "select", options: AGENT_AVATAR_SIZES },+ motion: { control: "select", options: ["auto", "still"] },+ trackingScope: { control: "select", options: ["region", "page"] },+ },+} satisfies Meta<typeof AgentCharacter>;+export default meta;+type Story = StoryObj<typeof meta>;+export const LiveCharacter: Story = {};+export const ReducedMotion: Story = { args: { motion: "still" } };+export const GrayBeforeConnection: Story = { args: { muted: true, state: "sleepy" } };+export const Palettes: Story = {+ render: () => <div className="grid grid-cols-4 gap-6">{AGENT_PALETTE_IDS.map(palette => <div key={palette} className="flex flex-col items-center gap-2">+ <AgentAvatar appearance={appearanceForPalette(palette)} size={96} label={palette} /><span className="text-xs">{palette}</span>+ </div>)}</div>,+};+export const Sizes: Story = {+ render: () => <div className="flex flex-wrap items-end gap-4">{AGENT_AVATAR_SIZES.map(size => <div key={size} className="flex flex-col items-center gap-2">+ <AgentAvatar agent={agent} size={size} /><span className="text-xs">{size} px</span>+ </div>)}</div>,+};+export const Expressions: Story = {+ render: () => <div className="grid grid-cols-3 gap-4">{CHARACTER_STATES.map(state => <div key={state} className="flex flex-col items-center gap-2">+ <AgentCharacter appearance={appearance} state={state} motion="still" size={128} /><span className="text-xs">{state}</span>+ </div>)}</div>,+};+export const LightAndDark: Story = {+ render: () => <div className="flex gap-4">{["light", "dark"].map(theme => <div key={theme} className={`${theme} bg-background p-6 text-foreground`}>+ <AgentIdentity agent={agent} /><AgentAvatar agent={agent} size={128} />+ </div>)}</div>,+};+export const StaticAndLive: Story = {+ render: () => <div className="flex items-center gap-8"><AgentAvatar agent={agent} pose="listening" size={256} /><AgentCharacter agent={agent} state="listening" /></div>,+};+function Onboarding() {+ const [state, setState] = useState<CharacterState>("sleepy");+ const region = useRef<HTMLDivElement>(null);+ return <div ref={region} className="flex max-w-lg flex-col items-center gap-4 p-6">+ <AgentCharacter appearance={appearance} state={state} muted={state === "sleepy" || state === "loading"} trackingRegion={region} />+ <h2 className="text-lg font-semibold">{state === "success" ? "Ready to work" : "Connect your agent"}</h2>+ <div className="flex gap-2"><Button onClick={() => setState("loading")}>Connecting</Button><Button onClick={() => setState("success")}>Connection succeeded</Button><Button variant="outline" onClick={() => setState("sleepy")}>Reset</Button></div>+ </div>;+}+export const OnboardingTransition: Story = { render: () => <Onboarding /> };+export const AppPlacements: Story = {+ render: () => <div className="grid max-w-3xl gap-6">+ <section className="space-y-3"><h2 className="text-lg font-semibold">Agents</h2>{AGENT_PALETTE_IDS.slice(0, 4).map((palette, i) => <div className="flex items-center justify-between gap-4" key={palette}>+ <AgentIdentity agent={{ id: palette, name: ["Chief of Staff", "Researcher", "Designer", "Engineer"][i], appearance: appearanceForPalette(palette) }} /><span className="text-xs text-muted-foreground">Idle</span>+ </div>)}</section>+ <section className="space-y-2"><h2 className="text-lg font-semibold">Task conversation</h2><AgentIdentity agent={agent} size="sm" /><p className="text-sm">The launch brief is ready for review.</p></section>+ <section className="flex items-center justify-between gap-4"><span className="text-sm">Prepare the launch brief</span><AgentAvatar agent={agent} size={20} label="Assigned to Chief of Staff" /></section>+ <section className="flex items-center gap-6"><AgentCharacter agent={agent} size={128} /><div><h2 className="text-lg font-semibold">Agent configuration</h2><p className="text-sm text-muted-foreground">Chief of Staff · Connected</p></div></section>+ </div>,+};+export const FiveHundredStaticAvatars: Story = {+ render: () => <div className="grid grid-cols-10 gap-2">{Array.from({ length: 500 }, (_, i) => <AgentAvatar key={i} appearance={appearanceForPalette(AGENT_PALETTE_IDS[i % AGENT_PALETTE_IDS.length])} size={24} />)}</div>,+};+export const LegacyIdentity: Story = { render: () => <AgentIdentity agent={{ id: "legacy-agent", name: "Existing agent" }} /> };+function Lifecycle() {+ const [mounted, setMounted] = useState(true);+ return <div className="space-y-4"><Button onClick={() => setMounted(value => !value)}>Toggle character</Button>{mounted && <AgentCharacter agent={agent} />}</div>;+}+export const MountAndUnmount: Story = { render: () => <Lifecycle /> };+export const OneLiveRenderer: Story = { render: () => <div className="flex gap-6"><AgentCharacter agent={agent} /><AgentCharacter appearance={appearanceForPalette("arctic-blue")} /></div> };+export const ImageFailure: Story = {+ render: () => <AgentAvatar appearance={appearance} name="Chief of Staff" size={64} />,+ play: async ({ canvasElement }) => {+ // Exercise the actual image error handler without a custom product URL API.+ canvasElement.querySelector("img")?.dispatchEvent(new Event("error"));+ await waitFor(() => expect(canvasElement.textContent).toContain("CS"));+ },+};+export const CacheMissLoading: Story = {+ render: () => <div className="flex items-center gap-4"><AgentAvatar agent={agent} size={64} /><span className="text-sm">The image slot keeps its dimensions while Paperclip renders a cold cache entry.</span></div>,+};+function WebGLFailure() {+ const region = useRef<HTMLDivElement>(null);+ return <div ref={region} className="space-y-4"><AgentCharacter agent={agent} />+ <Button onClick={() => region.current?.querySelector("canvas")?.dispatchEvent(new Event("webglcontextlost", { cancelable: true }))}>Simulate WebGL loss</Button>+ </div>;+}+export const RenderFailure: Story = { render: () => <WebGLFailure /> };+export const PointerScope: Story = {+ render: () => <div className="flex items-start gap-8"><Onboarding /><p className="text-sm">Pointer movement outside the connection panel does not move the character. Touch and reduced motion disable tracking.</p></div>,+};++// A seeked WebGL frame lets Linux visual tests compare the identical front-facing+// sample with the server SVG/raster path. It schedules no animation frames.+type SnapshotPairProps = { size?: typeof AGENT_AVATAR_SIZES[number]; state?: CharacterState; density?: 1 | 2 };+function SnapshotPair({ size = 256, state = "rest", density = 2 }: SnapshotPairProps) {+ const host = useRef<HTMLSpanElement>(null);+ useEffect(() => {+ let disposed = false;+ let cleanup: (() => void) | undefined;+ void Promise.all([import("@paperclipai/shared/cliplab/renderer"), import("@paperclipai/shared/cliplab/definition")]).then(([{ CharacterRenderer }, library]) => {+ if (disposed || !host.current) return;+ const canvas = document.createElement("canvas");+ canvas.className = "size-full";+ const renderer = new CharacterRenderer(canvas, { width: size, height: size, displaySize: size, pixelRatio: density });+ const definition = library.characterDefinition(appearance);+ renderer.render({ ...definition.character, trueFront: true, lockPosition: true, followCursor: false, followRotation: false }, library.characterStill(definition, state), { rotation: { x: 0, y: 0, z: 0 } });+ host.current.appendChild(canvas);+ cleanup = () => { renderer.dispose(); canvas.remove(); };+ });+ return () => { disposed = true; cleanup?.(); };+ }, [size, state, density]);+ return <div className="flex items-start gap-8">+ <div className="space-y-3"><span data-testid="static-frame" className={`inline-block ${avatarSizeClasses[size]}`}><img src={agentAvatarUrl(appearance, size, density, state)} width={size} height={size} className="size-full object-contain" alt="Static PNG portrait" /></span><p className="text-xs text-muted-foreground">PNG · {size * density} × {size * density}</p></div>+ <div className="space-y-3"><span data-testid="live-frame" ref={host} className={`inline-block ${avatarSizeClasses[size]}`} /><p className="text-xs text-muted-foreground">WebGL · {size * density} × {size * density}</p></div>+ </div>;+}+export const SnapshotAgreement = { args: { size: 256, state: "rest", density: 2 }, argTypes: { density: { control: "inline-radio", options: [1, 2] } }, render: (args: SnapshotPairProps) => <SnapshotPair {...args} /> } satisfies StoryObj<SnapshotPairProps>;